{
  "openapi": "3.0.4",
  "info": {
    "version": "1.0.0",
    "title": "Credit",
    "description": "This is OpenAPI Spec APIs for external partners to invoke the checkout process running the credit for the order.",
    "contact": {
      "name": "Omni API Support",
      "email": "DL-OmniAdapter@att.com"
    }
  },
  "servers": [
    {
      "url": "https://partner-omni-apis.att.com/omni-svcs"
    }
  ],
  "tags": [
    {
      "name": "sales-operations",
      "description": "Sales Operation"
    }
  ],
  "paths": {
    "/v1/order/{orderid}/credit": {
      "post": {
        "tags": [
          "sales-operations"
        ],
        "description": "Credit Check for an order",
        "summary": "Credit",
        "operationId": "invokeCreditCheck",
        "parameters": [
          {
            "name": "orderid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Order ID"
          }
        ],
        "requestBody": {
          "description": "Credit transaction request payload",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Credit"
              },
              "examples": {
                "CreditPolicy": {
                  "summary": "credit policy request for the order",
                  "value": {
                    "runPolicy": true
                  }
                },
                "CreditquestionsAndAnswers": {
                  "summary": "credit answers request for the order",
                  "value": {
                    "selectedAnswers": [
                      {
                        "questionId": "",
                        "answerId": ""
                      }
                    ]
                  }
                },
                "InquireCreditStatus": {
                  "summary": "Inquire Credit status",
                  "value": {
                    "unifiedCreditTransactionId": "UAS1234",
                    "casApplicationId": "123"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/CreditResponse"
          },
          "400": {
            "$ref": "#/components/responses/CreditErrorResponse"
          }
        }
      }
    }
  },
  "components": {
    "requestBodies": {
      "CreditRequest": {
        "description": "Credit transaction request payload",
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Credit"
            },
            "examples": {
              "CreditPolicy": {
                "summary": "credit policy request for the order",
                "value": {
                  "runPolicy": true
                }
              },
              "CreditquestionsAndAnswers": {
                "summary": "credit answers request for the order",
                "value": {
                  "selectedAnswers": [
                    {
                      "questionId": "",
                      "answerId": ""
                    }
                  ]
                }
              },
              "InquireCreditStatus": {
                "summary": "Inquire Credit status",
                "value": {
                  "unifiedCreditTransactionId": "UAS1234",
                  "casApplicationId": "123"
                }
              }
            }
          }
        }
      }
    },
    "responses": {
      "CreditResponse": {
        "description": "Credit transaction request payload",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/CreditResponse"
            },
            "examples": {
              "CreditPolicyResponse": {
                "summary": "credit policy result",
                "value": {
                  "unifiedPolicyTransactionId": "P20210818000068739",
                  "riskAssessmentResult": [
                    {
                      "productType": "wireline",
                      "securityType": "ADVPAY",
                      "securityDescription": "advance pay",
                      "securityAmount": 100,
                      "productOrderItemId": "!234"
                    }
                  ]
                }
              },
              "CreditquestionsAndAnswersResponse": {
                "summary": "credit questions and answers response",
                "value": {
                  "unifiedCreditTransactionId": "P20210818000068739",
                  "eidVerifierCode": true
                }
              },
              "CreditCheckAnalystResponse": {
                "summary": "credit check analyst review response",
                "value": {
                  "unifiedCreditTransactionId": "U20230224407318536",
                  "casApplicationId": "1234",
                  "risk": "AnalystReview"
                }
              },
              "CreditCheckDebtResponse": {
                "summary": "credit check debt response",
                "value": {
                  "unifiedCreditTransactionId": "U20230224407318536",
                  "casApplicationId": "1234",
                  "risk": "BadPaymentRisk",
                  "debt": [
                    {
                      "accountNumber": "",
                      "debtDetails": {
                        "accountBalance": 100
                      }
                    }
                  ]
                }
              },
              "CreditCheckFraudRiskResponse": {
                "summary": "credit check fraud risk result",
                "value": {
                  "unifiedCreditTransactionId": "U20230224407318536",
                  "casApplicationId": "1234",
                  "risk": "FraudRisk"
                }
              },
              "CreditStatusResult": {
                "summary": "Credit status Result",
                "value": {
                  "unifiedCreditTransactionId": "",
                  "casApplicationId": "",
                  "unifiedPolicyTransactionId": "",
                  "creditDisclosureRequired": true,
                  "eidVerifierCode": true
                }
              }
            }
          }
        }
      },
      "CreditErrorResponse": {
        "description": "Error Response body for credit transaction",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "validation": {
                  "$ref": "#/components/schemas/Validation"
                },
                "error": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Credit": {
        "type": "object",
        "properties": {
          "unifiedCreditTransactionId": {
            "type": "string",
            "example": "U20230224407318536"
          },
          "casApplicationId": {
            "type": "string",
            "example": ""
          },
          "runPolicy": {
            "type": "boolean"
          },
          "unifiedPolicyTransactionId": {
            "type": "string",
            "example": ""
          },
          "selectedAnswers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "questionId": {
                  "type": "string",
                  "example": "1"
                },
                "answerId": {
                  "type": "string",
                  "example": "1"
                }
              },
              "required": [
                "questionId",
                "answerId"
              ]
            }
          },
          "creditDisclosureRequired": {
            "type": "boolean"
          },
          "eidVerifierCode": {
            "type": "boolean"
          }
        }
      },
      "CreditResponse": {
        "type": "object",
        "properties": {
          "unifiedCreditTransactionId": {
            "type": "string",
            "example": "U20230224407318536"
          },
          "casApplicationId": {
            "type": "string",
            "example": ""
          },
          "unifiedPolicyTransactionId": {
            "type": "string",
            "example": ""
          },
          "creditDisclosureRequired": {
            "type": "boolean"
          },
          "eidVerifierCode": {
            "type": "boolean"
          },
          "debt": {
            "$ref": "#/components/schemas/DebtAccountDetails"
          },
          "riskAssessmentResult": {
            "$ref": "#/components/schemas/RiskAssessmentResult"
          }
        }
      },
      "RiskAssessmentResult": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "productType": {
              "type": "string",
              "example": "WIRELINE_PRODUCTS"
            },
            "securityType": {
              "type": "string",
              "example": "ADVPAY"
            },
            "securityDescription": {
              "type": "string",
              "example": "Advance Pay"
            },
            "securityAmount": {
              "type": "number",
              "example": 100
            },
            "productOrderItemId": {
              "type": "string",
              "example": ""
            }
          }
        }
      },
      "DebtAccountDetails": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "accountNumber": {
              "type": "string",
              "example": "117293950"
            },
            "billingAddress": {
              "$ref": "#/components/schemas/BillingAddress"
            },
            "billingFullName": {
              "type": "string",
              "example": "SANDRA HOOD"
            },
            "debtDetails": {
              "$ref": "#/components/schemas/DebtDetails"
            }
          }
        }
      },
      "BillingAddress": {
        "type": "object",
        "properties": {
          "addressCharacteristic": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AddressCharacteristic"
            }
          },
          "city": {
            "type": "string",
            "example": "GARLAND"
          },
          "geographicSubAddress": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "postcode": {
            "type": "string",
            "example": "75044"
          },
          "stateOrProvince": {
            "type": "string",
            "example": "TX"
          }
        }
      },
      "AddressCharacteristic": {
        "type": "object",
        "properties": {
          "characteristicRelationship": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "metadata": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "name": {
            "type": "string",
            "example": "addressLine1"
          },
          "value": {
            "type": "string",
            "example": "517 BALTUSROL CIR"
          },
          "valueMetadata": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "DebtDetails": {
        "type": "object",
        "properties": {
          "accountBalance": {
            "type": "number",
            "format": "float",
            "example": 101.54
          },
          "accountStatus": {
            "type": "string",
            "example": "O"
          },
          "billRenderDate": {
            "type": "string",
            "format": "date"
          },
          "minimumAmountDue": {
            "type": "number",
            "format": "float",
            "example": 101.54
          },
          "pastDueAmount": {
            "type": "number",
            "format": "float",
            "example": 101.54
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string",
            "example": "<400-INVALID-REQUEST>"
          },
          "errorDescription": {
            "type": "string",
            "example": "Validation Failure"
          },
          "errorList": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "action": {
                  "type": "string",
                  "example": "credit",
                  "description": "Holds the action that is being perfomed causing the error"
                },
                "errorCode": {
                  "type": "string",
                  "example": "CREDIT-XXX"
                },
                "errorDescription": {
                  "type": "string",
                  "example": "CREDIT xxx"
                },
                "errorDetails": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "system": {
                        "type": "string",
                        "example": "CREDIT"
                      },
                      "errorCode": {
                        "type": "string",
                        "example": "CREDITXXX"
                      },
                      "errorDescription": {
                        "type": "string",
                        "example": "CREDITXXX"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Validation": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "Status of the order"
          },
          "readyToSubmit": {
            "type": "boolean",
            "description": "Indicates if the order is ready to submit"
          },
          "validationMessage": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string",
                  "description": "Validation message text"
                },
                "type": {
                  "type": "string",
                  "description": "Component type"
                },
                "parameter": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "Holds the value for any line level error ids"
                      },
                      "value": {
                        "type": "string",
                        "description": "Value of the parameter name"
                      }
                    }
                  }
                }
              }
            }
          },
          "configuration": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "description": "Configuration type"
                },
                "status": {
                  "type": "string",
                  "description": "Configuration status"
                },
                "required": {
                  "type": "boolean",
                  "description": "Indicates if the configuration is required"
                },
                "postOrderConfigurable": {
                  "type": "boolean",
                  "description": "Indicates if the configuration is post-order configurable"
                }
              }
            }
          }
        }
      }
    }
  }
}