openapi: 3.0.1
info:
  title: Price
  description: API to manage prices
  license:
    name: Nexway License Version 1.0
  version: '1.0'
servers:
  - url: https://api.staging.nexway.build
    description: Generated server url
security:
  - Bearer:
      - read
      - write
paths:
  /prices/currencies/{customerId}:
    get:
      tags:
        - Price
      summary: Get distinct currencies by customerId
      description: Search the currencies by customerId
      operationId: getDistinctCurrenciesByCustomer
      responses:
        '200':
          description: Success
          content:
            '*/*':
              schema:
                type: object
                additionalProperties:
                  uniqueItems: true
                  type: array
                  items:
                    type: string
        '401':
          description: Unauthorized
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
  /prices/{id}:
    get:
      tags:
        - Price
      summary: Get item
      operationId: getItem
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Price'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
      x-operationWeight: '200'
    put:
      tags:
        - Price
      summary: Update price
      operationId: updateItem
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Price'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Price'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
    delete:
      tags:
        - Price
      summary: Delete price
      description: >-
        Deleting prices is allowed only for prices that are scheduled in the
        future. Prices that have already been effective cannot be deleted in
        order to keep the history of pricing per product
      operationId: deleteItem
      responses:
        '204':
          description: No Content
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
  /prices:
    get:
      tags:
        - Price
      summary: Get items
      operationId: getItems
      parameters:
        - name: customerId
          in: query
          description: Filter prices by customerId
        - name: productId
          in: query
          description: Filter prices by productId
        - name: country
          in: query
          description: Filter prices by country
        - name: currency
          in: query
          description: Filter prices by currency
        - name: value
          in: query
          description: Filter prices by price
        - name: upSell
          in: query
          description: Filter prices by upSell price
        - name: crossSell
          in: query
          description: Filter prices by crossSell price
        - name: msrp
          in: query
          description: Filter prices by msrp value
        - name: vatIncluded
          in: query
          description: Filter prices with or without vat included
        - name: startingDate
          in: query
          description: >-
            Filter by start date of the price. You can use date ranges by using
            < or << operator, examples: startingDate=XXXX< will return prices
            starting after XXXX, startingDate=<XXXX will return prices starting
            before XXXX, startingDate=XXXX<<YYYYY will return prices starting
            between XXXX and YYYY
        - name: endingDate
          in: query
          description: >-
            Filter by end date of the price. You can use date ranges by using <
            or << operator, examples: endingDate=XXXX< will return prices ending
            after XXXX, endingDate=<XXXX will return prices ending before XXXX,
            endingDate=XXXX<<YYYYY will return prices ending between XXXX and
            YYYY
        - name: marketingCampaignId
          in: query
          description: Filter prices by marketingCampaignId
        - name: target
          in: query
          description: >-
            Return selected fields only (multiple occurrences allowed for
            selecting multiple fields)
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResultPrice'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
      x-operationWeight: '300'
    post:
      tags:
        - Price
      summary: Create price
      operationId: createItem
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Price'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Price'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
  /prices/best:
    get:
      tags:
        - Price
      summary: Get best price for parameters
      description: >-
        Search price for product with given parameters: country, currency,
        defaultCurrency, effective date
      operationId: getBestPrice
      parameters:
        - name: customerId
          in: query
          description: ID of the customer
          required: true
        - name: productId
          in: query
          description: ID of the product
          required: true
        - name: country
          in: query
          description: Country code in ISO 3166-2 format
          required: true
          example: FR
        - name: currency
          in: query
          description: Currency code in ISO-4217 format
          example: USD
        - name: defaultCurrency
          in: query
          description: Fallback currency code in ISO-4217 format
          example: EUR
        - name: date
          in: query
          description: >-
            Effective date in ISO-8601 format, examples: 2020-10-14,
            2020-10-14T12:00:00Z
        - name: marketingCampaignId
          in: query
          description: ID of marketing campaign
      responses:
        '200':
          description: Success
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Price'
        '401':
          description: Unauthorized
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
  /prices/distinct:
    get:
      tags:
        - Price
      summary: Get distinct values for a given field
      operationId: distinct
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResultObject'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
      x-operationWeight: '100'
  /prices/recap:
    get:
      tags:
        - Price
      summary: Get recap quantities for a given field
      operationId: recap
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResultRecapEntry'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
      x-operationWeight: '150'
  /prices/unwind:
    get:
      tags:
        - Price
      summary: Search unwind for a given field
      operationId: unwind
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResultDocument'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NormalizeException'
      x-operationWeight: '150'
  /prices/public/currencies:
    get:
      tags:
        - Public
      summary: Get available currencies
      description: >-
        Search the available currencies based on a set of product IDs and a
        marketingCampaign id
      operationId: getAvailableCurrencies
      parameters:
        - name: productId
          in: query
          description: One or multiple productIds separated by comma
          required: true
        - name: marketingCampaignId
          in: query
          description: ID of marketing campaign
      responses:
        '200':
          description: Success
          content:
            '*/*':
              schema:
                uniqueItems: true
                type: array
                items:
                  type: string
        '401':
          description: Unauthorized
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '403':
          description: Forbidden
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '404':
          description: Not Found
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
        '500':
          description: Failure
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/NormalizeException'
components:
  schemas:
    ExceptionDetail:
      type: object
      properties:
        errorType:
          type: string
        resourceType:
          type: string
        resourceId:
          type: string
        resourceDisplayName:
          type: string
        specific:
          type: object
    NormalizeException:
      type: object
      properties:
        timestamp:
          type: integer
          format: int64
        status:
          type: integer
          format: int32
        error:
          type: string
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/ExceptionDetail'
    Event:
      type: object
      properties:
        event:
          type: string
          enum:
            - CREATED
            - UPDATED
            - ARCHIVED
        when:
          type: string
          format: date-time
        previousData:
          $ref: '#/components/schemas/Price'
        affectedIds:
          type: array
          items:
            type: string
      description: Historical data on the price
      readOnly: true
    Price:
      required:
        - crossSell
        - currency
        - endDate
        - productId
        - startDate
        - upSell
        - value
        - vatIncluded
      type: object
      properties:
        id:
          type: string
          deprecated: true
        customerId:
          type: string
        createDate:
          type: string
          format: date-time
          deprecated: true
        updateDate:
          type: string
          format: date-time
          deprecated: true
        modelVersion:
          type: string
          deprecated: true
        dbVersion:
          type: integer
          format: int64
        lastUpdateReason:
          type: string
        originalId:
          type: string
          writeOnly: true
        productId:
          type: string
          description: Product identifier
        startDate:
          type: string
          description: Price start date timestamp in milliseconds
          format: date-time
        endDate:
          type: string
          description: Price end date timestamp in milliseconds
          format: date-time
        country:
          type: string
          description: Country code in ISO 3166-2 format
          example: FR
        currency:
          type: object
          properties:
            currencyCode:
              type: string
            defaultFractionDigits:
              type: integer
              format: int32
            numericCode:
              type: integer
              format: int32
            displayName:
              type: string
            symbol:
              type: string
            numericCodeAsString:
              type: string
          description: Currency code in ISO-4217 format
          example: EUR
        value:
          type: number
          description: Regular price, two decimal places format
          format: double
          example: 14.99
        upSell:
          type: number
          description: Upsell price, two decimal places format
          format: double
          example: 10.99
        crossSell:
          type: number
          description: CrossSell price, two decimal places format
          format: double
          example: 12.99
        vatIncluded:
          type: boolean
          description: Tax is included in price
        msrp:
          type: number
          description: Recommended price, two decimal places format
          format: double
          example: 39.99
        marketingCampaignId:
          type: string
          description: Marketing campaign Id
        archived:
          type: boolean
          description: Indicator if the price was removed/archived
        history:
          type: array
          description: Historical data on the price
          readOnly: true
          items:
            $ref: '#/components/schemas/Event'
    SearchResultPrice:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Price'
        last:
          type: boolean
        totalItems:
          type: integer
          format: int64
        totalPages:
          type: integer
          format: int32
        size:
          type: integer
          format: int32
        number:
          type: integer
          format: int32
    SearchResultObject:
      type: object
      properties:
        items:
          type: array
          items:
            type: object
        last:
          type: boolean
        totalItems:
          type: integer
          format: int64
        totalPages:
          type: integer
          format: int32
        size:
          type: integer
          format: int32
        number:
          type: integer
          format: int32
    RecapEntry:
      type: object
      properties:
        targetValue:
          type: string
        count:
          type: integer
          format: int32
    SearchResultRecapEntry:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/RecapEntry'
        last:
          type: boolean
        totalItems:
          type: integer
          format: int64
        totalPages:
          type: integer
          format: int32
        size:
          type: integer
          format: int32
        number:
          type: integer
          format: int32
    Document:
      type: object
      properties:
        empty:
          type: boolean
      additionalProperties:
        type: object
    SearchResultDocument:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Document'
        last:
          type: boolean
        totalItems:
          type: integer
          format: int64
        totalPages:
          type: integer
          format: int32
        size:
          type: integer
          format: int32
        number:
          type: integer
          format: int32
  securitySchemes:
    Bearer:
      type: http
      description: Enter Bearer token
      scheme: bearer
      bearerFormat: JWT
