openapi: 3.0.2
info:
  title: Customer and policy Services
  version: '0.1'
  description: >-
    Collection of service for Scalepoint to find customer and policy and lookup
    details on those.
  contact:
    name: Scalepoint support
    url: https://web.scalepoint.com/support/
servers:
  - url: https://api.server.test/v1
tags:
  - name: policyLookup
  - name: policyDetails
components:
  securitySchemes:
    oAuth2ClientCredentials:
      type: oauth2
      description: Oauth2 with clientCredential flow
      flows:
        clientCredentials:
          tokenUrl: https://api.server.test/token
          scopes: {}
  parameters:
    limitParam:
      description: >-
        Defines the limit of rows the endpoints will return. 'after' parameter
        denfines where the next page starts
      in: query
      name: limit
      required: true
      schema:
        type: number
    afterParam:
      description: Specifies where the page starts example, ?limit=10&after=20
      in: query
      name: after
      required: false
      schema:
        type: number
    dateParam:
      in: query
      name: date
      required: true
      schema:
        format: date
        type: string
    customerIdParam:
      name: customerId
      in: path
      schema:
        type: string
      required: true
    policyVersionIdParam:
      name: policyVersionId
      in: path
      schema:
        type: string
      required: true
    policyObjectVersionIdParam:
      name: policyObjectVersionId
      in: path
      schema:
        type: string
      required: true
  schemas:
    common:
      allOf:
        - type: object
          properties:
            description:
              type: string
            startDate:
              format: date
              type: string
            endDate:
              format: date
              type: string
        - $ref: '#/components/schemas/statusComponent'
    customer:
      type: object
      properties:
        customerId:
          type: string
        number:
          type: string
        fullName:
          type: string
        taxId:
          description: >-
            both personal and coporate tax id. Should be empty on multiple
            results
          type: string
        address:
          type: string
        description:
          type: string
        policyMatches:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/policy'
              - properties:
                  policyObjectMatches:
                    type: array
                    items:
                      $ref: '#/components/schemas/policyObject'
      required:
        - customerId
    policy:
      allOf:
        - $ref: '#/components/schemas/common'
        - type: object
          properties:
            policyVersionId:
              type: string
            number:
              type: string
            product:
              type: string
      required:
        - policyVersionId
    policyObject:
      allOf:
        - $ref: '#/components/schemas/common'
        - type: object
          properties:
            policyObjectVersionId:
              type: string
      required:
        - policyObjectVersionId
    coverage:
      allOf:
        - $ref: '#/components/schemas/common'
        - type: object
          properties:
            coverageId:
              type: string
            deductible:
              format: float
              type: number
            annualLimit:
              format: float
              type: number
      required:
        - coverageId
    error:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      required:
        - code
        - message
    statusComponent:
      type: object
      properties:
        isActive:
          type: boolean
        statusText:
          type: string
      required:
        - isActive
    address:
      type: object
      properties:
        street1:
          type: string
        street2:
          type: string
        postalcode:
          type: string
        city:
          type: string
        country:
          type: string
    contactInfo:
      type: object
      properties:
        name:
          type: string
        phone:
          type: string
        mobilePhone:
          type: string
        email:
          type: string
          format: email
        address:
          $ref: '#/components/schemas/address'
    schemas-customer:
      allOf:
        - type: object
          description: can be both a company or a person
          properties:
            customerId:
              type: string
            taxId:
              description: personal or commercial tax id depending on type of customer
              type: string
        - $ref: '#/components/schemas/contactInfo'
      patternProperties":
        ^#.*$:
          - $ref": dynamic_property.yml#/definitions/dynamicProperty
    coverageSnapshot:
      allOf:
        - type: object
          properties:
            coverageId:
              type: string
            description:
              type: string
            deductible:
              format: float
              type: number
            annualLimit:
              format: float
              type: number
        - $ref: '#/components/schemas/statusComponent'
      patternProperties":
        ^#.*$:
          - $ref": dynamic_property.yml#/definitions/dynamicProperty
    person:
      allOf:
        - type: object
          properties:
            policyObjectType:
              type: string
              enum:
                - person
            personalTaxId:
              type: string
        - $ref: '#/components/schemas/contactInfo'
      required:
        - policyObjectType
    building:
      type: object
      properties:
        policyObjectType:
          type: string
          enum:
            - building
        address:
          $ref: '#/components/schemas/address'
        year:
          type: string
      required:
        - policyObjectType
    vehicle:
      type: object
      properties:
        policyObjectType:
          type: string
          enum:
            - vehicle
        registrationNo:
          type: string
        brand:
          type: string
          enum:
            - Alfa Romeo
            - Audi
            - BMW
            - Cadillac
            - Chevrolet/Daewoo
            - Chrysler
            - Citroën
            - Dacia
            - Daihatsu
            - Dodge
            - DS
            - Fiat
            - Ford
            - Honda
            - Hyundai
            - Isuzu
            - Iveco
            - Jaguar
            - Jeep
            - Kia
            - Lada
            - Lancia
            - Land Rover
            - Lexus
            - Mazda
            - Mercedes
            - Mini
            - Mitsubishi
            - Nissan
            - Opel
            - Peugeot
            - Porsche
            - Renault
            - Rover
            - Seat
            - Talbot (Simca)
            - Saab
            - Skoda
            - Smart
            - SsangYong
            - Subaru
            - Suzuki
            - Tesla
            - Toyota
            - Volvo
            - VW
        model:
          type: string
        chassisNo:
          type: string
        year:
          type: string
      required:
        - policyObjectType
    schemas-policyObject:
      allOf:
        - type: object
          properties:
            description:
              type: string
            coverages:
              type: array
              items:
                $ref: '#/components/schemas/coverageSnapshot'
            policyLineName:
              type: string
        - $ref: '#/components/schemas/statusComponent'
        - oneOf:
            - $ref: '#/components/schemas/person'
            - $ref: '#/components/schemas/building'
            - $ref: '#/components/schemas/vehicle'
      patternProperties":
        ^#.*$:
          - $ref": dynamic_property.yml#/definitions/dynamicProperty
    policySnapshot:
      allOf:
        - type: object
          properties:
            policyNumber:
              type: string
            product:
              summary: code for the insurance product
              type: string
            productDisplay:
              summary: eg. Motor commercial, Private Housing
              type: string
            startDate:
              format: date
              type: string
            endDate:
              format: date
              type: string
            policyHolder:
              $ref: '#/components/schemas/schemas-customer'
            coinsured:
              type: array
              items:
                $ref: '#/components/schemas/schemas-customer'
            PolicyObjectSnapshot:
              $ref: '#/components/schemas/schemas-policyObject'
        - $ref: '#/components/schemas/statusComponent'
      required:
        - policyNumber
        - product
      patternProperties":
        ^#.*$:
          - $ref": dynamic_property.yml#/definitions/dynamicProperty
  responses:
    Unauthorized:
      description: Not allowed to access this resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
paths:
  /customers:
    get:
      tags:
        - policyLookup
      operationId: searchCustomer
      description: search for customers, policies and objects
      parameters:
        - $ref: '#/components/parameters/dateParam'
        - name: q
          in: query
          schema:
            type: string
          required: true
        - $ref: '#/components/parameters/limitParam'
        - $ref: '#/components/parameters/afterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/customer'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /customers/{customerId}/policies:
    get:
      tags:
        - policyLookup
      operationId: getCustomerPolicies
      description: lookup policies by customerid
      parameters:
        - $ref: '#/components/parameters/dateParam'
        - $ref: '#/components/parameters/customerIdParam'
        - $ref: '#/components/parameters/limitParam'
        - $ref: '#/components/parameters/afterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/policy'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /customers/{customerId}/policies/{policyVersionId}/policyObjects:
    get:
      tags:
        - policyLookup
      operationId: getPolicyObjects
      description: lookup policy objects related to a policy version
      parameters:
        - $ref: '#/components/parameters/customerIdParam'
        - $ref: '#/components/parameters/policyVersionIdParam'
        - $ref: '#/components/parameters/limitParam'
        - $ref: '#/components/parameters/afterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/policyObject'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /customers/{customerId}/policies/{policyVersionId}/policyObjects/{policyObjectVersionId}/coverages:
    get:
      tags:
        - policyLookup
      operationId: getPolicyObjectCoverages
      description: lookup coverages which is related to a given policy object
      parameters:
        - $ref: '#/components/parameters/customerIdParam'
        - $ref: '#/components/parameters/policyVersionIdParam'
        - $ref: '#/components/parameters/policyObjectVersionIdParam'
        - $ref: '#/components/parameters/limitParam'
        - $ref: '#/components/parameters/afterParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/coverage'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /customers/{customerId}/policies/{policyVersionId}/policyObjects/{policyObjectVersionId}:
    get:
      tags:
        - policyDetails
      operationId: getPolicySnapshot
      description: >-
        This service returns details about the policy and selected object only.
        This is scoped to a specific date.
      parameters:
        - $ref: '#/components/parameters/customerIdParam'
        - $ref: '#/components/parameters/policyVersionIdParam'
        - $ref: '#/components/parameters/policyObjectVersionIdParam'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/policySnapshot'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
security:
  - oAuth2ClientCredentials: []
