info:
  title: APIFlask
  version: 0.1.0
tags:
- name: V1
- name: V1.Pin_Scope
servers:
- url: https://live.luigisbox.com
paths:
  /v1/recommender/pin/{tracker_id}/scope:
    post:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PinScopeDto'
          description: Created
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Invalid configuration provided
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: Invalid pin definition provided
      tags:
      - V1.Pin_Scope
      summary: Creates pin scope
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InputPinScopeDto'
      security:
      - BasicAuth: []
  /v1/recommender/pin/{tracker_id}/scopes:
    post:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      - in: query
        name: sort
        description: "The name of the attribute used for sorting. To modify a sorting direction, the suffix ':asc|desc' can be provided"
        schema:
          type: array
          items:
            type: string
          default: null
          nullable: true
        style: form
        explode: true
        required: false
      - in: query
        name: tag
        schema:
          type: array
          default: null
          nullable: true
          items:
            type: string
        required: false
        explode: true
        style: form
      - in: query
        name: target_type
        schema:
          type: array
          default: null
          nullable: true
          items:
            description: TargetTypeByValue
            enum:
            - all
            - item
            - criteria
        required: false
        explode: true
        style: form
      - in: query
        name: model
        schema:
          type: array
          default: null
          nullable: true
          items:
            type: string
        required: false
        explode: true
        style: form
      - in: query
        name: target_identity
        schema:
          type: array
          default: null
          nullable: true
          items:
            type: string
        required: false
        explode: true
        style: form
      - in: query
        name: offset
        schema:
          type: integer
          default: null
          nullable: true
        required: false
      - in: query
        name: limit
        schema:
          type: integer
          default: null
          nullable: true
        required: false
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedPinScopes'
          description: Success
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: Validation error
      tags:
      - V1.Pin_Scope
      summary: Search pin scopes
      description: Allows to return only a subset of client's pin scopes matching
        provided filters. It is also possible to paginate and sort results by a defined
        attribute. If an unknown attribute is used, pagination is silently ignored.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BodyPinScopeFilterDto'
      security:
      - BasicAuth: []
  /v1/recommender/pin/{tracker_id}/scopes/export:
    post:
      description: Allows to export all pin scopes for a client. It is possible to filter out expired pins and pins with nonexisting items.
      parameters:
        - in: path
          name: tracker_id
          required: true
          schema:
            type: string
        - explode: true
          in: query
          name: target_identity
          required: false
          schema:
            default: null
            items:
              type: string
            nullable: true
            type: array
          style: form
        - explode: true
          in: query
          name: target_type
          required: false
          schema:
            default: null
            items:
              description: TargetTypeByValue
              enum:
                - all
                - item
                - criteria
            nullable: true
            type: array
          style: form
        - explode: true
          in: query
          name: model
          required: false
          schema:
            default: null
            items:
              type: string
            nullable: true
            type: array
          style: form
        - explode: true
          in: query
          name: tag
          required: false
          schema:
            default: null
            items:
              type: string
            nullable: true
            type: array
          style: form
        - in: query
          name: remove_expired_pins
          required: false
          schema:
            default: false
            type: boolean
        - in: query
          name: remove_nonexisting_item_pins
          required: false
          schema:
            default: false
            type: boolean
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PinScopesResponseDto'
          description: Success
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: Validation error
      security:
        - BearerAuth: []
      summary: Export pin scopes
      tags:
        - V1.Pin_Scope
  /v1/recommender/pin/{tracker_id}/summary:
    get:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientScopesSummaryDto'
          description: Success
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
      tags:
      - V1.Pin_Scope
      summary: Get Client Scopes Summary
      security:
      - BasicAuth: []
  /v1/recommender/pin/{tracker_id}/scopes/_bulk:
    post:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      - in: query
        name: conflict_strategy
        description: "Strategy which is used when dealing with conflicting pins"
        schema:
          type: string
          enum:
            - raise
            - ignore
            - override
          default: raise
          nullable: true
        style: form
        explode: true
        required: false
      responses:
        '200':
          content:
            application/json:
              schema: {}
          description: Success
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Too many pins provided in a single request.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Invalid pin definition provided.
      requestBody:
        description: One pin scope JSON definition per line.
        content:
          application/x-ndjson:
            schema:
              type: string
              example: |
                {"target_type": "all", "tags": ["yellow clothes"], "model": "item_detail_complements", "pin_definitions": [{ "pin_type": "item", "pin_identity": "p1", "position": 5}]}
                {"target_type": "all", "tags": ["green clothes"], "model": "item_detail_complements", "pin_definitions": [{ "pin_type": "item", "pin_identity": "p2", "position": 4}]}
        required: true
      tags:
      - V1.Pin_Scope
      summary: Creates multiple pin scopes
      description: Creates multiple pin scopes in a single api call. One pin scope
        JSON per line is required. Up to 5000 pin scopes can be provided in a single call.
      security:
      - BasicAuth: []
  /v1/recommender/pin/{tracker_id}/scope/{scope_id}:
    get:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      - in: path
        name: scope_id
        schema:
          type: string
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PinScopeDto'
          description: Success
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
      tags:
      - V1.Pin_Scope
      summary: Get Pin Scope By Id
      security:
      - BasicAuth: []
    put:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      - in: path
        name: scope_id
        schema:
          type: string
        required: true
      responses:
        '204':
          description: Successfully updated
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Invalid configuration provided
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: Invalid pin definition provided
      tags:
      - V1.Pin_Scope
      summary: Update Pin Scope By Id
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InputPinScopeDto'
      security:
      - BasicAuth: []
    delete:
      parameters:
      - in: path
        name: tracker_id
        schema:
          type: string
        required: true
      - in: path
        name: scope_id
        schema:
          type: string
        required: true
      responses:
        '204':
          description: Successfully deleted
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Authentication error
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
          description: Not found
      tags:
      - V1.Pin_Scope
      summary: Delete Pin Scope By Id
      security:
      - BasicAuth: []
openapi: 3.0.3
components:
  schemas:
    ValidationError:
      properties:
        reason:
          type: string
        exception_details:
          type: object
      type: object
    HTTPError:
      properties:
        reason:
          type: string
        exception_details:
          type: object
      type: object
    AttributeCriteriaDto:
      type: object
      properties:
        attribute:
          type: string
        operator:
          type: string
          enum:
            - in
            - not_in
            - all_of
            - exists
            - not_exists
            - lt
            - lte
            - gt
            - gte
        values:
          type: array
          items:
            oneOf:
              - type: string
              - type: number
        condition:
          $ref: '#/components/schemas/CriteriaConditionDto'
        transformation:
          $ref: '#/components/schemas/AttributeTransformationDto'
      required:
        - attribute
        - operator

    CriteriaConditionDto:
      type: object
      properties:
        left_attribute:
          type: string
        left_value:
          type: string
          enum:
            - '@same'
            - '@same_last'
            - '@same_first'
            - '@same_second'
            - '@same_third'
            - '@same_first_two'
            - '@same_first_three'
            - '@same_second_and_later'
            - '@same_third_and_later'
            - '@same_but_last'
            - '@same_main_only'
            - '@same_last_main_only'
            - '@same_first_main_only'
            - '@same_second_main_only'
            - '@same_third_main_only'
            - '@same_first_two_main_only'
            - '@same_first_three_main_only'
            - '@same_second_and_later_main_only'
            - '@same_third_and_later_main_only'
            - '@same_but_last_main_only'
        right_values:
          type: array
          items:
            oneOf:
              - type: string
              - type: number
        operator:
          type: string
          enum:
            - in
            - not_in
            - all_of
            - exists
            - not_exists
            - lt
            - lte
            - gt
            - gte
            - between
            - eq
            - neq
        right_attribute:
          type: string
        transformation:
          $ref: '#/components/schemas/ConditionTransformationDto'
      required:
        - left_attribute
        - left_value
        - right_values
        - operator


    AttributeTransformationDto:
      type: object
      properties:
        function:
          type: string
          enum:
            - '+'
            - '*'
        value:
          type: number
      required:
        - function
    ConditionTransformationDto:
      type: object
      properties:
        function:
          type: string
          enum:
            - '+'
            - '*'
            - 'length'
        value:
          type: number
      required:
        - function

    ComplexCriteriaDto:
      type: object
      properties:
        operator:
          type: "string"
          enum:
          - and
          - or
          - not
        criteria:
          type: array
          minItems: 1
          items:
            oneOf:
              - $ref: '#/components/schemas/ComplexCriteriaDto'
              - $ref: '#/components/schemas/AttributeCriteriaDto'
      required:
      - criteria
      - operator
    InputPinDefinitionDto:
      type: object
      properties:
        active_to:
          type: string
          format: date-time
          default: null
          nullable: true
        placement_id:
          type: string
          default: null
          nullable: true
        active_from:
          type: string
          format: date-time
          default: null
          nullable: true
        is_block_pin:
          type: boolean
          default: false
        is_bundle_pin:
          type: boolean
          default: false
        pin_criteria:
          default: null
          allOf:
          - $ref: '#/components/schemas/ComplexCriteriaDto'
          nullable: true
        pin_identity:
          type: string
          default: null
          nullable: true
        position:
          type: integer
        pin_type:
          enum:
          - item
          - criteria
      required:
      - pin_type
      - position
    PinDefinitionDto:
      type: object
      properties:
        is_block_pin:
          type: boolean
          default: false
        is_bundle_pin:
          type: boolean
          default: false
        pin_identity:
          type: string
          default: null
          nullable: true
        pin_type:
          type: "string"
          enum:
          - item
          - criteria
        pin_criteria:
          default: null
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ComplexCriteriaDto'
        placement_id:
          type: string
          default: null
          nullable: true
        active_from:
          type: string
          format: date-time
          default: null
          nullable: true
        active_to:
          type: string
          format: date-time
          default: null
          nullable: true
        position:
          type: integer
        image_link:
          type: string
          default: null
          nullable: true
        title:
          type: string
          default: null
          nullable: true
        available:
          type: boolean
          default: true
      required:
      - pin_type
      - position
    InputPinScopeDto:
      type: object
      properties:
        pin_definitions:
          type: array
          items:
            $ref: '#/components/schemas/InputPinDefinitionDto'
        target_criteria:
          default: null
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ComplexCriteriaDto'
        model:
          type: string
        target_type:
          type: "string"
          enum:
          - all
          - item
          - criteria
        tags:
          type: array
          default: null
          nullable: true
          items:
            type: string
        target_identity:
          type: string
          default: null
          nullable: true
      required:
      - pin_definitions
      - model
      - target_type
    PinScopeDto:
      type: object
      properties:
        id:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
        target_identity:
          type: string
          default: null
          nullable: true
        target_criteria:
          default: null
          nullable: true
          allOf:
          - $ref: '#/components/schemas/ComplexCriteriaDto'
        target_metadata:
          type: object
          additionalProperties:
            nullable: true
        model:
          type: string
        creator:
          type: string
        target_type:
          type: "string"
          enum:
          - all
          - item
          - criteria
        tags:
          type: array
          default: null
          nullable: true
          items:
            type: string
        pin_definitions:
          type: array
          items:
            $ref: '#/components/schemas/PinDefinitionDto'
        available:
          type: boolean
          default: true
      required:
      - created_at
      - creator
      - id
      - pin_definitions
      - model
      - target_type
    BodyPinScopeFilterDto:
      type: object
      properties:
        criteria:
          type: array
          default: null
          nullable: true
          items:
            $ref: '#/components/schemas/ComplexCriteriaDto'
    LimitOffsetPaginationDto:
      type: object
      properties:
        offset:
          type: integer
          default: null
          nullable: true
        limit:
          type: integer
          default: null
          nullable: true
    PaginatedPinScopes:
      type: object
      properties:
        pagination:
          $ref: '#/components/schemas/LimitOffsetPaginationDto'
        results:
          type: array
          items:
            $ref: '#/components/schemas/PinScopeDto'
      required:
      - pagination
      - results
    PinScopesResponseDto:
      properties:
        results:
          items:
            $ref: '#/components/schemas/PinScopeDto'
          type: array
      required:
        - results
      type: object
    ClientScopesSummaryDto:
      type: object
      properties:
        user_tags:
          type: array
          items:
            type: string
        scope_counts:
          type: object
          additionalProperties:
            type: integer
      required:
      - scope_counts
      - user_tags
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer

