swagger: "2.0"
info:
  description: |
    This API specification is describing sandbox APIs provided by Global Payments Marketplace.
    It is available in different formats including as Open API YAML specification.
  version: "1.3"
  title: "Marketplace Sandbox APIs"
  contact:
    email: "apiteam@mygp.global"
  license:
    name: "Global Payments Marketplace Partner Agreement 1.0"
    url: "https://mygp.cz/agreements/marketplace-partner-agreement-1.0"
basePath: "/v1/sandbox"
tags:
- name: "customers"
  description: "manipulation of sandbox customer records"
- name: "users"
  description: "manipulation of sandbox user data"
- name: "orders"
  description: "manipulation of sandbox customer orders"
schemes:
- "https"
paths:
  /customers:
    post:
      tags:
        - "customers"
      summary: "createSandboxCustomer"
      description: |
        New customer record is created for the sandbox.
      operationId: "createSandboxCustomer"
      parameters:
      - name: "request"
        in: "body"
        required: true
        schema:
          $ref: "#/definitions/CreateSandboxCustomerRequest"
      produces:
      - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/CreateSandboxCustomerResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
      security:
      - mygp_auth:
        - "manage_sandbox_data"
  /customers/{customer_key}/add-outlets:
    post:
      tags:
        - "customers"
      summary: "addOutletsToCustomer"
      description: |
        Appends new outlet (brick & mortar shop) records to an existing customer record.
        New outlet IDs must be unique and must not exist on the system.
      operationId: "addOutletsToCustomer"
      parameters:
        - name: "customer_key"
          in: "path"
          required: true
          type: string
        - name: "request"
          in: "body"
          description: |
            Only outlets property (array) of the request object must be populated.
          schema:
            $ref: "#/definitions/ModifySandboxCustomerRequest"
      produces:
        - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/AddOutletsToCustomerResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
  /customers/{customer_key}/subscriptions:
    get:
      tags:
        - "customers"
      summary: "getCustomerSubscriptions"
      description: |
        Returns list of active subscription records for sandbox customer account.
      operationId: "getCustomerSubscriptions"
      parameters:
        - name: "customer_key"
          in: "path"
          required: true
          type: string
      produces:
        - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/GetCustomerSubscriptionsResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
  /customers/{customer_key}/remove-outlets:
    post:
      tags:
        - "customers"
      summary: "removeOutletsFromCustomer"
      description: |
        Removes outlet (brick & mortar shop) records from an existing customer record.
        Outlet IDs must be linked to the customer record in order for the operation to
        have the desired effect.
      operationId: "removeOutletsFromCustomer"
      parameters:
        - name: "customer_key"
          in: "path"
          required: true
          type: string
        - name: "request"
          in: "body"
          description: |
            Only outlets property (array) of the request object must be populated.
          schema:
            $ref: "#/definitions/ModifySandboxCustomerRequest"
      produces:
        - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/ApiResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
  /customers/{customer_key}/add-gateways:
    post:
      tags:
        - "customers"
      summary: "addGatewaysToCustomer"
      description: |
        Appends new payment gateway records to an existing customer record.
        New gateway IDs must be unique and must not exist on the system.
      operationId: "addGatewaysToCustomer"
      parameters:
        - name: "customer_key"
          in: "path"
          required: true
          type: string
        - name: "request"
          in: "body"
          description: |
            Only gateways property (array) of the request object must be populated.
          schema:
            $ref: "#/definitions/ModifySandboxCustomerRequest"
      produces:
        - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/AddGatewaysToCustomerResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
  /customers/{customer_key}/remove-gateways:
    post:
      tags:
        - "customers"
      summary: "removeGatewaysFromCustomer"
      description: |
        Removes payment gateway records from an existing customer record.
        Gateway IDs must be linked to the customer record in order for the operation to
        have the desired effect.
      operationId: "removeGatewaysFromCustomer"
      parameters:
        - name: "customer_key"
          in: "path"
          required: true
          type: string
        - name: "request"
          in: "body"
          description: |
            Only gateways property (array) of the request object must be populated.
          schema:
            $ref: "#/definitions/ModifySandboxCustomerRequest"
      produces:
        - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/ApiResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
  /users:
    post:
      tags:
      - "users"
      summary: "createSandboxUser"
      description: |
        New user account invitation is created and connected with sandbox customer record.
      operationId: "createSandboxUser"
      parameters:
      - name: "request"
        in: "body"
        required: true
        schema:
          $ref: "#/definitions/CreateSandboxUserRequest"
      produces:
      - "application/json"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/CreateSandboxUserResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
      security:
      - mygp_auth:
        - "manage_sandbox_data"
  /orders:
    post:
      tags:
      - "orders"
      summary: "createSandboxOrder"
      description: |
        New customer order is placed for the sandbox customer record.
      operationId: "createSandboxOrder"
      parameters:
      - name: "request"
        in: "body"
        required: true
        schema:
          $ref: "#/definitions/CreateSandboxOrderRequest"
      responses:
        200:
          description: "successful operation"
          schema:
            $ref: "#/definitions/CreateSandboxOrderResponse"
        400:
          description: "bad request"
          schema:
            $ref: "#/definitions/ApiResponse"
        404:
          description: "customer record not found"
          schema:
            $ref: "#/definitions/ApiResponse"
      security:
      - mygp_auth:
        - "manage_sandbox_data"
securityDefinitions:
  mygp_auth:
    type: "oauth2"
    tokenUrl: "https://mygp.global/auth/realms/mygp-global/protocol/openid-connect/token"
    flow: "application"
    scopes:
      manage_sandbox_data: "manage sandbox data"
definitions:
  ApiResponse:
    type: "object"
    required:
      - code
      - message
    properties:
      code:
        type: "integer"
        format: "int32"
        example: 200
      message:
        type: "string"
        example: "SUCCESS"
      description:
        type: "string"
        example: "Request was completed successfully."
  CreateSandboxCustomerRequest:
    type: object
    properties:
      outlets:
        type: array
        items:
          type: string
        example:
          - "OUTMID99001"
          - "OUTMID99002"
      gateways:
        type: array
        items:
          type: string
        example:
          - "PGWMID99003"
          - "PGWMID99004"
          - "PGWMID99005"
  CreateSandboxCustomerResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - customer_key
        properties:
          customer_key:
            type: string
            example: "55a11fa2eaab24242d528a855b79973ee54319a1"
  CreateSandboxUserRequest:
    type: object
    required:
      - customer_key
    properties:
      customer_key:
        type: string
        example: "55a11fa2eaab24242d528a855b79973ee54319a1"
  CreateSandboxUserResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - invitation_url
        properties:
          customer_key:
            type: string
            example: "f11532a96d16a054f254362575035c59522e9c3f"
  CreateSandboxOrderRequest:
    type: object
    required:
      - customer_key
      - operation
    properties:
      customer_key:
        type: string
        example: "55a11fa2eaab24242d528a855b79973ee54319a1"
      operation:
        type: string
        enum:
          - ADD
          - MODIFY
          - REMOVE
        example: "ADD"
      offer_id:
        type: string
        format: uuid
        example: "3BE2B9E5-4C5C-4ED3-9F93-925DD77C0214"
      subscription_id:
        type: string
        format: uuid
        example: "375C7547-7B76-490A-8FE9-C59AE91B49DA"
  CreateSandboxOrderResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - order_id
        properties:
          order_id:
            type: string
            format: uuid
            example: "2D0FB6DA-5E9D-4599-952B-EC9AE0834E46"
  ModifySandboxCustomerRequest:
    type: object
    properties:
      outlets:
        type: array
        items:
          type: string
        example:
          - "OUTMID99001"
          - "OUTMID99002"
      gateways:
        type: array
        items:
          type: string
        example:
          - "PGWMID99003"
          - "PGWMID99004"
          - "PGWMID99005"
  AddOutletsToCustomerResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - outlets
        properties:
          outlets:
            type: array
            items:
              type: object
            example:
              - locid: "OUTMID99006"
                location_number: "992020063991344"
              - locid: "OUTMID99007"
                location_number: "992020063991345"
  AddGatewaysToCustomerResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - outlets
        properties:
          outlets:
            type: array
            items:
              type: object
            example:
              - locid: "PGWMID99008"
                location_number: "992020063951391"
              - locid: "OUTMID99009"
                location_number: "992020063951392"
  CustomerSubscriptionInfo:
    type: object
    properties:
      subsciption_id:
        type: string
        format: uuid
        example: "54a764ae-88cc-11ea-90bb-87e0c451e1a0"
      offer_id:
        type: string
        format: uuid
        example: "62c2b674-88cc-11ea-a2f9-c365138bfc0a"
      status:
        type: string
        example: "ACTIVE"
      origin_id:
        type: string
        format: uuid
        description: "identifier assigned to this subscription instance on provider platform"
        example: "85f8a306-88cc-11ea-bb4e-e36a2940b2dc"
      created:
        type: string
        format: 'date-time'
        example: '2020-04-21T17:32:28Z'
      modifed:
        type: string
        format: 'date-time'
        example: '2020-04-27T17:32:28Z'
  GetCustomerSubscriptionsResponse:
    allOf:
      - $ref: "#/definitions/ApiResponse"
      - type: object
        required:
          - count
        properties:
          count:
            type: integer
            example: 1
          items:
            type: array
            items:
              $ref: "#/definitions/CustomerSubscriptionInfo"
