openapi: 3.0.0
info:
  title: 'YetiForce API for Webservice App. Type: Manage consents'
  description: "Skip the `/webservice` fragment for connections via ApiProxy. There are two ways to connect to API, with or without rewrite, below are examples of both:\n * rewrite\n * - __CRM_URL__/webservice/ManageConsents/Users/Login\n * - __CRM_URL__/webservice/ManageConsents/Accounts/RecordRelatedList/117/Contacts\n * without rewrite\n * - __CRM_URL__/webservice.php?_container=ManageConsents&module=Users&action=Login\n * - __CRM_URL__/webservice.php?_container=ManageConsents&module=Accounts&action=RecordRelatedList&record=117&param=Contacts"
  termsOfService: 'https://yetiforce.com/'
  contact:
    name: 'Devs API Team'
    url: 'https://yetiforce.com/'
    email: devs@yetiforce.com
  license:
    name: 'YetiForce Public License v3'
    url: 'https://yetiforce.com/en/yetiforce/license'
  version: '0.2'
servers:
  -
    url: 'https://gitdeveloper.yetiforce.com'
    description: 'Demo server of the development version'
  -
    url: 'https://gitstable.yetiforce.com'
    description: 'Demo server of the latest stable version'
paths:
  /webservice/ManageConsents/ApprovalsRegister/Record:
    post:
      tags:
        - Consents
      summary: 'Adds an consent entry'
      operationId: 425399d47c958ba5c538827d258fde0a
      requestBody:
        description: 'Required data for communication'
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ApprovalsRegisterRequestBody'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/ApprovalsRegisterRequestBody'
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalsRegisterRequestBody'
      responses:
        '200':
          description: 'Result of adding entry'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalsRegisterResponseBody'
            application/xml:
              schema:
                $ref: '#/components/schemas/ApprovalsRegisterResponseBody'
        '401':
          description: '`No sent token` OR `Invalid token`'
        '403':
          description: 'No permissions for module'
        '405':
          description: 'Method Not Allowed'
      security:
        -
          basicAuth: []
          ApiKeyAuth: []
          token: []
  /webservice/ManageConsents/Approvals/RecordsList:
    get:
      tags:
        - Consents
      summary: 'Gets the list of consents'
      operationId: 04e7ebb08f943d466f20bb0e98311271
      parameters:
        -
          name: x-row-limit
          in: header
          description: 'Get rows limit, default: 1000'
          required: false
          schema:
            type: integer
          example: 1000
        -
          name: x-row-offset
          in: header
          description: 'Offset, default: 0'
          required: false
          schema:
            type: integer
          example: 0
        -
          name: x-raw-data
          in: header
          description: 'Gets raw data'
          required: false
          schema:
            type: integer
            enum:
              - 0
              - 1
          example: 1
        -
          name: x-condition
          in: header
          description: 'Conditions [Json format]'
          required: false
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApprovalsConditionsRequest'
      responses:
        '200':
          description: 'List of consents'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConsentsResponseBody'
            application/xml:
              schema:
                $ref: '#/components/schemas/ConsentsResponseBody'
        '401':
          description: '`No sent token` OR `Invalid token`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
            application/xml:
              schema:
                $ref: '#/components/schemas/Exception'
        '403':
          description: 'No permissions for module'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
            application/xml:
              schema:
                $ref: '#/components/schemas/Exception'
        '405':
          description: 'Method Not Allowed'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Exception'
            application/xml:
              schema:
                $ref: '#/components/schemas/Exception'
      security:
        -
          basicAuth: []
          ApiKeyAuth: []
          token: []
  '/webservice/ManageConsents/{moduleName}/GetConsentsForEntry':
    post:
      tags:
        - Consents
      summary: 'Gets the list of consents for specific entry'
      operationId: 9fd993e544cb6935282883e505b8d1d6
      parameters:
        -
          name: moduleName
          in: path
          description: 'Module name'
          required: true
          schema:
            type: string
          example: Contacts
      requestBody:
        description: 'Required data for communication'
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ConsentsForEntryRequestBody'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/ConsentsForEntryRequestBody'
          application/json:
            schema:
              $ref: '#/components/schemas/ConsentsForEntryRequestBody'
      responses:
        '200':
          description: 'List of consents for specific entry'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConsentsForEntryResponseBody'
        '401':
          description: '`No sent token` OR `Invalid token`'
        '403':
          description: 'No permissions for module'
        '404':
          description: 'Not Found'
        '405':
          description: 'Method Not Allowed'
      security:
        -
          basicAuth: []
          ApiKeyAuth: []
          token: []
  '/webservice/ManageConsents/{moduleName}/SendEmail':
    post:
      tags:
        - Consents
      summary: 'Send e-mail'
      operationId: 86c8610aedbae9a8690ab71a3ae22134
      parameters:
        -
          name: moduleName
          in: path
          description: 'Module name'
          required: true
          schema:
            type: string
          example: Contacts
      requestBody:
        description: 'Required data for communication'
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/SendEmailRequestBody'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/SendEmailRequestBody'
          application/json:
            schema:
              $ref: '#/components/schemas/SendEmailRequestBody'
      responses:
        '200':
          description: 'Status of adding an email to the queue'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SendEmailResponseBody'
        '401':
          description: '`No sent token` OR `Invalid token`'
        '403':
          description: 'No permissions for module'
        '404':
          description: 'Not Found'
        '405':
          description: 'Method Not Allowed'
      security:
        -
          basicAuth: []
          ApiKeyAuth: []
          token: []
components:
  schemas:
    ApprovalsRegisterRequestBody:
      title: 'A list of fields required while creating an entry'
      description: 'The list is based on fields in the Consent register module. Accepting or declining consent takes place based on the value in the approvals_register_status field.'
      type: object
      example:
        subject: Text
        approvalsid: '123'
        contactid: '321'
        approvals_register_type: PLL_ACCEPTANCE
        approvals_register_status: PLL_FOR_VERIFICATION
        registration_date: '2019-11-12 12:00'
    ApprovalsRegisterResponseBody:
      title: 'Adding an entry'
      description: 'Result of adding entry'
      properties:
        status:
          description: 'A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error'
          type: integer
          enum:
            - 0
            - 1
        result:
          description: 'Result of adding entry'
          properties:
            id:
              description: 'New entry ID. Empty value means that the operation was unsuccessful.'
              type: integer
              example: 24842
            error:
              description: 'Error message. The variable exists when some of the provided data is incomplete and the entry could not be added.'
              type: string
              example: ''
          type: object
      type: object
    ApprovalsConditionsRequest:
      title: Conditions
      description: 'The list is based on fields in the Consent register module. fieldName - Field name, value - Value, operator - Specific operator, group - true/false. '
      type: object
      example:
        fieldName: approvals_status
        value: PLL_ACTIVE
        operator: e
    ConsentsResponseBody:
      title: 'List of consents'
      description: 'List of obtained consents'
      properties:
        status:
          description: 'A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error'
          type: integer
          enum:
            - 0
            - 1
        result:
          description: 'Specific response'
          properties:
            records:
              properties:
                '24862':
                  properties: { id: { description: 'Consent ID', type: integer, example: 24862 }, name: { description: Text, type: string, example: 'Consent for email' }, approvals_status: { description: Status, type: string, example: Active }, number: { description: Text, type: string, example: N12 }, assigned_user_id: { description: 'Assigned user name', type: string, example: 'Kowalski Adam' }, createdtime: { type: string, example: '2019-10-07 08:32:38' }, modifiedtime: { type: string, example: '2019-10-07 08:32:38' }, created_user_id: { description: 'Assigned user name', type: string, example: 'Kowalski Adam' }, shownerid: { description: 'Assigned user name', type: string, example: 'Kowalski Adam' }, description: { description: Description, type: string, example: 'I confirm to have read..' } }
                  type: object
              type: object
            rawData:
              properties:
                '24862':
                  properties: { id: { description: 'Consent ID', type: integer, example: 24862 }, name: { description: Text, type: string, example: 'Consent for email' }, approvals_status: { description: Status, type: string, example: PLL_ACTIVE }, number: { description: Text, type: string, example: N12 }, assigned_user_id: { description: 'Assigned user ID', type: integer, example: 245 }, createdtime: { type: string, example: '2019-10-07 08:32:38' }, modifiedtime: { type: string, example: '2019-10-07 08:32:38' }, created_user_id: { description: 'Assigned user ID', type: integer, example: 245 }, shownerid: { description: 'Assigned user name', type: string, example: 'Kowalski Adam' }, description: { description: Description, type: string, example: 'I confirm to have read..' } }
                  type: object
              type: object
            isMorePages:
              description: 'There are more entries'
              type: boolean
              example: true
          type: object
      type: object
    Exception:
      title: 'General - Error exception'
      description: 'Gets consents.'
      properties:
        status:
          description: '0 - error'
          type: integer
          enum:
            - 0
          example: 0
        error:
          description: 'Error  details'
          properties:
            message:
              description: 'To show more details turn on: config\Debug.php apiShowExceptionMessages = true'
              type: string
              example: 'Invalid method'
            code:
              type: integer
              example: 405
            file:
              description: 'default disabled to enable set: config\Debug.php apiShowExceptionBacktrace = true'
              type: string
              example: api\webservice\Portal\BaseAction\Files.php
            line:
              description: 'default disabled to enable set: config\Debug.php apiShowExceptionBacktrace = true'
              type: integer
              example: 101
            backtrace:
              description: 'default disabled to enable set: config\Debug.php apiShowExceptionBacktrace = true'
              type: string
              example: '#0 api\webservice\Portal\BaseAction\Files.php (101) ....'
          type: object
      type: object
    ConsentsForEntryRequestBody:
      title: 'Request body for GetConsentsForEntry'
      properties:
        token:
          description: 'Entry unique ID (Token type field in the module is required)'
          type: string
      type: object
    ConsentsForEntryResponseBody:
      title: 'Response body for GetConsentsForEntry'
      description: 'Gets consents.'
      properties:
        status:
          description: 'A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error'
          type: integer
          enum:
            - 0
            - 1
        result:
          description: 'Specific response'
          properties:
            id:
              description: 'Record ID'
              type: integer
              example: 24842
            consents:
              description: 'Get the edit value in display view'
              type: object
              additionalProperties:
                description: 'Data from the associated module'
                type: integer
                example: 24862
          type: object
      type: object
    SendEmailRequestBody:
      title: 'Request body for SendEmail'
      properties:
        e-mail:
          description: 'E-mail address (Token type field in the module is required)'
          type: string
        templateId:
          description: 'Specific ID of the email template'
          type: integer
      type: object
    SendEmailResponseBody:
      title: 'Response body for SendEmail'
      description: 'Send e-mail.'
      properties:
        status:
          description: 'A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error'
          type: integer
          enum:
            - 0
            - 1
        result:
          description: 'Added mail to quote for send: true - success , false - fail'
          type: boolean
          example: true
      type: object
  securitySchemes:
    basicAuth:
      type: http
      description: 'Basic Authentication header'
      scheme: basic
    ApiKeyAuth:
      type: apiKey
      description: 'Webservice api key header'
      name: X-API-KEY
      in: header
    token:
      type: apiKey
      description: 'Webservice api token by user header'
      name: X-TOKEN
      in: header
