openapi: 3.0.0
info:
  title: Fraud API
  contact:
    name: API Integration Support
    email: integration@dintero.com
  description: >
    # Changelog

    All notable changes to the API.



    ## 2024-11-01


    > Adds endpoints for getting reports of alarms based on observed events from
    the psp-service.

    >   - [POST
    /v1/accounts/{aid}/fraud/reports/generate](/fraud-api/reports/api_fraud_reports_generate_post)


    > Adds endpoints for getting alarms based on observed events from the
    psp-service.

    >   - [GET
    /v1/accounts/{aid}/fraud/alarms](/fraud-api/alarms/api_fraud_alarms_get)


    ## 2024-10-01


    > Adds endpoints for block rules, proxy requests to the PSP service.

    >   - [POST
    /v1/accounts/{aid}/fraud/psp-block-rules](/fraud-api/psp-block-rules/api_fraud_psp_block_rules_post)

    >   - [GET
    /v1/accounts/{aid}/fraud/psp-block-rules](/fraud-api/psp-block-rules/api_fraud_psp_block_rules_get)

    >   - [GET
    /v1/accounts/{aid}/fraud/psp-block-rules/{id}](/fraud-api/psp-block-rules/api_fraud_psp_block_rules_id_get)

    >   - [DELETE
    /v1/accounts/{aid}/fraud/psp-block-rules/{id}](/fraud-api/psp-block-rules/api_fraud_psp_block_rules_id_delete)
  version: LATEST
  license:
    name: UNLICENSED
    url: https://dintero.com
  x-logo:
    url: https://docs.dintero.com/img/dintero-dark-padded.svg
    altText: Dintero Logo
security:
  - JWT: []
tags:
  - name: psp-block-rules
    x-displayName: PSP Block Rules
    description: |
      Resources used to manage PSP block rules
  - name: alarms
    x-displayName: Alarms
    description: |
      Resources with fraud alarms
  - name: reports
    x-displayName: Reports
    description: |
      Resources with fraud reports
  - name: rules
    x-displayName: Alarm rules
    description: |
      Resources for managing alarm rules
paths:
  /accounts/{aid}/fraud/alarms:
    get:
      operationId: api_fraud_alarms_get
      summary: api_fraud_alarms_get
      description: |
        Lists arlams in fraud service.

        **scopes**:
        - admin:fraud:/admin
        - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - alarms
      parameters:
        - $ref: '#/components/parameters/accountId'
      responses:
        '200':
          $ref: '#/components/responses/FraudAlarmCollection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Collection of current alarms
          sidebarTitle: Collection of current alarms
  /accounts/{aid}/fraud/psp-block-rules:
    post:
      operationId: api_fraud_psp_block_rules_post
      summary: api_fraud_psp_block_rules_post
      description: >
        Create block rules for blocking payments based on certain criteria in
        the PSP-service.


        **scopes**:

        - admin:fraud:/admin

        - write:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - write:fraud:/write
      tags:
        - psp-block-rules
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/PspBlockRule'
      responses:
        '200':
          $ref: '#/components/responses/PspBlockRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Create a new PSP block rule
          sidebarTitle: Create a new PSP block rule
    get:
      operationId: api_fraud_psp_block_rules_get
      summary: api_fraud_psp_block_rules_get
      description: >
        Lists block rules for blocking payments based on certain criteria in the
        PSP-service.


        **scopes**:

        - admin:fraud:/admin

        - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - psp-block-rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: type
          in: query
          description: >-
            parameter to filter the block rules by type. Return all types by
            default.
          schema:
            type: string
            enum:
              - ip_cidr_block
              - bin
              - email
              - phone_number
              - name
              - country
        - name: limit
          in: query
          description: A limit on the number of objects to be returned. Default is all.
          schema:
            type: integer
        - name: starting_after
          in: query
          description: |
            cursor for use in pagination. starting_after is an object ID
            that defines your place in the list. For instance, if you make
            a list request and receive 100 objects, ending with `obj_foo`,
            your subsequent call can include `starting_after=obj_foo`
            in order to fetch the next page of the list.
          schema:
            type: string
            format: block_rule_id
        - name: deleted
          in: query
          description: >-
            parameter to filter deleted object in the list. Default is false and
            will return only non deleted objects.
          schema:
            type: boolean
      responses:
        '200':
          $ref: '#/components/responses/PspBlockRuleCollection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Collection of PSP block rules
          sidebarTitle: Collection of PSP block rules
  /accounts/{aid}/fraud/psp-block-rules/{id}:
    get:
      operationId: api_fraud_psp_block_rules_id_get
      summary: api_fraud_psp_block_rules_id_get
      description: |
        **scopes**:
          - admin:fraud:/admin
          - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - psp-block-rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: id
          in: path
          description: Id of the PSP block rule
          schema:
            type: string
          required: true
      responses:
        '200':
          $ref: '#/components/responses/PspBlockRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Get a PSP block rule
          sidebarTitle: Get a PSP block rule
    delete:
      operationId: api_fraud_psp_block_rules_id_delete
      summary: api_fraud_psp_block_rules_id_delete
      description: |
        **scopes**:
          - admin:fraud:/admin
          - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - psp-block-rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: id
          in: path
          description: Id of the PSP block rule
          schema:
            type: string
          required: true
      responses:
        '200':
          $ref: '#/components/responses/PspBlockRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Delete a PSP block rule
          sidebarTitle: Delete a PSP block rule
  /accounts/{aid}/fraud/reports/generate:
    post:
      operationId: api_fraud_reports_generate_post
      summary: api_fraud_reports_generate_post
      description: >
        Returns a file with report data from the fraud service.


        report type alarms CSV example:

        ```

        id;rule_type;rule_dimension;rule_threshold;severity;account_id;window_start;window_end;metric_account_id:metric_type;metric_value;metric_numerator;metric_denominator;entered_at;expires_at

        7e4ff3e5-18fe-4932-b322-2a5f549a141f;bin_attack;55555555;100.0;high;P00000000;2018-02-13T00:00:00;2018-02-13T23:59:59;P11112230;count;200;200;1;2018-02-13T15:28:48;2018-02-20T15:28:48

        ```


        **scopes**:

        - admin:fraud:/admin

        - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - reports
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: Accept
          in: header
          required: true
          schema:
            type: string
            enum:
              - text/csv
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FraudReportGenerate'
        description: Automation to create
        required: true
      responses:
        '200':
          description: Report file matching format in Accept header
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Get a alarms report from the fraud service
          sidebarTitle: Get a alarms report from the fraud service
  /accounts/{aid}/fraud/rules:
    get:
      operationId: api_fraud_merchant_metric_rules_collection_get
      summary: api_fraud_merchant_metric_rules_collection_get
      description: |
        Lists of merchant metric rules defined in fraud service.

        **scopes**:
        - admin:fraud:/admin
        - read:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - read:fraud:/admin
      tags:
        - rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - $ref: '#/components/parameters/metricAccountId'
      responses:
        '200':
          $ref: '#/components/responses/FraudMerchantMetricRuleCollection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Collection of merchant metric rules
          sidebarTitle: Collection of merchant metric rules
    post:
      operationId: api_fraud_merchant_metric_rules_collection_post
      summary: api_fraud_merchant_metric_rules_collection_post
      description: >
        Create a merchant metric rule for triggering alrmes when metric values
        exceed the defined thresholds.


        **scopes**:

        - admin:fraud:/admin

        - write:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - write:fraud:/write
      tags:
        - rules
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        $ref: >-
          #/components/requestBodies/api_fraud_merchant_metric_rules_collection_postOptions
      responses:
        '200':
          $ref: '#/components/responses/FraudMerchantMetricRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Create a merchant metric rules
          sidebarTitle: Create a merchant metric rules
  /accounts/{aid}/fraud/rules/{id}:
    put:
      operationId: api_fraud_merchant_metric_rules_by_id_put
      summary: api_fraud_merchant_metric_rules_by_id_put
      description: >
        Update a merchant metric rule for triggering alrmes when metric values
        exceed the defined thresholds.


        **scopes**:

        - admin:fraud:/admin

        - write:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - write:fraud:/write
      tags:
        - rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: id
          in: path
          description: Id of the rule
          schema:
            type: string
          required: true
      requestBody:
        $ref: >-
          #/components/requestBodies/api_fraud_merchant_metric_rules_collection_postOptions
      responses:
        '200':
          $ref: '#/components/responses/FraudMerchantMetricRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Update a merchant metric rule by id
          sidebarTitle: Update a merchant metric rule by id
    delete:
      operationId: api_fraud_merchant_metric_rules_by_id_delete
      summary: api_fraud_merchant_metric_rules_by_id_delete
      description: |
        Deletes a merchant metric rule.

        **scopes**:
        - admin:fraud:/admin
        - write:fraud:/admin
      x-scopes:
        - admin:fraud:/admin
        - write:fraud:/write
      tags:
        - rules
      parameters:
        - $ref: '#/components/parameters/accountId'
        - name: id
          in: path
          description: Id of the rule
          schema:
            type: string
          required: true
      responses:
        '200':
          $ref: '#/components/responses/FraudMerchantMetricRule'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      x-mint:
        metadata:
          title: Delete a merchant metric rule by id
          sidebarTitle: Delete a merchant metric rule by id
servers:
  - url: https://api.dintero.com/v1
components:
  parameters:
    accountId:
      name: aid
      description: |
        An id that uniquely identifies the account.
      in: path
      required: true
      schema:
        type: string
        format: ^[PT]{1}\d{8}$
        minLength: 9
        maxLength: 9
    metricAccountId:
      name: metric_account_id
      description: |
        An id that identifies the account that is measured by a rule.
      in: query
      required: false
      schema:
        type: string
        minLength: 9
        maxLength: 9
        pattern: ^[PT]{1}\d{8}$
  responses:
    FraudAlarmCollection:
      description: Fraud alarms response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FraudAlarmCollection'
    BadRequest:
      description: Bad / Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Unexpected Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PspBlockRuleCollection:
      description: Block rule response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PspBlockRuleCollection'
    PspBlockRule:
      description: PspBlockRuleResponse
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PspBlockRule'
    NotFound:
      description: Resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    FraudMerchantMetricRuleCollection:
      description: Fraud merchant metric rules response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FraudMerchantMetricRuleCollection'
    FraudMerchantMetricRule:
      description: Fraud merchant metric rule response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FraudMerchantMetricRule'
  requestBodies:
    api_fraud_merchant_metric_rules_collection_postOptions:
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/FraudMerchantMetricRule'
  securitySchemes:
    JWT:
      type: http
      description: >
        Bearer authentication (token authentication) should be used for
        accessing the API.


        Use [Get Token](/api-reference/authenticate/aid_auths_oauth_token_post)
        to get an access token for client credentials.

        Pass the token in the request header:

            Authorization: Bearer {access_token}

        where the **access_token** is JSON Web Tokens (JWT).
      scheme: bearer
      bearerFormat: JWT
  schemas:
    PspBlockRuleBIN:
      type: object
      x-discriminator-value: bin
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: >-
                Block rule range value for BIN (the first six to eight digits of
                the Primary Account Number)
              additionalProperties: false
              required:
                - bin
              properties:
                bin:
                  type: object
                  required:
                    - min
                  properties:
                    min:
                      type: string
                      description: >-
                        The first six to eight digits of the Primary Account
                        Number (PAN)
                    max:
                      type: string
                      description: >-
                        The first six to eight digits of the Primary Account
                        Number (PAN). Set by default to min value if not
                        provided
                  additionalProperties: false
                  description: >
                    Block a payment card whose card number starts within the
                    range of number between min and max.
            type:
              type: string
              enum:
                - bin
      title: bin
    PspBlockRuleIP:
      type: object
      x-discriminator-value: ip_cidr_block
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: Block rule value for IP
              additionalProperties: false
              required:
                - ip_cidr_block
              properties:
                ip_cidr_block:
                  type: string
                  additionalProperties: false
                  description: >
                    Block a specific IP address or a range of IP addresses.


                    To block a specific IPv4 address, use the IP address
                    followed by a slash and the number 32. For example,
                    127.0.0.1/32.
            type:
              type: string
              enum:
                - ip_cidr_block
      title: ip_cidr_block
    PspBlockRuleCountry:
      type: object
      x-discriminator-value: country
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: Block rule value for country
              additionalProperties: false
              required:
                - country
              properties:
                country:
                  type: string
                  additionalProperties: false
                  description: |
                    Block a specific country.

                    Uppercase two-letter country code.
            type:
              type: string
              enum:
                - country
      title: country
    PspBlockRuleEmail:
      type: object
      x-discriminator-value: email
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: Block rule value for email
              additionalProperties: false
              required:
                - email
              properties:
                email:
                  type: string
                  additionalProperties: false
                  description: |
                    Block a specific email address.
            type:
              type: string
              enum:
                - email
      title: email
    PspBlockRuleName:
      type: object
      x-discriminator-value: name
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: Block rule value for name
              additionalProperties: false
              required:
                - name
              properties:
                name:
                  type: string
                  additionalProperties: false
                  description: |
                    Block a specific name
            type:
              type: string
              enum:
                - name
      title: name
    PspBlockRulePhoneNumber:
      type: object
      x-discriminator-value: phone_number
      allOf:
        - $ref: '#/components/schemas/PspBlockRuleBase'
        - required:
            - value
          additionalProperties: false
          properties:
            value:
              type: object
              description: Block rule value for phone number
              additionalProperties: false
              required:
                - phone_number
              properties:
                phone_number:
                  type: string
                  additionalProperties: false
                  description: |
                    Block a specific phone number, including the country code.
                    Eg. +4798765432
            type:
              type: string
              enum:
                - phone_number
      title: phone_number
    FraudMerchantMetricRuleRatio:
      type: object
      x-discriminator-value: ratio
      allOf:
        - $ref: '#/components/schemas/FraudMerchantMetricRuleBase'
        - required:
            - metric_value_numerator
            - metric_value_denominator
          additionalProperties: false
          properties:
            metric_value_numerator:
              $ref: '#/components/schemas/DataPoint'
            metric_value_denominator:
              $ref: '#/components/schemas/DataPoint'
            metric_variant:
              type: string
              enum:
                - ratio
      title: ratio
    FraudMerchantMetricRuleValue:
      type: object
      x-discriminator-value: value
      allOf:
        - $ref: '#/components/schemas/FraudMerchantMetricRuleBase'
        - required:
            - metric_value
          additionalProperties: false
          properties:
            metric_value:
              $ref: '#/components/schemas/DataPoint'
            metric_variant:
              type: string
              enum:
                - value
      title: value
    GteFilter:
      type: object
      x-discriminator-value: gte
      allOf:
        - $ref: '#/components/schemas/FilterBase'
        - required:
            - field
            - value
          additionalProperties: false
          properties:
            field:
              type: string
              enum:
                - amount
            value:
              type: number
            type:
              type: string
              enum:
                - gte
      title: gte
    LteFilter:
      type: object
      x-discriminator-value: lte
      allOf:
        - $ref: '#/components/schemas/FilterBase'
        - required:
            - field
            - value
          additionalProperties: false
          properties:
            field:
              type: string
              enum:
                - amount
            value:
              type: number
            type:
              type: string
              enum:
                - lte
      title: lte
    MatchFilter:
      type: object
      x-discriminator-value: match
      allOf:
        - $ref: '#/components/schemas/FilterBase'
        - required:
            - field
            - value
          additionalProperties: false
          properties:
            field:
              type: string
              enum:
                - amount
            values:
              type: array
              items:
                type: string
                description: The values to match
            type:
              type: string
              enum:
                - match
      title: match
    FraudAlarm:
      type: object
      description: Alarm in the fraud-service
      required:
        - rule_type
        - rule_dimension
        - rule_threshold
        - severity
        - window_start
        - window_end
        - metric_type
        - metric_value
        - metric_numerator
        - metric_denominator
        - entered_at
        - updated_at
        - expires_at
      properties:
        rule_id:
          type: string
        rule_type:
          type: string
        rule_dimension:
          type: string
        rule_threshold:
          type: number
        severity:
          type: string
        account_id:
          type: string
        window_start:
          type: string
          format: date-time
        window_end:
          type: string
          format: date-time
        metric_type:
          type: string
        metric_value:
          type: number
        metric_numerator:
          type: number
        metric_denominator:
          type: number
        entered_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        expires_at:
          type: string
          format: date-time
    FraudAlarmCollection:
      type: object
      required:
        - alarms
      additionalProperties: false
      properties:
        alarms:
          type: array
          items:
            $ref: '#/components/schemas/FraudAlarm'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            code:
              type: string
              description: The code used to identify the error/warning
            errors:
              type: array
              description: The nested error(s) encountered during validation
              items:
                type: object
            message:
              type: string
              description: The human readable description of the error/warning
    PspBlockRule:
      description: PSP BlockRule
      discriminator:
        propertyName: type
        mapping:
          bin: '#/components/schemas/PspBlockRuleBIN'
          ip_cidr_block: '#/components/schemas/PspBlockRuleIP'
          country: '#/components/schemas/PspBlockRuleCountry'
          email: '#/components/schemas/PspBlockRuleEmail'
          name: '#/components/schemas/PspBlockRuleName'
          phone_number: '#/components/schemas/PspBlockRulePhoneNumber'
      oneOf:
        - $ref: '#/components/schemas/PspBlockRuleBIN'
        - $ref: '#/components/schemas/PspBlockRuleIP'
        - $ref: '#/components/schemas/PspBlockRuleCountry'
        - $ref: '#/components/schemas/PspBlockRuleEmail'
        - $ref: '#/components/schemas/PspBlockRuleName'
        - $ref: '#/components/schemas/PspBlockRulePhoneNumber'
    PspBlockRuleCollection:
      type: object
      required:
        - block_rules
      additionalProperties: false
      properties:
        block_rules:
          type: array
          items:
            $ref: '#/components/schemas/PspBlockRule'
    FraudReportGenerate:
      type: object
      description: Report type to generate
      required:
        - report_type
        - entered_at
      properties:
        report_type:
          type: string
          enum:
            - alarms
        rule_type:
          type: string
        entered_at:
          type: object
          required:
            - gte
            - lte
          properties:
            gte:
              type: string
              format: date-time
            lte:
              type: string
              format: date-time
    FraudMerchantMetricRule:
      description: Rule for fraud merchant metric
      discriminator:
        propertyName: metric_variant
        mapping:
          ratio: '#/components/schemas/FraudMerchantMetricRuleRatio'
          value: '#/components/schemas/FraudMerchantMetricRuleValue'
      oneOf:
        - $ref: '#/components/schemas/FraudMerchantMetricRuleRatio'
        - $ref: '#/components/schemas/FraudMerchantMetricRuleValue'
    FraudMerchantMetricRuleCollection:
      type: object
      required:
        - rules
      additionalProperties: false
      properties:
        rules:
          type: array
          items:
            $ref: '#/components/schemas/FraudMerchantMetricRule'
    FilterInterval:
      type: string
      enum:
        - 1 minute
        - 5 minute
        - 10 minute
        - 15 minute
        - 1 hour
        - 1 day
        - 1 week
        - 1 month
    Filter:
      discriminator:
        propertyName: type
        mapping:
          gte: '#/components/schemas/GteFilter'
          lte: '#/components/schemas/LteFilter'
          match: '#/components/schemas/MatchFilter'
      oneOf:
        - $ref: '#/components/schemas/GteFilter'
        - $ref: '#/components/schemas/LteFilter'
        - $ref: '#/components/schemas/MatchFilter'
    DataPoint:
      description: Data-point for merchant metric rule
      type: object
      required:
        - type
        - aggregate_window
        - filters
      properties:
        type:
          type: string
          description: |
            Data-point type
          enum:
            - count
            - sum
        aggregate_window:
          $ref: '#/components/schemas/FilterInterval'
        filters:
          type: array
          items:
            $ref: '#/components/schemas/Filter'
    PspBlockRuleBase:
      type: object
      description: PSP BlockRule
      properties:
        type:
          type: string
          description: |
            PSP Block rule type
        description:
          type: string
          description: Describes the purpose of the block rule
        blocked_by:
          description: >-
            Humman readable version of the system that created the block rule,
            eg. 'backoffice' or 'fraud-service'
          type: string
        expires_at:
          description: >-
            An expiration date-time for the block rule. A rule will only be
            active until this date-time.
          format: date-time
        id:
          type: string
          format: uuid
          description: |
            An UUID that uniquely identifies the resource
          readOnly: true
        created_at:
          type: string
          format: date-time
          description: |
            The date-time when the resource was created
          readOnly: true
        created_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client that created the resource
          readOnly: true
        updated_at:
          type: string
          format: date-time
          description: |
            The date-time when the resource was last updated
          readOnly: true
        updated_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client that updated the resource
          readOnly: true
        deleted_at:
          type: string
          format: date-time
          readOnly: true
        deleted_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client that deleted the resource
          readOnly: true
      required:
        - type
        - blocked_by
    FraudMerchantMetricRuleBase:
      type: object
      description: Rule for fraud merchant metric
      properties:
        rule_type:
          type: string
        account_id:
          type: string
        metric_account_id:
          type: string
        severity:
          type: string
          enum:
            - low
            - medium
            - high
            - urgent
        metric_threshold_upper:
          type: number
        metric_threshold_lower:
          type: number
        metric_variant:
          type: string
        id:
          type: string
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        deleted_at:
          type: string
          format: date-time
          readOnly: true
        created_by:
          type: string
          readOnly: true
        updated_by:
          type: string
          readOnly: true
        deleted_by:
          type: string
          readOnly: true
      required:
        - rule_type
        - account_id
        - metric_account_id
        - severity
        - metric_threshold_upper
        - metric_threshold_lower
    FilterBase:
      type: object
      properties:
        type:
          type: string
      required:
        - type
