{
    "openapi":  "3.1.0",
    "info":  {
                 "title":  "bitLogin Loyalty API",
                 "description":  "Loyalty configuration endpoints for bitLogin (integration toggle, point conversion, and reward options).",
                 "version":  "1.0.0"
             },
    "servers":  [
                    {
                        "url":  "https://api.bitbybit.studio",
                        "description":  "Production"
                    }
                ],
    "security":  [
                     {
                         "ApiKeyAuth":  [

                                        ]
                     }
                 ],
    "paths":  {
                  "/bitlogin/api/open/v1/loyalty/integration":  {
                                                                    "get":  {
                                                                                "operationId":  "getLoyaltyIntegration",
                                                                                "summary":  "Get loyalty integration status",
                                                                                "description":  "Get whether loyalty program is enabled for a company.",
                                                                                "tags":  [
                                                                                             "Loyalty - bitLogin"
                                                                                         ],
                                                                                "parameters":  [

                                                                                               ],
                                                                                "responses":  {
                                                                                                  "200":  {
                                                                                                              "description":  "Success",
                                                                                                              "content":  {
                                                                                                                              "application/json":  {
                                                                                                                                                       "schema":  {
                                                                                                                                                                      "$ref":  "#/components/schemas/LoyaltyIntegration"
                                                                                                                                                                  }
                                                                                                                                                   }
                                                                                                                          }
                                                                                                          }
                                                                                              }
                                                                            },
                                                                    "post":  {
                                                                                 "operationId":  "setLoyaltyIntegration",
                                                                                 "summary":  "Enable or disable loyalty integration",
                                                                                 "description":  "Enable or disable the loyalty program for a company.",
                                                                                 "tags":  [
                                                                                              "Loyalty - bitLogin"
                                                                                          ],
                                                                                 "parameters":  [

                                                                                                ],
                                                                                 "requestBody":  {
                                                                                                     "required":  true,
                                                                                                     "content":  {
                                                                                                                     "application/json":  {
                                                                                                                                              "schema":  {
                                                                                                                                                             "type":  "object",
                                                                                                                                                             "required":  [
                                                                                                                                                                              "enabled"
                                                                                                                                                                          ],
                                                                                                                                                             "properties":  {
                                                                                                                                                                                "enabled":  {
                                                                                                                                                                                                "type":  "boolean"
                                                                                                                                                                                            }
                                                                                                                                                                            }
                                                                                                                                                         }
                                                                                                                                          }
                                                                                                                 }
                                                                                                 },
                                                                                 "responses":  {
                                                                                                   "200":  {
                                                                                                               "description":  "Success",
                                                                                                               "content":  {
                                                                                                                               "application/json":  {
                                                                                                                                                        "schema":  {
                                                                                                                                                                       "$ref":  "#/components/schemas/LoyaltyIntegration"
                                                                                                                                                                   }
                                                                                                                                                    }
                                                                                                                           }
                                                                                                           }
                                                                                               }
                                                                             }
                                                                },
                  "/bitlogin/api/open/v1/loyalty/point-conversion":  {
                                                                         "get":  {
                                                                                     "operationId":  "getPointConversion",
                                                                                     "summary":  "Get point conversion tiers",
                                                                                     "description":  "Get conversion tiers used to convert currency amount to loyalty points.",
                                                                                     "tags":  [
                                                                                                  "Loyalty - bitLogin"
                                                                                              ],
                                                                                     "parameters":  [

                                                                                                    ],
                                                                                     "responses":  {
                                                                                                       "200":  {
                                                                                                                   "description":  "Success",
                                                                                                                   "content":  {
                                                                                                                                   "application/json":  {
                                                                                                                                                            "schema":  {
                                                                                                                                                                           "$ref":  "#/components/schemas/PointConversionResponse"
                                                                                                                                                                       }
                                                                                                                                                        }
                                                                                                                               }
                                                                                                               }
                                                                                                   }
                                                                                 },
                                                                         "post":  {
                                                                                      "operationId":  "setPointConversion",
                                                                                      "summary":  "Set point conversion tiers",
                                                                                      "description":  "Replace all point conversion tiers for a company.",
                                                                                      "tags":  [
                                                                                                   "Loyalty - bitLogin"
                                                                                               ],
                                                                                      "parameters":  [

                                                                                                     ],
                                                                                      "requestBody":  {
                                                                                                          "required":  true,
                                                                                                          "content":  {
                                                                                                                          "application/json":  {
                                                                                                                                                   "schema":  {
                                                                                                                                                                  "type":  "object",
                                                                                                                                                                  "required":  [
                                                                                                                                                                                   "tiers"
                                                                                                                                                                               ],
                                                                                                                                                                  "properties":  {
                                                                                                                                                                                     "tiers":  {
                                                                                                                                                                                                   "type":  "array",
                                                                                                                                                                                                   "items":  {
                                                                                                                                                                                                                 "$ref":  "#/components/schemas/PointConversionTierInput"
                                                                                                                                                                                                             }
                                                                                                                                                                                               }
                                                                                                                                                                                 }
                                                                                                                                                              }
                                                                                                                                               }
                                                                                                                      }
                                                                                                      },
                                                                                      "responses":  {
                                                                                                        "200":  {
                                                                                                                    "description":  "Success",
                                                                                                                    "content":  {
                                                                                                                                    "application/json":  {
                                                                                                                                                             "schema":  {
                                                                                                                                                                            "$ref":  "#/components/schemas/PointConversionResponse"
                                                                                                                                                                        }
                                                                                                                                                         }
                                                                                                                                }
                                                                                                                }
                                                                                                    }
                                                                                  }
                                                                     },
                  "/bitlogin/api/open/v1/loyalty/reward-options":  {
                                                                       "get":  {
                                                                                   "operationId":  "listRewardOptions",
                                                                                   "summary":  "List reward options",
                                                                                   "description":  "List all loyalty reward options for a company.",
                                                                                   "tags":  [
                                                                                                "Loyalty - bitLogin"
                                                                                            ],
                                                                                   "parameters":  [

                                                                                                  ],
                                                                                   "responses":  {
                                                                                                     "200":  {
                                                                                                                 "description":  "Success",
                                                                                                                 "content":  {
                                                                                                                                 "application/json":  {
                                                                                                                                                          "schema":  {
                                                                                                                                                                         "type":  "object",
                                                                                                                                                                         "properties":  {
                                                                                                                                                                                            "companyId":  {
                                                                                                                                                                                                              "type":  "integer"
                                                                                                                                                                                                          },
                                                                                                                                                                                            "rewardOptions":  {
                                                                                                                                                                                                                  "type":  "array",
                                                                                                                                                                                                                  "items":  {
                                                                                                                                                                                                                                "$ref":  "#/components/schemas/RewardOption"
                                                                                                                                                                                                                            }
                                                                                                                                                                                                              }
                                                                                                                                                                                        }
                                                                                                                                                                     }
                                                                                                                                                      }
                                                                                                                             }
                                                                                                             }
                                                                                                 }
                                                                               },
                                                                       "post":  {
                                                                                    "operationId":  "createRewardOption",
                                                                                    "summary":  "Create reward option",
                                                                                    "description":  "Create a reward option and corresponding Shopify price rule.",
                                                                                    "tags":  [
                                                                                                 "Loyalty - bitLogin"
                                                                                             ],
                                                                                    "parameters":  [

                                                                                                   ],
                                                                                    "requestBody":  {
                                                                                                        "required":  true,
                                                                                                        "content":  {
                                                                                                                        "application/json":  {
                                                                                                                                                 "schema":  {
                                                                                                                                                                "$ref":  "#/components/schemas/RewardOptionInput"
                                                                                                                                                            }
                                                                                                                                             }
                                                                                                                    }
                                                                                                    },
                                                                                    "responses":  {
                                                                                                      "201":  {
                                                                                                                  "description":  "Created",
                                                                                                                  "content":  {
                                                                                                                                  "application/json":  {
                                                                                                                                                           "schema":  {
                                                                                                                                                                          "$ref":  "#/components/schemas/RewardOption"
                                                                                                                                                                      }
                                                                                                                                                       }
                                                                                                                              }
                                                                                                              }
                                                                                                  }
                                                                                }
                                                                   },
                  "/bitlogin/api/open/v1/loyalty/reward-options/{id}":  {
                                                                            "get":  {
                                                                                        "operationId":  "getRewardOption",
                                                                                        "summary":  "Get reward option",
                                                                                        "description":  "Get reward option detail by id.",
                                                                                        "tags":  [
                                                                                                     "Loyalty - bitLogin"
                                                                                                 ],
                                                                                        "parameters":  [
                                                                                                           {
                                                                                                               "name":  "id",
                                                                                                               "in":  "path",
                                                                                                               "required":  true,
                                                                                                               "schema":  {
                                                                                                                              "type":  "string"
                                                                                                                          }
                                                                                                           }
                                                                                                       ],
                                                                                        "responses":  {
                                                                                                          "200":  {
                                                                                                                      "description":  "Success",
                                                                                                                      "content":  {
                                                                                                                                      "application/json":  {
                                                                                                                                                               "schema":  {
                                                                                                                                                                              "$ref":  "#/components/schemas/RewardOption"
                                                                                                                                                                          }
                                                                                                                                                           }
                                                                                                                                  }
                                                                                                                  },
                                                                                                          "404":  {
                                                                                                                      "description":  "Not found",
                                                                                                                      "content":  {
                                                                                                                                      "application/json":  {
                                                                                                                                                               "schema":  {
                                                                                                                                                                              "$ref":  "#/components/schemas/MessageError"
                                                                                                                                                                          }
                                                                                                                                                           }
                                                                                                                                  }
                                                                                                                  }
                                                                                                      }
                                                                                    },
                                                                            "put":  {
                                                                                        "operationId":  "updateRewardOption",
                                                                                        "summary":  "Update reward option",
                                                                                        "description":  "Update reward option and corresponding Shopify price rule.",
                                                                                        "tags":  [
                                                                                                     "Loyalty - bitLogin"
                                                                                                 ],
                                                                                        "parameters":  [
                                                                                                           {
                                                                                                               "name":  "id",
                                                                                                               "in":  "path",
                                                                                                               "required":  true,
                                                                                                               "schema":  {
                                                                                                                              "type":  "string"
                                                                                                                          }
                                                                                                           }
                                                                                                       ],
                                                                                        "requestBody":  {
                                                                                                            "required":  true,
                                                                                                            "content":  {
                                                                                                                            "application/json":  {
                                                                                                                                                     "schema":  {
                                                                                                                                                                    "$ref":  "#/components/schemas/RewardOptionInput"
                                                                                                                                                                }
                                                                                                                                                 }
                                                                                                                        }
                                                                                                        },
                                                                                        "responses":  {
                                                                                                          "200":  {
                                                                                                                      "description":  "Success",
                                                                                                                      "content":  {
                                                                                                                                      "application/json":  {
                                                                                                                                                               "schema":  {
                                                                                                                                                                              "$ref":  "#/components/schemas/RewardOption"
                                                                                                                                                                          }
                                                                                                                                                           }
                                                                                                                                  }
                                                                                                                  },
                                                                                                          "404":  {
                                                                                                                      "description":  "Not found",
                                                                                                                      "content":  {
                                                                                                                                      "application/json":  {
                                                                                                                                                               "schema":  {
                                                                                                                                                                              "$ref":  "#/components/schemas/MessageError"
                                                                                                                                                                          }
                                                                                                                                                           }
                                                                                                                                  }
                                                                                                                  }
                                                                                                      }
                                                                                    },
                                                                            "delete":  {
                                                                                           "operationId":  "deleteRewardOption",
                                                                                           "summary":  "Delete reward option",
                                                                                           "description":  "Delete reward option and corresponding Shopify price rule.",
                                                                                           "tags":  [
                                                                                                        "Loyalty - bitLogin"
                                                                                                    ],
                                                                                           "parameters":  [
                                                                                                              {
                                                                                                                  "name":  "id",
                                                                                                                  "in":  "path",
                                                                                                                  "required":  true,
                                                                                                                  "schema":  {
                                                                                                                                 "type":  "string"
                                                                                                                             }
                                                                                                              }
                                                                                                          ],
                                                                                           "responses":  {
                                                                                                             "204":  {
                                                                                                                         "description":  "No content"
                                                                                                                     },
                                                                                                             "404":  {
                                                                                                                         "description":  "Not found",
                                                                                                                         "content":  {
                                                                                                                                         "application/json":  {
                                                                                                                                                                  "schema":  {
                                                                                                                                                                                 "$ref":  "#/components/schemas/MessageError"
                                                                                                                                                                             }
                                                                                                                                                              }
                                                                                                                                     }
                                                                                                                     }
                                                                                                         }
                                                                                       }
                                                                        }
              },
    "components":  {
                       "securitySchemes":  {
                                               "ApiKeyAuth":  {
                                                                  "description":  "API key for authentication. Create one in Settings \u003e Developer.",
                                                                  "name":  "x-api-key",
                                                                  "in":  "header",
                                                                  "type":  "apiKey"
                                                              }
                                           },
                       "schemas":  {
                                       "MessageError":  {
                                                            "type":  "object",
                                                            "properties":  {
                                                                               "message":  {
                                                                                               "type":  "string"
                                                                                           }
                                                                           }
                                                        },
                                       "LoyaltyIntegration":  {
                                                                  "type":  "object",
                                                                  "properties":  {
                                                                                     "companyId":  {
                                                                                                       "type":  "integer"
                                                                                                   },
                                                                                     "enabled":  {
                                                                                                     "type":  "boolean"
                                                                                                 }
                                                                                 }
                                                              },
                                       "PointConversionTierInput":  {
                                                                        "type":  "object",
                                                                        "required":  [
                                                                                         "currencyAmount",
                                                                                         "points"
                                                                                     ],
                                                                        "properties":  {
                                                                                           "currencyAmount":  {
                                                                                                                  "description":  "Positive number as string/decimal with up to 4 decimals. Example: 5 or 5.25",
                                                                                                                  "oneOf":  [
                                                                                                                                {
                                                                                                                                    "type":  "string",
                                                                                                                                    "description":  "Positive number as string/decimal with up to 4 decimals. Example: 5 or 5.25"
                                                                                                                                },
                                                                                                                                {
                                                                                                                                    "type":  "number",
                                                                                                                                    "description":  "Positive number. Example: 5 or 5.25"
                                                                                                                                }
                                                                                                                            ]
                                                                                                              },
                                                                                           "points":  {
                                                                                                          "type":  "integer",
                                                                                                          "minimum":  1
                                                                                                      }
                                                                                       }
                                                                    },
                                       "PointConversionTier":  {
                                                                   "type":  "object",
                                                                   "properties":  {
                                                                                      "id":  {
                                                                                                 "type":  "string"
                                                                                             },
                                                                                      "currencyAmount":  {
                                                                                                             "type":  "number"
                                                                                                         },
                                                                                      "points":  {
                                                                                                     "type":  "integer"
                                                                                                 }
                                                                                  }
                                                               },
                                       "PointConversionResponse":  {
                                                                       "type":  "object",
                                                                       "properties":  {
                                                                                          "companyId":  {
                                                                                                            "type":  "integer"
                                                                                                        },
                                                                                          "tiers":  {
                                                                                                        "type":  "array",
                                                                                                        "items":  {
                                                                                                                      "$ref":  "#/components/schemas/PointConversionTier"
                                                                                                                  }
                                                                                                    }
                                                                                      }
                                                                   },
                                       "RewardOptionInput":  {
                                                                 "type":  "object",
                                                                 "required":  [
                                                                                  "rewardName",
                                                                                  "costToRedeem",
                                                                                  "discountType",
                                                                                  "discountValue",
                                                                                  "expirationPreset"
                                                                              ],
                                                                 "properties":  {
                                                                                    "rewardName":  {
                                                                                                       "type":  "string"
                                                                                                   },
                                                                                    "costToRedeem":  {
                                                                                                         "type":  "integer",
                                                                                                         "minimum":  1
                                                                                                     },
                                                                                    "discountType":  {
                                                                                                         "type":  "string",
                                                                                                         "enum":  [
                                                                                                                      "fixed_amount",
                                                                                                                      "percentage",
                                                                                                                      "free_shipping"
                                                                                                                  ]
                                                                                                     },
                                                                                    "discountValue":  {
                                                                                                          "description":  "Decimal string up to 4 decimals. Percentage must be 1-100.",
                                                                                                          "oneOf":  [
                                                                                                                        {
                                                                                                                            "type":  "string",
                                                                                                                            "description":  "Decimal string up to 4 decimals. Percentage must be 1-100."
                                                                                                                        },
                                                                                                                        {
                                                                                                                            "type":  "number",
                                                                                                                            "description":  "Decimal number up to 4 decimals. Percentage must be 1-100."
                                                                                                                        }
                                                                                                                    ]
                                                                                                      },
                                                                                    "voucherPrefix":  {
                                                                                                          "type":  "string",
                                                                                                          "nullable":  true
                                                                                                      },
                                                                                    "minimumPurchaseAmount":  {
                                                                                                                  "description":  "Decimal string up to 4 decimals.",
                                                                                                                  "oneOf":  [
                                                                                                                                {
                                                                                                                                    "type":  "string",
                                                                                                                                    "description":  "Decimal string up to 4 decimals."
                                                                                                                                },
                                                                                                                                {
                                                                                                                                    "type":  "number",
                                                                                                                                    "description":  "Decimal number up to 4 decimals."
                                                                                                                                }
                                                                                                                            ]
                                                                                                              },
                                                                                    "expirationPreset":  {
                                                                                                             "type":  "string",
                                                                                                             "enum":  [
                                                                                                                          "NO_EXPIRATION",
                                                                                                                          "SEVEN_DAYS",
                                                                                                                          "THIRTY_DAYS",
                                                                                                                          "NINETY_DAYS",
                                                                                                                          "ONE_YEAR"
                                                                                                                      ]
                                                                                                         }
                                                                                }
                                                             },
                                       "RewardOption":  {
                                                            "type":  "object",
                                                            "properties":  {
                                                                               "id":  {
                                                                                          "type":  "string"
                                                                                      },
                                                                               "companyId":  {
                                                                                                 "type":  "integer"
                                                                                             },
                                                                               "rewardName":  {
                                                                                                  "type":  "string"
                                                                                              },
                                                                               "costToRedeem":  {
                                                                                                    "type":  "integer"
                                                                                                },
                                                                               "discountType":  {
                                                                                                    "type":  "string",
                                                                                                    "enum":  [
                                                                                                                 "fixed_amount",
                                                                                                                 "percentage",
                                                                                                                 "free_shipping"
                                                                                                             ]
                                                                                                },
                                                                               "discountValue":  {
                                                                                                     "type":  "number"
                                                                                                 },
                                                                               "voucherPrefix":  {
                                                                                                     "type":  "string",
                                                                                                     "nullable":  true
                                                                                                 },
                                                                               "minimumPurchaseAmount":  {
                                                                                                             "type":  "number"
                                                                                                         },
                                                                               "expirationPreset":  {
                                                                                                        "type":  "string",
                                                                                                        "enum":  [
                                                                                                                     "NO_EXPIRATION",
                                                                                                                     "SEVEN_DAYS",
                                                                                                                     "THIRTY_DAYS",
                                                                                                                     "NINETY_DAYS",
                                                                                                                     "ONE_YEAR"
                                                                                                                 ]
                                                                                                    },
                                                                               "priceRuleId":  {
                                                                                                   "type":  "string"
                                                                                               },
                                                                               "startsAt":  {
                                                                                                "type":  "string",
                                                                                                "format":  "date-time"
                                                                                            },
                                                                               "endsAt":  {
                                                                                              "type":  [
                                                                                                           "string",
                                                                                                           "null"
                                                                                                       ],
                                                                                              "format":  "date-time"
                                                                                          },
                                                                               "createdAt":  {
                                                                                                 "type":  "string",
                                                                                                 "format":  "date-time"
                                                                                             },
                                                                               "updatedAt":  {
                                                                                                 "type":  "string",
                                                                                                 "format":  "date-time"
                                                                                             }
                                                                           }
                                                        }
                                   }
                   }
}
