openapi: 3.0.3
info:
  title: cx-data-services-lambda-customers
  description: Existing customers operations endpoints documentation
  version: v2
  contact:
    email: sedataops@carlsberg.com
    name: DataOps Team
servers:
  - url: https://api-eu.carlsbergwebservices.com/data/dev/v2
    description: Customers lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/tst/v2
    description: Customers lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/stg/v2
    description: Customers lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/prd/v2
    description: Customers lambda API server url
tags:
  - name: customers
    description: Customers lambda endpoints
paths:
  /hello:
    get:
      tags:
        - customers
      operationId: fetchHello
      summary: Get hello
      description: Endpoint to see if service is alive
      responses:
        '200':
          $ref: '#/components/responses/CustomerHello'
  /{sales_org}/customers/{record_id}:
    get:
      tags:
        - customers
      operationId: fetchCustomer
      summary: Get customer by record id
      description: Concatenation of fields and the proper format (just customer_id in this case)
      responses:
        '200':
          $ref: '#/components/responses/Customer'
        '400':
          $ref: '#/components/responses/CustomerError'
    parameters:
      - $ref: '#/components/parameters/sales_org'
      - $ref: '#/components/parameters/record_id'
  /{sales_org}/customers:
    get:
      tags:
        - customers
      operationId: fetchAllCustomers
      summary: Get customers by sales org
      description: Retrieve a list of customers for a specific sales org
      responses:
        '200':
          $ref: '#/components/responses/CustomerList'
        '400':
          $ref: '#/components/responses/CustomerError'
      parameters:
        - $ref: '#/components/parameters/fields'
        - $ref: '#/components/parameters/list'
        - $ref: '#/components/parameters/size'
        - $ref: '#/components/parameters/token'
    parameters:
      - $ref: '#/components/parameters/sales_org'
components:
  schemas:
    HelloModel:
      title: hello response
      x-stoplight:
        id: zp0vl9utaeyrk
      description: This is the response structure when testing availability
      type: object
      properties:
        message:
          description: Content of greeting test message
          type: string
          example: Hello from CxDataOps Data Services !!!
    CustomerModel:
      title: Customer schema
      x-stoplight:
        id: ax9qgc3je0dwt
      description: This is the body attribute for response
      type: object
      properties:
        country:
          description: Customer's Alpha-2 Country Code.
          type: string
          example: GB
        trade_channel_4:
          description: Trade Channel 4, Can be null.
          type: string
          example: TC30201020
        RAW_customer_id:
          description: Original Customer ID With the Leading Zeros
          type: string
          example: '00099999999'
        trade_channel_3:
          description: Trade Channel 3, Can be null.
          type: string
          example: TC302010
        house_number:
          description: Customer's House Number and Floor.
          type: string
          example: '1'
        account_group_code:
          description: Account's Group Code starting with Z.
          type: string
          example: Z010
        trade_channel_2:
          description: Trade Channel 2, Can be null.
          type: string
          example: TC3020
        trade_channel_1:
          description: Trade Channel 1, Can be null.
          type: string
          example: TC30
        sales_org_code:
          description: Sales Organization Code.
          type: string
          example: '9999'
        season:
          description: Season, Can be null, Year Round or Event.
          type: string
          example: Year Round
        customer_id:
          description: Customer ID Without the Leading Zeros.
          type: string
          example: '9999999'
        group:
          description: Group Code based on Customer.
          type: string
          example: '01'
        longitude:
          description: Customer's Geographic Coordinate Longitude.
          type: string
          example: '99.999999999999'
        outlet_definition:
          description: Outlet Definition, Can be null.
          type: string
          example: 'null'
        kam_id:
          description: Key Account Manager Id.
          type: string
          example: '0099999999'
        creation_date:
          description: Creation Date of the Record.
          type: string
          example: '20131007'
        classification:
          description: Classification of the Customer's Ranking.
          type: string
          example: Platinum
        service_technician_id:
          description: Service Technician Id.
          type: string
          example: '0099999999'
        wholesaler_id:
          description: Cutomer's Saler Person Id.
          type: string
          example: '0099999999'
        volume:
          description: Customer's Volume Quantity.
          type: string
          example: '0'
        trade_channel_1_desc:
          description: Trade Channel 1 Description.
          type: string
          example: On-trade
        mission:
          description: Customer's Mission Description.
          type: string
          example: 'null'
        trade_channel_4_desc:
          description: Trade Channel 4 Description.
          type: string
          example: Regular Restaurant
        phone:
          description: Phone Number Of Customer.
          type: string
          example: '999999999'
        maintenance_technician_id:
          description: Maintenance Technician Id.
          type: string
          example: '0099999999'
        name:
          description: Customer Name Information.
          type: string
          example: AAAAAA AAAAAA 1
        region:
          description: Customer Region Information.
          type: string
          example: '1'
        organization_number:
          description: Organization Id Number.
          type: string
          example: '999999999'
        organization_number2:
          description: Organization Id Number 2.
          type: string
          example: '999999999'
        customer_status:
          description: Current Customer Status.
          type: string
          example: Active
        sales_group_code:
          description: Sales Group Code Number.
          type: string
          example: C01
        sales_rep_id:
          description: Sales Representative Id.
          type: string
          example: '0099999999'
        sales_office_desc:
          description: Sales Office Description.
          type: string
          example: Other
        chain4:
          description: Customer's Chain 4 Description.
          type: string
          example: No chain On Trade N4
        city:
          description: Customer City Information.
          type: string
          example: OSLO
        trade_channel_3_desc:
          description: Trade Channel 3 Description.
          type: string
          example: On-trade
        chain3:
          description: Customer's Chain 3 Description.
          type: string
          example: No chain On Trade N3
        mobile_contact_name:
          description: Mobile Contact Name Info.
          type: string
          example: '999999999'
        chain2:
          description: Customer's Chain 2 Description.
          type: string
          example: No chain On Trade N2
        latitude:
          description: Customer's Geographic Coordinate Latitude.
          type: string
          example: '99.999999999999'
        chain1:
          description: Customer's Chain 1 Description.
          type: string
          example: No chain On Trade N1
        classification_desc:
          description: Classification Description.
          type: string
          example: Bronze
        prim_telesales_ag_id:
          description: Telesales AG Id Primary.
          type: string
          example: '0099999999'
        license_class:
          description: License Class Information.
          type: string
          example: NO LICENSE
        contact_email:
          description: Contact Email Information.
          type: string
          example: aaaaaa@gmail.com
        sales_manager_id:
          description: Sales Manager Id Info.
          type: string
          example: '0099999999'
        street:
          description: Customer Street Address.
          type: string
          example: AAAA AAAA 1
        mobile_phone:
          description: Mobile Phone Information.
          type: string
          example: '999999999'
        outlet_image:
          description: Outlet Image Information.
          type: string
          example: 'null'
        visits_per_year:
          description: Visits Per Year Agreed - SLA.
          type: string
          example: '0'
        legal_name:
          description: Legal Name Information.
          type: string
          example: AAAA AAAA
        email:
          description: Customer Email Information.
          type: string
          example: aaaaa@gmail.com
        store_id:
          description: Store Id Information.
          type: string
          example: '0099999999'
        customer_support:
          description: Customer Support Infomation.
          type: string
          example: 'null'
        contact_name:
          description: Customer Contact Name.
          type: string
          example: AAAA AAAA
        RAW_crm_contact_id:
          description: Original CRM Contact Id.
          type: string
          example: '000099999999999'
        trade_channel_2_desc:
          description: Trade Channel 2 Description.
          type: string
          example: Eating
        logistics_class:
          description: Customer's Logistics Class Information.
          type: string
          example: 'null'
        sales_district:
          description: Sales District Information.
          type: string
          example: 'NO'
        crm_contact_id:
          description: CRM Contact Id Information.
          type: string
          example: '999999999'
        sales_office:
          description: Sales Office Information.
          type: string
          example: C001
        postal_code:
          description: Customer Postal Address.
          type: string
          example: '9999'
        terms_of_payment:
          description: Terms Of Payment Info.
          type: string
          example: '0001'
        France_latitude:
          description: France Latitude Information.
          type: string
          example: '99.999999999999'
        France_longitude:
          description: France Longitude Information.
          type: string
          example: '99.999999999999'
        total_visits_per_year:
          description: Total Visits Per Year Info.
          type: string
          example: '0'
        customer_email2:
          description: Customer Email 2 Information.
          type: string
          example: aaaaa@gmail.com
        min_order_value:
          description: Minimum Order Value Information.
          type: number
          format: float
          example: 1
        min_order_quantity:
          description: Minimum Order Quantity Information.
          type: integer
          format: int32
          example: 1
    CustomersListModel:
      type: object
      x-stoplight:
        id: xfvkauj2ywwz3
      description: This is structure for response
      properties:
        content:
          type: array
          description: Body response of a list of customers schemas existing in DynamoDB
          items:
            $ref: '#/components/schemas/CustomerModel'
          example:
            - $ref: '#/components/schemas/CustomerModel'
        pagination:
          $ref: '#/components/schemas/TokenPaginationModel'
    ErrorResponseModel:
      title: error response
      description: This is a schema for response when there is an error
      type: object
      properties:
        title:
          description: Title of the failure
          type: string
          example: Bad Request
        status:
          description: Error type code form response
          type: integer
          format: int32
          example: 400
        detail:
          description: More detailed information about the error
          type: string
          example: 'record_id: XYZ, sales_org: 9999 not found'
    TokenPaginationModel:
      title: Token Pagination
      x-stoplight:
        id: l8dtums7blqw4
      type: object
      description: Pagination metadata for using token page method
      properties:
        size:
          type: integer
          format: int32
          description: The size (number of elements) displayed per page
          example: 100
        token:
          type: string
          description: Token used to fetch next page data
          example: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
      example:
        size: 100
        token: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
  parameters:
    sales_org:
      name: sales_org
      in: path
      required: true
      schema:
        type: string
        example: '9999'
      description: Sales Organization Code
    record_id:
      name: record_id
      in: path
      required: true
      schema:
        type: string
        example: CUSTOMER_123
      description: Concatenation of fields and the proper format (just customer_id in this case)
    size:
      name: size
      in: query
      required: false
      schema:
        type: integer
        format: int32
        example: 100
      description: number of items to return
    fields:
      name: fields
      in: query
      required: false
      schema:
        type: string
        example: fields=sales_org_code
      description: an attribute from the body
    token:
      name: token
      in: query
      required: false
      schema:
        type: string
        example: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
      description: Token that retrieves next page of results
    list:
      name: list
      in: query
      required: false
      schema:
        type: string
        example: list=CUSTOMER_123, CUSTOMER_456
      description: List of partkeys (without "_<env>"). Limit of 100 elements.
  responses:
    CustomerHello:
      description: Retrieve a static message just to verify deployment
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HelloModel'
    Customer:
      description: Get customer detail based in given record id and sales org
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CustomerModel'
    CustomerList:
      description: Get customers detail list based in given sales org
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CustomersListModel'
    CustomerError:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseModel'
x-stoplight:
  id: 760u5ti95kx0b
