openapi: 3.0.0
info:
  title: Referrals
  description: Everything about viewing referred accounts.
servers:
  - url: https://rest.clicksend.com
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
  schemas:
    pagination:
      type: object
      properties:
        total:
          type: integer
          description: The total number of items available for viewing.
          example: 2
        per_page:
          type: integer
          description: >-
            The number of items returned per page. This is specified in the
            limit parameter. You can have 100 items at maximum, and 15 at
            minimum.
          example: 15
        current_page:
          type: integer
          description: The current page number.
          example: 1
        last_page:
          type: integer
          description: The last page number.
          example: 1
        next_page_url:
          type: string
          nullable: true
          description: >-
            A URL of the next page. It will return **null** if there’s no next
            page.
          example: null
        prev_page_url:
          type: string
          nullable: true
          description: >-
            A URL of the previous page. It will return **null** if there’s no
            previous page.
          example: null
        from:
          type: integer
          description: The number of the first result in the current page.
          example: 1
        to:
          type: integer
          description: The number of the last result in the current page.
          example: 2
    view-referral-accounts:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here are your referrals.
        data:
          allOf:
            - $ref: '#/components/schemas/pagination'
            - type: object
              properties:
                data:
                  type: array
                  items:
                    type: object
                    properties:
                      referral_rule_id:
                        type: integer
                        description: The ID of the Referral Account.
                      refered_user_id:
                        type: integer
                        description: The ID of the Referral Account.
                      date_referred:
                        type: number
                        description: The ID of the Referral Account.
                        example: 1438260940
                      percentage_referral:
                        type: number
                        description: The Percentage of the Referral.
                        example: 5
                  example:
                    - referral_rule_id: 1
                      refered_user_id: 24
                      date_referred: 1438260940
                      percentage_referral: 5
                    - referral_rule_id: 2
                      refered_user_id: 25
                      date_referred: 1438260989
                      percentage_referral: 5
paths:
  /v3/referral/accounts/:
    get:
      summary: View Referral Accounts
      operationId: view-referral-accounts
      description: >-
        _Get all referral accounts_


        ### Parameters


        | Parameter | In | Type | Required | Description |

        | --- | --- | --- | --- | --- |

        | page | query | integer(int32) | false | [Page number](/#pagination) |

        | limit | query | integer(int32) | false | [Number of records per
        page](/#pagination) |



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-referral-accounts'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/referral/accounts'
        - lang: PHP
          source: >-
            <?php

            require_once(__DIR__ . '/vendor/autoload.php');


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\ReferralAccountApi(new
            GuzzleHttp\Client(),$config);

            $page = 1; // int | Page number

            $limit = 10; // int | Number of records per page


            try {
                $result = $apiInstance->referralAccountsGet($page, $limit);
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling ReferralAccountApi->referralAccountsGet: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var referralAccountApi = new ReferralAccountApi(configuration);
            var response = referralAccountApi.ReferralAccountsGet();
        - lang: Java
          source: |-
            package ClickSend;

            import ClickSend.Api.ReferralAccountApi;

            public class view_referral_account {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                ReferralAccountApi apiInstance = new ReferralAccountApi(defaultClient);
                Integer page = 1; // Integer | Page number
                Integer limit = 10; // Integer | Number of records per page
                try {
                    String result = apiInstance.referralAccountsGet(page, limit);
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling ReferralAccountApi#referralAccountsGet");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: >-
            var api = require('./api.js');


            var referralApi = new api.ReferralAccountApi("USERNAME", "API_KEY");


            var page = 1;

            var limit = 10;


            referralApi.referralAccountsGet(page, limit).then(function(response)
            {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::ReferralAccountApi.new

            opts = {
              page: 1,  # Integer | Page number
              limit: 10 # Integer | Number of records per page
            }

            begin
              # Get all referral accounts
              result = api_instance.referral_accounts_get(opts)
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling ReferralAccountApi->referral_accounts_get: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.ReferralAccountApi(clicksend_client.ApiClient(configuration))

            page = 1 # int | Page number (optional) (default to 1)

            limit = 10 # int | Number of records per page (optional) (default to
            10)


            try:
                # Get all referral accounts
                api_response = api_instance.referral_accounts_get(page=page, limit=limit)
                print(api_response)
            except ApiException as e:
                print("Exception when calling ReferralAccountApi->referral_accounts_get: %s\n" % e)
        - lang: perl
          source: >-
            use  WWW::ClickSendClient::ReferralAccountApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::ReferralAccountApi->new(username =>
            $username, password => $password);


            my $json_output = $api->referral_accounts_get('page' => '1' ,'limit'
            => '10');


            print $json_output;
        - lang: objc
          source: >-
            #import "CSReferralAccountApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            NSNumber *page = [[NSNumber alloc] initWithInt:1];

            NSNumber *limit = [[NSNumber alloc] initWithInt:15];


            CSReferralAccountApi *referralAccountApiInstance =
            [[CSReferralAccountApi alloc] init];

            [referralAccountApiInstance referralAccountsGetWithPage:page
            limit:limit completionHandler:^(NSString *output, NSError *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }


            ReferralAccountAPI.referralAccountsGet(page: 1, limit: 15) {
            (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
