openapi: 3.0.0
info:
  version: '1.0'
  title: Credit records
servers:
  - url: https://api.solaris-sandbox.de
    description: Sandbox
  - url: https://api.solarisbank.de
    description: Production
paths:
  /v1/persons/{person_id}/credit_records:
    post:
      tags:
        - Person credit record
      summary: Create a credit record for a retail customer
      description: >-
        Creates a credit record and assigns to the customer with the `person_id`
        specified in the request URL. You can specify the `source` of the credit
        record file as either `partner` or `solarisBank`. If the `source` is set
        to `partner`, you must collect the credit record yourself from a credit
        bureau and add the credit record file content Base64-encoded in the
        payload.
      security:
        - oauth2:
            - solaris_service_person_credit_record#create
      responses:
        '201':
          description: CreditRecord
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PersonCreditRecord.GetPersonCreditRecordResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error403'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
        '504':
          description: Gateway Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SolarisToolkit.Web.Json.ErrorBody'
      requestBody:
        required: false
        description: The credit record attributes
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PersonCreditRecord.CreatePersonCreditRecordRequest
      parameters:
        - schema:
            type: string
          required: true
          name: person_id
          in: path
          description: >-
            The person ID of the customer for whom you are creating the credit
            record.
      operationId: PersonCreditRecordWeb.V1.CreditRecords.CreateOperation
      deprecated: false
  /v1/freelancers/persons/{person_id}/credit_records:
    post:
      tags:
        - Person credit record
      summary: Create a credit record for a freelancer
      description: >-
        Creates a credit record and assigns to the freelancer with the
        `person_id` specified in the request URL. You can specify the `source`
        of the credit record file as either `partner` or `solarisBank`. If the
        `source` is set to `partner`, you must collect the credit record
        yourself from a credit bureau and add the credit record file content
        Base64-encoded in the payload.
      security:
        - oauth2:
            - solaris_service_freelancer_credit_record#create
      responses:
        '201':
          description: CreditRecord
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PersonCreditRecord.GetPersonCreditRecordResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error400'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error403'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error500'
        '504':
          description: Gateway Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SolarisToolkit.Web.Json.ErrorBody'
      requestBody:
        required: false
        description: The credit record attributes
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PersonCreditRecord.CreateFreelancerCreditRecordRequest
      parameters:
        - schema:
            type: string
          required: true
          name: person_id
          in: path
          description: >-
            The person ID of the freelancer for whom you are creating the credit
            record.
      operationId: PersonCreditRecordWeb.V1.CreditRecords.CreateFreelancerOperation
      deprecated: false
  /v1/persons/{person_id}/credit_records/{credit_record_id}:
    get:
      tags:
        - Person credit record
      summary: Retrieve a credit record
      description: >-
        Returns the information about a customer's existing credit record,
        including the status and validity of the credit record. Add the
        customer's `person_id` and the `credit_record_id` in the request URL. If
        the `status` of a credit record is `expired`, you must create a new
        credit record for the customer.
      security:
        - oauth2:
            - solaris_service_person_credit_record#find
      responses:
        '200':
          description: Credit Record
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PersonCreditRecord.GetPersonCreditRecordResponse
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error404'
      parameters:
        - schema:
            type: string
          required: true
          name: person_id
          in: path
          description: The `person_id` of the customer.
        - schema:
            type: string
          required: true
          name: credit_record_id
          in: path
          description: The unique ID of the customer's credit record.
      operationId: PersonCreditRecordWeb.V1.CreditRecords.ShowOperation
      deprecated: false
components:
  schemas:
    PersonCreditRecord.CreatePersonCreditRecordRequest:
      x-struct: >-
        Elixir.PersonCreditRecordWeb.V1.CreditRecords.CreateOperation.CreatePersonCreditRecordRequest
      type: object
      title: PersonCreditRecord.CreatePersonCreditRecordRequest
      required:
        - source
      properties:
        source:
          type: string
          description: The source of the credit record file.
          example: solarisBank
          enum:
            - partner
            - solarisBank
        file:
          type: string
          nullable: true
          description: >-
            The credit record file content, Base64-encoded. Required only if
            `source` is `partner`.
    PersonCreditRecord.GetPersonCreditRecordResponse:
      x-struct: >-
        Elixir.PersonCreditRecordWeb.V1.CreditRecords.ShowOperationView.GetPersonCreditRecordResponse
      type: object
      title: PersonCreditRecord.GetPersonCreditRecordResponse
      required:
        - id
        - person_id
        - status
        - created_at
      properties:
        status:
          type: string
          description: >-
            The status of the credit record. If the status is `expired`, you
            must create a new credit record for the customer.
          example: available
          enum:
            - available
            - expired
        person_id:
          type: string
          description: The person ID of the customer.
          example: dc1a6812a14f6cc338cd084208535bcdcper
        id:
          type: string
          description: The ID of the credit record resource.
          example: fbb7d15fa4c54ba0b077592665ef04a4ccrd
        created_at:
          type: string
          description: UTC timestamp from when the credit record was created.
          example: '2020-20-03T18:01:48.000Z'
    Error400:
      x-struct: Elixir.SolarisToolkit.Web.Schemas.HttpError.Error400
      type: object
      title: Error400
      properties:
        title:
          type: string
          example: Failed to build pagination headers.
        status:
          type: string
          example: '400'
        id:
          type: string
          example: a95f2aaf-4e0c-4d49-8021-8a16a884ed86
        detail:
          type: string
          example: Cannot connect to database.
        code:
          type: string
          example: build_pagination_headers_failure
    Error403:
      x-struct: Elixir.SolarisToolkit.Web.Schemas.HttpError.Error403
      type: object
      title: Error403
      properties:
        title:
          type: string
          example: Unauthorized Action
        status:
          type: string
          example: '403'
        id:
          type: string
          example: a95f2aaf-4e0c-4d49-8021-8a16a884ed86
        detail:
          type: string
          example: Unauthorized action is not allowed.
        code:
          type: string
          example: unauthorized_action
    Error404:
      x-struct: Elixir.SolarisToolkit.Web.Schemas.HttpError.Error404
      type: object
      title: Error404
      properties:
        title:
          type: string
          example: Model Not Found
        status:
          type: string
          example: '404'
        id:
          type: string
          example: a95f2aaf-4e0c-4d49-8021-8a16a884ed86
        detail:
          type: string
          example: >-
            Couldn't find 'credit record' for id
            'fbb7d15fa4c54ba0b077592665ef04a4ccrd'.
        code:
          type: string
          example: model_not_found
    Error500:
      x-struct: Elixir.SolarisToolkit.Web.Schemas.HttpError.Error500
      type: object
      title: Error500
      properties:
        title:
          type: string
          example: Internal server error
        status:
          type: string
          example: '500'
        id:
          type: string
          example: a95f2aaf-4e0c-4d49-8021-8a16a884ed86
        detail:
          type: string
          example: Internal server error
        code:
          type: string
          example: internal_server_error
    SolarisToolkit.Web.Json.Error:
      x-struct: Elixir.SolarisToolkit.Web.Json.ErrorBody.Error
      type: object
      title: SolarisToolkit.Web.Json.Error
      required:
        - id
        - status
        - code
        - title
        - detail
      properties:
        title:
          type: string
          description: Some short human friendly string
        status:
          type: integer
          description: The HTTP status
        source:
          type: object
          required:
            - field
            - message
          properties:
            message:
              type: string
            field:
              type: string
          nullable: true
          example:
            message: is_required
            field: name
          description: Optional computer-friendly error source description
        id:
          type: string
          description: A UUID, preferably the request ID
        detail:
          type: string
          description: 'Some human friendly-ish detail: field is required'
        code:
          type: string
          description: some_computer_friendly_string
        backtrace:
          type: array
          nullable: true
          items:
            type: string
          description: Optional array of backtrace lines
    SolarisToolkit.Web.Json.ErrorBody:
      x-struct: Elixir.SolarisToolkit.Web.Json.ErrorBody
      type: object
      title: SolarisToolkit.Web.Json.ErrorBody
      required:
        - errors
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/SolarisToolkit.Web.Json.Error'
    PersonCreditRecord.CreateFreelancerCreditRecordRequest:
      x-struct: >-
        Elixir.PersonCreditRecordWeb.V1.CreditRecords.CreateFreelancerOperation.CreateFreelancerCreditRecordRequest
      type: object
      title: PersonCreditRecord.CreateFreelancerCreditRecordRequest
      required:
        - source
      properties:
        source:
          type: string
          description: The source of the credit record file.
          example: solarisBank
          enum:
            - partner
            - solarisBank
        file:
          type: string
          nullable: true
          description: >-
            The credit record file content, Base64-encoded. Required only if
            `source` is `partner`.
