openapi: 3.1.0

info:
  title: Consumer Offers - Terminate Endpoint
  version: 1.0.0
  description: |
    # Overview
    Use this operation to terminate a consumer offer.

servers:
  - url: https://resale.api.sandbox.bango.com
    description: Integration test environment
  - url: https://resale.api.bango.com
    description: Production environment

security:
  - basic: []

tags:
  - name: Consumer Offers
    description: Manage the lifecycle of your consumer offers

paths:
  /consumerOffers/{consumerOfferId}/terminate:
    post:
      tags:
        - Consumer Offers
      summary: Terminate Consumer Offer
      description: Use this operation to terminate a consumer offer
      operationId: TerminateConsumerOffer
      parameters:
        - name: consumerOfferId
          in: path
          description: Consumer offer ID
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TerminateConsumerOfferInput'
            example:
              cancelReasonCategory: ACTIVATION_ROLLBACK
              cancelReasonCode: FRAUD
              cancelReasonDescription: Personal data stolen
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelResponse'
              examples:
                Accepted:
                  value:
                    consumerOffer:
                      consumerOfferId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
                      offerId: "b2c3d4e5-f6a7-8901-bcde-f12345678901"
                      status: FULLY_TERMINATED
                    entitlements:
                      - entitlementId: "c3d4e5f6-a7b8-9012-cdef-123456789012"
                        status: ENDED
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseObject'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseObject'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseObject'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseObject'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseObject'

components:
  securitySchemes:
    basic:
      type: http
      scheme: basic

  schemas:
    TerminateConsumerOfferInput:
      type: object
      properties:
        cancelReasonCategory:
          type: string
          description: High-level category for the cancellation reason
          example: ACTIVATION_ROLLBACK
        cancelReasonCode:
          type: string
          description: Specific cancellation reason code
          example: FRAUD
        cancelReasonDescription:
          type: string
          description: Detailed reason for termination
          maxLength: 500
          example: Personal data stolen

    ModelResponse:
      type: object
      properties:
        consumerOffer:
          $ref: '#/components/schemas/ConsumerOffer'
        entitlements:
          type: array
          items:
            $ref: '#/components/schemas/Entitlement'

    ConsumerOffer:
      type: object
      properties:
        consumerOfferId:
          type: string
          format: uuid
        offerId:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - REQUESTED
            - CREATES_FAILED
            - FULLY_CREATED
            - PARTIALLY_CREATED
            - FULLY_ACTIVE
            - FULLY_TERMINATED

    Entitlement:
      type: object
      properties:
        entitlementId:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - REQUESTED
            - CREATED
            - ACTIVE
            - CREATE_FAILED
            - ENDED
            - SUSPENDED

    ErrorResponseObject:
      type: object
      properties:
        responseCode:
          type: string
        responseMessage:
          type: string
        metadata:
          $ref: '#/components/schemas/Metadata'

    Metadata:
      type: object
      properties:
        responseMessageFrom:
          type: string
          description: The originator of the error (either Bango or the content provider)
          enum:
            - BANGO
            - MERCHANT