openapi: 3.0.3
info:
  title: Ingrid API
  description: >-
    The Ingrid API is organized around REST. Our API has predictable
    resource-oriented URLs, accepts JSON-encoded request bodies, returns
    JSON-encoded responses, and uses standard HTTP response codes,
    authentication, and verbs.You can use the Ingrid API in test mode, which
    doesn't affect your live data or interact with carrier networks. The API key
    you use to authenticate the request determines whether the request is live
    mode or test mode.
  version: 1.0.1
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  contact:
    name: Ingrid Support
    email: support@ingrid.com
servers:
  - url: https://next.ingrid.com/v1
security: []
paths:
  /v1/delivery/locations:
    post:
      tags:
        - Delivery
      summary: List service locations
      description: >
        List available locations for a given service code and country with
        optional postal code.

        If latitude and longitude are provided, the locations will be sorted by
        distance from the given coordinates.


        The supplied service code must be for a service that is location based,
        e.g. instabox pickup.


        Change.
      operationId: DeliveryService_ListServiceLocations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ListServiceLocationsRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListServiceLocationsResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        default:
          $ref: '#/components/responses/DefaultError'
components:
  schemas:
    Distance:
      type: object
      properties:
        value:
          example: 10
          type: number
          format: double
        unit:
          example: KILOMETERS
          enum:
            - METERS
            - KILOMETERS
            - FEET
            - MILES
          type: string
          format: enum
    ListServiceLocationsRequest:
      type: object
      properties:
        serviceCode:
          example: svc_instabox-locker-se
          type: string
        country:
          example: SE
          type: string
        postalCode:
          example: '11350'
          type: string
        latitude:
          example: 59.329323
          type: number
          format: double
        longitude:
          example: 18.06858
          type: number
          format: double
        limit:
          type: integer
          default: 20
          format: int32
    ListServiceLocationsResponse:
      type: object
      properties:
        foo:
          example: bar
          type: string
        forServiceCode:
          example: svc_instabox-locker-se
          type: string
        forCountry:
          example: SE
          type: string
        forPostalCode:
          example: '11350'
          type: string
        forLatitude:
          example: 59.329323
          type: number
          format: double
        forLongitude:
          example: 18.06858
          type: number
          format: double
        locations:
          type: array
          items:
            $ref: '#/components/schemas/ServiceLocation'
    ServiceLocation:
      type: object
      properties:
        id:
          example: loc_instabox-abc123def789
          type: string
        name:
          example: Odengatan 14 Spel & Tobak
          type: string
        distance:
          $ref: '#/components/schemas/Distance'
    ErrorResponse:
      type: object
      additionalProperties: false
      description: Standard error response following google.rpc.Status structure
      properties:
        code:
          type: integer
          format: int32
          description: Error code
        message:
          type: string
          description: Error message
        details:
          type: array
          description: Error details containing additional information
          items:
            $ref: '#/components/schemas/ErrorDetail'
      example:
        code: 3
        message: Request validation failed.
        details:
          - type: type.googleapis.com/google.rpc.BadRequest
            fieldViolations:
              - field: name
                description: Name is required
                reason: REQUIRED_FIELD_MISSING
    ErrorDetail:
      type: object
      required:
        - type
      description: >-
        Contains an arbitrary serialized message along with a @type that
        describes the type of the serialized message.
      properties:
        type:
          type: string
          description: >-
            A URL/resource name that uniquely identifies the type of error
            detail
        fieldViolations:
          type: array
          description: >-
            The field violations (if any), containing the field that violated
            the constraint and the reason for the violation
          items:
            type: object
            required:
              - field
              - reason
            properties:
              field:
                type: string
                description: The field that violated the constraint
              description:
                type: string
                description: The description of the violation
              reason:
                type: string
                description: The reason for the violation
  responses:
    DefaultError:
      description: An unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    BadRequest:
      description: >-
        Bad Request - The request was invalid or cannot be served. The client
        should not retry without modification.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not Found - The requested resource could not be found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
tags:
  - name: Delivery
    description: Delivery API endpoints
