Advertisement
joeberetta

Tezro Tollar ad system API

May 14th, 2024 (edited)
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 10.94 KB | Source Code | 0 0
  1. openapi: '3.0.3'
  2. info:
  3.   title: Tollar AdSystem API
  4.   version: '1.0.0'
  5.   description: |
  6.    Tollar AdSystem is Tezro bonus and promotion system for merchants.
  7.     ---
  8.     This API is available for merchants of Tezro after registering in Tollar AdSystem using app.
  9.  
  10.     <b>Summary</b>
  11.     - The system is for merchants, who plans to improve customer conversions and sails using givebacks (bonus) to customers based on their activity (e.g. X funds for product view or share)
  12.     - The API is used as bridge between merchants' system and Tezro AdSystem.
  13.     - Currently API provides two endpoints:
  14.       - `POST /activities` - for sending tracked customer activity to Tezro for future givebacks to customer. Available to use right from client-side (browser or mobile app)
  15.       - `GET /customers/:customer_id` - for retrieving customers current state in Tezro bonus system
  16.     - Detailed description of DTOs and data types are described right in schemas, please expand them to get more info
  17.  
  18.     <b>Developer notes</b>
  19.     - Currently API Security is under construction and accepts any valid string value (error causes if `PublicApiKey` header is missing`)
  20.     - All endpoints require `PublicApiKey`
  21.     - Private (server-to-server) endpoints will also require `SignedAuthKey` auth header (currently is /customers/ and it's under construction)
  22.     - `POST /activities` endpoint in the production mode will also use extra mechanisms like origin domains and ip adresses whitelisting, browser fingerprinting and rate-limits to reduce system abuse from public and fraudulent access
  23.     - Timestamp header is used to validate actuality of requests and reply MITM attacks
  24.  
  25. servers:
  26.   - url: https://dev-openapi.tezro.com/adsystem/mock
  27.     description: Dev mock server
  28.   - url: http://localhost:8080
  29.     description: For local development
  30.  
  31. tags:
  32.   - name: Activities
  33.     description: Endpoints realted to creating customer activities
  34.   - name: Customers
  35.     description: Endpoints realted to tracking customers' info
  36.  
  37. paths:
  38.   /activities:
  39.     post:
  40.       operationId: addActivity
  41.       summary: Add new activity info
  42.       description: Based on `customer_id` will register new or update existing customer info.
  43.       tags:
  44.        - Activities
  45.       security:
  46.         - PublicApiKey: []
  47.       parameters:
  48.         - $ref: '#/components/parameters/Timestamp'
  49.       requestBody:
  50.         required: true
  51.         content:
  52.           application/json:
  53.             schema:
  54.               $ref: '#/components/schemas/AddActivityPayloadDto'
  55.       responses:
  56.         '400':
  57.           $ref: '#/components/responses/400_bad_request'
  58.         '401':
  59.           $ref: '#/components/responses/401_missing_auth'
  60.         '403':
  61.           $ref: '#/components/responses/403_forbidden'
  62.         '201':
  63.           $ref: '#/components/responses/201_empty_ok'
  64.  
  65.   /customers/{customer_id}:
  66.     get:
  67.       operationId: getCustomer
  68.       summary: Get customer info
  69.       tags:
  70.        - Customers
  71.       security:
  72.         - PublicApiKey: []
  73.         - SignedAuthKey: []
  74.       parameters:
  75.         - $ref: '#/components/parameters/Timestamp'
  76.         - in: path
  77.           required: true
  78.           name: customer_id
  79.           examples:
  80.             Customer not linked to Tezro:
  81.               value: customer-not-linked-to-tezro
  82.             Customer linked to Tezro:
  83.               value: customer-linked-to-tezro
  84.           schema:
  85.             $ref: '#/components/schemas/CustomerId'
  86.       responses:
  87.         '401':
  88.           $ref: '#/components/responses/401_missing_auth'
  89.         '403':
  90.           $ref: '#/components/responses/403_forbidden'
  91.         '404':
  92.           $ref: '#/components/responses/404_not_found'
  93.         '200':
  94.           description: Customer info
  95.           content:
  96.             application/json:
  97.               schema:
  98.                 $ref: '#/components/schemas/CustomerDto'
  99.               examples:
  100.                 Customer not linked to Tezro:
  101.                   description: Example state of DTO for customer, who not authorized and linked account in Tezro yet
  102.                   value:
  103.                     customer_id: customer-not-linked-to-tezro
  104.                     created_at: 2024-05-14T05:02:34.234Z
  105.                     code: 'refer-code-customer-not-linked-to-tezro'
  106.                     link_to_app: 'https://tezro.app.link/customer-not-linked-to-tezro'
  107.                     balance:
  108.                       total_earned_tollars: '10'
  109.                       total_earned_in_usd: '0.01'
  110.                       today_earned_tollars: '10'
  111.                       today_earned_in_usd: '0.01'
  112.                 Customer linked to Tezro:
  113.                   description: Example state of DTO for customer, who linked account in Tezro
  114.                   value:
  115.                     customer_id: customer-linked-to-tezro
  116.                     created_at: 2024-05-14T05:02:34.234Z
  117.                     code: 'refer-code-customer-linked-to-tezro'
  118.                     link_to_app: 'https://tezro.app.link/customer-linked-to-tezro'
  119.                     balance:
  120.                       total_earned_tollars: '100'
  121.                       total_earned_in_usd: '0.1'
  122.                       today_earned_tollars: '10'
  123.                       today_earned_in_usd: '0.01'
  124.                     linked_user_id: tezro-user-id
  125.                     linked_user_at: 2024-05-14T15:02:34.234Z
  126.  
  127. components:
  128.  # Security schemas for current API
  129.   # TODO WIP
  130.   securitySchemes:
  131.     PublicApiKey:
  132.       type: apiKey
  133.       name: KeyId
  134.       in: header
  135.     SignedAuthKey:
  136.       type: apiKey
  137.       name: x-tezro-signature
  138.       in: header
  139.       description: WIP. Calculated for every request. For mock or dev servers may pass `API_INTEGRATE`.
  140.  
  141.   parameters:
  142.     Timestamp:
  143.       name: timestamp
  144.       in: header
  145.       required: true
  146.       schema:
  147.         $ref: '#/components/schemas/DateTime'
  148.  
  149.   # DTOs and other data types
  150.   schemas:
  151.     DateTime:
  152.       description: System wide date-time format. Prefer to use UTC time.
  153.       externalDocs:
  154.         url: https://datatracker.ietf.org/doc/html/rfc3339#section-5.6
  155.       type: string
  156.       format: date-time
  157.       example: 2024-05-14T05:02:34.234Z
  158.     CustomerId:
  159.       type: string
  160.       description: "Customer's id"
  161.       example: 'ea077b53-012d-4efe-99b6-2de5a17630dd'
  162.  
  163.     # Add new activity request payload
  164.     AddActivityPayloadDto:
  165.       type: object
  166.       required:
  167.        - tag
  168.         - customer_id
  169.         - entity_id
  170.       properties:
  171.         tag:
  172.           $ref: '#/components/schemas/ActivityTagEnum'
  173.         customer_id:
  174.           $ref: '#/components/schemas/CustomerId'
  175.         entity_id:
  176.           description: Entity is universal name for this endpoint. Pass here system-wide unique value for entity like product, order, product review and etc.
  177.           type: string
  178.           example: 'some-product-or-order-or-other-entity-id'
  179.         meta:
  180.           description: |
  181.            Any valid JSON object. Tezro stores it and provides you ability to do analytics based on this data
  182.             You are able to pass here extra info about event (e.g. customers' session duration or current page info or product review notes)
  183.           type: object
  184.           example: { key: value }
  185.  
  186.     # Activity types (enum)
  187.     ActivityTagEnum:
  188.       type: string
  189.       description: Activity tag unique code. List below is to be extended in the future.
  190.       example: 'view_product'
  191.       enum:
  192.        - view_product
  193.         - buy_product
  194.         - share_product
  195.         - favorite_product
  196.         - view_shared_product
  197.         - buy_shared_product
  198.         - leave_review
  199.  
  200.     # Merchant's
  201.     CustomerDto:
  202.       type: object
  203.       description: Customer info
  204.       required:
  205.        - id
  206.         - created_at
  207.         - code
  208.         - link_to_app
  209.       properties:
  210.         customer_id:
  211.           $ref: '#/components/schemas/CustomerId'
  212.         created_at:
  213.           $ref: '#/components/schemas/DateTime'
  214.         code:
  215.           type: string
  216.           example: sOmEUnIqUeReFeRaLcOdE
  217.         link_to_app:
  218.           type: string
  219.           description: Deeplink. Generate QR code based on this value, so customers are available to navigate to Tezro and get givebacks to their wallet.
  220.           example: https://tezro.app.link/customer-referal-link
  221.         balance:
  222.           $ref: '#/components/schemas/CustomerBalanceDto'
  223.         linked_user_id:
  224.           type: string
  225.           description: Available after authorizing in Tezro app and linking customer account.
  226.           example: 'some-tezro-user-id'
  227.         linked_user_at:
  228.           $ref: '#/components/schemas/DateTime'
  229.  
  230.     CustomerBalanceDto:
  231.       description: |
  232.        Customer's balance info.<br />
  233.         P.s. Tollar - abstract currency in context of current system.<br />
  234.         P.p.s $ equivalents are recalculated by actual rate on time of request.
  235.       type: object
  236.       properties:
  237.         total_earned_tollars:
  238.           description: All time earned funds.
  239.           type: string
  240.           default: '0'
  241.           example: '1000.00'
  242.         total_earned_in_usd:
  243.           description: $ equivalent of all time earned funds.
  244.           type: string
  245.           default: '0'
  246.           example: '10.00'
  247.         today_earned_tollars:
  248.           description: Earned funds since 00:00:00 (UTC) until current time.
  249.           type: string
  250.           default: '0'
  251.           example: '1000.00'
  252.         today_earned_in_usd:
  253.           description: $ equivalent of earned funds since 00:00:00 (UTC) until current time.
  254.           type: string
  255.           default: '0'
  256.           example: '10.00'
  257.  
  258.     # Common error response structure
  259.     ErrorResponseDto:
  260.       description: Common error response payload
  261.       type: object
  262.       required:
  263.        - code
  264.         - message
  265.         - description
  266.       properties:
  267.         code:
  268.           description: HTTP status code
  269.           type: number
  270.           example: 400
  271.         message:
  272.           description: ERROR_CODE
  273.           type: string
  274.           example: FORBIDDEN
  275.         description:
  276.           description: More detailed info
  277.           type: string
  278.           example: Entity not found
  279.  
  280.   # Common responses
  281.   responses:
  282.     201_empty_ok:
  283.       description: Ok, entity created
  284.  
  285.     400_bad_request:
  286.       description: Bad request payload
  287.       content:
  288.         application/json:
  289.           schema:
  290.             $ref: '#/components/schemas/ErrorResponseDto'
  291.  
  292.     401_missing_auth:
  293.       description: Required to provide auth credentials
  294.       content:
  295.         application/json:
  296.           schema:
  297.             $ref: '#/components/schemas/ErrorResponseDto'
  298.  
  299.     403_forbidden:
  300.       description: You are not allowed to perform this request
  301.       content:
  302.         application/json:
  303.           schema:
  304.             $ref: '#/components/schemas/ErrorResponseDto'
  305.  
  306.     404_not_found:
  307.       description: Resource not found
  308.       content:
  309.         application/json:
  310.           schema:
  311.             $ref: '#/components/schemas/ErrorResponseDto'
Tags: tezro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement