openapi: 3.0.3
info:
  title: Everflow Affiliate API - Traffic
  description: >
    Traffic blocking and traffic control endpoints for the Everflow Affiliate API.
    Affiliates can view blocked offer sources, traffic control rules, and blocked
    variables that affect their traffic.
  version: 1.0.0
servers:
  - description: Production Server
    url: https://api.eflow.team/v1
tags:
  - name: Affiliate Traffic
    description: Endpoints for viewing traffic blocking rules and controls.
paths:
  /affiliates/trafficblocking:
    get:
      summary: Find All Blocked Offer Sources
      tags:
        - Affiliate Traffic
      parameters:
        - name: network_offer_id
          in: query
          description: Filter by specific offer ID.
          schema:
            type: integer
        - name: traffic_blocking_status
          in: query
          description: Filter by blocking status.
          schema:
            type: string
            enum:
              - active
              - inactive
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  traffic_blocking:
                    type: array
                    description: Array of blocked offer source entries.
                    items:
                      type: object
                      properties:
                        network_offer_id:
                          type: integer
                          description: The offer ID associated with this block.
                        relationship:
                          type: object
                          description: Related data for this block.
                          properties:
                            variables:
                              type: object
                              description: Variables that define the blocking rule.
                              properties:
                                total:
                                  type: integer
                                  description: Total number of variable entries.
                                entries:
                                  type: array
                                  description: Array of variable entries.
                                  items:
                                    type: object
                                    properties:
                                      comparison_method:
                                        type: string
                                        description: How the variable is compared (contains, exact_match, begins_with, etc.).
                                      variable:
                                        type: string
                                        description: The variable being blocked (e.g. sub1, sub2, source_id).
                                      variable_value:
                                        type: string
                                        description: The value of the variable that triggers the block.
      security:
        - API Key: []

  /affiliates/trafficcontrols:
    get:
      summary: Find All Traffic Controls
      tags:
        - Affiliate Traffic
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  traffic_controls:
                    type: array
                    description: Array of traffic control rules.
                    items:
                      $ref: "#/components/schemas/TrafficControl"
      security:
        - API Key: []

  /affiliates/trafficcontrols/{controlId}:
    get:
      summary: Find Traffic Control By ID
      tags:
        - Affiliate Traffic
      parameters:
        - name: controlId
          in: path
          required: true
          description: The numeric ID of the traffic control rule.
          schema:
            type: integer
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TrafficControl"
        "404":
          description: Traffic control not found or does not apply to the authenticated affiliate.
      security:
        - API Key: []

  /affiliates/blockedvariables:
    post:
      summary: Find All Blocked Variables
      tags:
        - Affiliate Traffic
      requestBody:
        required: true
        content:
          application/json:
            example:
              network_offer_id: 1
              timezone_id: 90
              from: "2025-01-01"
              to: "2025-01-31"
            schema:
              type: object
              required:
                - network_offer_id
                - timezone_id
              properties:
                network_offer_id:
                  type: integer
                  description: The offer ID to retrieve blocked variables for. Required.
                timezone_id:
                  type: integer
                  description: Timezone identifier for the date range.
                from:
                  type: string
                  description: Start date for the lookup period. Format `YYYY-MM-DD`.
                to:
                  type: string
                  description: End date for the lookup period. Format `YYYY-MM-DD`.
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: object
                properties:
                  variables:
                    type: array
                    description: Array of blocked variable entries.
                    items:
                      type: object
                      properties:
                        variable:
                          type: string
                          description: The variable name (e.g. sub1, sub2, source_id).
                        value:
                          type: string
                          description: The blocked variable value.
                        operator:
                          type: string
                          description: The comparison operator used for blocking (equals, contains, etc.).
      security:
        - API Key: []

components:
  schemas:
    TrafficControl:
      type: object
      properties:
        network_traffic_control_id:
          type: integer
          description: Unique identifier for the traffic control rule.
        status:
          type: string
          description: Status of the control rule (active, inactive).
        is_apply_all_offers:
          type: boolean
          description: Whether this control applies to all offers or specific ones.
        control_type:
          type: string
          description: The type of traffic control action (block, redirect, etc.).
        date_valid_from:
          type: string
          description: Start date when the control rule becomes effective. Empty string if not set.
        date_valid_to:
          type: string
          description: End date when the control rule expires. Empty string if not set.
        comparison_method:
          type: string
          description: Method used to compare variables (exact_match, contains, begins_with, etc.).
        variables:
          type: array
          description: Variable names that define the control matching criteria (e.g. "ip", "sub1").
          items:
            type: string
        relationship:
          type: object
          description: Related data for this control rule.
          properties:
            values:
              type: array
              description: The values to match against for the specified variables.
              items:
                type: string

  securitySchemes:
    API Key:
      description: >
        The affiliate's API key generated from the Affiliate Portal.
        Uses the X-Eflow-Api-Key header.
      in: header
      name: X-Eflow-Api-Key
      type: apiKey
