{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/InsertRuleRequest",
  "title": "InsertRuleRequest",
  "required": [
    "name",
    "salesChannels",
    "paymentSystem",
    "connector",
    "issuer",
    "antifraud",
    "installmentOptions",
    "isSelfAuthorized",
    "requiresAuthentication",
    "enabled",
    "installmentsService",
    "isDefault",
    "beginDate",
    "endDate",
    "condition",
    "multiMerchantList",
    "country",
    "dateIntervals"
  ],
  "type": "object",
  "description": "New payment rule request body information.",
  "properties": {
    "name": {
      "type": "string",
      "description": "Rule name.",
      "example": "Test_API_2"
    },
    "salesChannels": {
      "$ref": "#/components/schemas/SalesChannel"
    },
    "paymentSystem": {
      "$ref": "#/components/schemas/PaymentSystem"
    },
    "connector": {
      "$ref": "#/components/schemas/Connector"
    },
    "issuer": {
      "$ref": "#/components/schemas/Issuer"
    },
    "antifraud": {
      "$ref": "#/components/schemas/Antifraud"
    },
    "installmentOptions": {
      "required": [
        "dueDateType",
        "interestRateMethod",
        "minimumInstallmentValue",
        "installments"
      ],
      "type": "object",
      "description": "Installment options information.",
      "nullable": true,
      "properties": {
        "dueDateType": {
          "type": "number",
          "description": "Indicates whether the billing date will be at the end (0) or beginning of the period (1).",
          "enum": [
            0,
            1
          ]
        },
        "interestRateMethod": {
          "type": "number",
          "description": "Indicates the type of interest to calculate the value of the installments (Compound Interest = `null` or `0`, Simple Interest Rate with Tax = `1` and Single Interest = `2`).",
          "enum": [
            null,
            0,
            1,
            2
          ],
          "nullable": true
        },
        "minimumInstallmentValue": {
          "type": "number",
          "description": "Minimum value of each installment."
        },
        "installments": {
          "type": "array",
          "description": "Array containing installments information.",
          "items": {
            "required": [
              "ruleId",
              "quantity",
              "value",
              "interestRate",
              "isExternalInstallmentService",
              "interestTax"
            ],
            "type": "object",
            "description": "Installments information.",
            "properties": {
              "ruleId": {
                "type": "string",
                "description": "Rule identification.",
                "example": "fe6c470b-f80b-4bb1-a75c-378617f8767a",
                "nullable": true
              },
              "quantity": {
                "type": "integer",
                "description": "Number of installments.",
                "example": 1
              },
              "value": {
                "type": "number",
                "description": "Value of each installment."
              },
              "interestRate": {
                "type": "number",
                "description": "Interest rate (percent 0.1 = 10%)."
              },
              "isExternalInstallmentService": {
                "type": "number",
                "description": "Indicates the external installment system (if applicable).",
                "nullable": true
              },
              "interestTax": {
                "type": "number",
                "description": "Interest tax (percent 0.1 = 10%).",
                "nullable": true
              }
            }
          }
        }
      }
    },
    "isSelfAuthorized": {
      "type": "boolean",
      "description": "Indicates whether the payment is automatically authorized.",
      "example": true,
      "nullable": true
    },
    "requiresAuthentication": {
      "type": "boolean",
      "description": "Indicates whether it is necessary to log in to make the payment.",
      "example": true,
      "nullable": true
    },
    "enabled": {
      "type": "boolean",
      "description": "Indicates whether the rule is enabled in the store.",
      "example": false
    },
    "installmentsService": {
      "type": "boolean",
      "description": "Indicates whether any specific type of installment service is used.",
      "example": false
    },
    "isDefault": {
      "type": "boolean",
      "description": "Indicates whether this rule should be considered the default for a given payment condition.",
      "example": false,
      "nullable": true
    },
    "beginDate": {
      "type": "string",
      "description": "Rule start date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format (`YYYY-MM-DDThh:mm:ss.fff`), if applicable.",
      "example": "2023-12-10T17:00:00Z",
      "nullable": true
    },
    "endDate": {
      "type": "string",
      "description": "Rule end date in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format (`YYYY-MM-DDThh:mm:ss.fff`), if applicable.",
      "example": "2023-12-12T17:00:00Z",
      "nullable": true
    },
    "condition": {
      "required": [
        "id",
        "pullRate",
        "name"
      ],
      "type": "object",
      "description": "Commercial condition information.",
      "nullable": true,
      "properties": {
        "id": {
          "type": "string",
          "description": "Commercial condition identification.",
          "example": "1"
        },
        "pullRate": {
          "type": "number",
          "description": "Indicates the minimum percentage of SKUs required in the cart using this commercial condition for it to be activated.",
          "example": 0
        },
        "name": {
          "type": "string",
          "description": "Commercial condition information.",
          "example": "Commercial_condition_1",
          "nullable": true
        }
      }
    },
    "multiMerchantList": {
      "type": "array",
      "description": "Indicates the names of the accounts to which the rule is being applied exclusively.",
      "items": {
        "type": "string",
        "description": "Account names.",
        "example": "test_store_1"
      },
      "nullable": true
    },
    "country": {
      "required": [
        "name",
        "isoCode"
      ],
      "type": "object",
      "description": "Information about rule application in a country.",
      "nullable": true,
      "properties": {
        "name": {
          "type": "string",
          "description": "Country name.",
          "example": "Brazil",
          "nullable": true
        },
        "isoCode": {
          "type": "string",
          "description": "Country code (ISO 3166 alpha-2).",
          "example": "BRA"
        }
      }
    },
    "dateIntervals": {
      "type": "array",
      "description": "Array containing information about the periods (days and hours) in which the rule is enabled.",
      "nullable": true,
      "items": {
        "required": [
          "start",
          "end"
        ],
        "type": "object",
        "description": "Rule enablement period information.",
        "properties": {
          "start": {
            "type": "string",
            "description": "Time, days of the week, and GMT time zone in which the rule is activated. This data is available in [CRON format](https://en.wikipedia.org/wiki/Cron).",
            "example": "* * 11 * * 1,3,4 * -0300"
          },
          "end": {
            "type": "string",
            "description": "Time, days of the week and GMT time zone in which the rule is deactivated. This data is available in [CRON format](https://en.wikipedia.org/wiki/Cron).",
            "example": "* * 18 * * 1,3,4 * -0300"
          }
        }
      }
    },
    "externalInterest": {
      "type": "boolean",
      "description": "Indicates whether interest can be calculated externally.",
      "example": false
    },
    "minimumValue": {
      "type": "number",
      "description": "Minimum payment transaction amount for the rule to be applied.",
      "nullable": true
    },
    "deadlines": {
      "type": "array",
      "description": "Array containing information about the payment deadlines (applicable for credit payment method).",
      "items": {
        "type": "object",
        "description": "Payment deadlines information.",
        "required": [
          "paymentOptions"
        ],
        "properties": {
          "paymentOptions": {
            "type": "array",
            "description": "Array containing payment options information.",
            "items": {
              "required": [
                "days",
                "interestRate"
              ],
              "type": "object",
              "description": "Payment options information.",
              "properties": {
                "days": {
                  "type": "number",
                  "description": "Deadline in days to make payment.",
                  "example": 30
                },
                "interestRate": {
                  "type": "number",
                  "description": "Interest rate applied (in percentage, e.g. `3.0` means 3%).",
                  "example": 0
                }
              }
            }
          }
        }
      }
    },
    "cobrand": {
      "required": [
        "name"
      ],
      "type": "object",
      "description": "Information about the cobranded card.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Card name.",
          "example": "Cobrand_Test",
          "nullable": true
        }
      }
    },
    "cardLevel": {
      "required": [
        "name"
      ],
      "type": "object",
      "description": "Information about the card category.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Card category name (e.g. standard, gold, premium).",
          "example": "premium",
          "nullable": true
        }
      }
    },
    "excludedBinsRanges": {
      "type": "number",
      "description": "Range of card bins excluded from application of this rule.",
      "nullable": true
    }
  }
}