Class: AdvancedBilling::SalesCommissionsController

Inherits:
BaseController show all
Defined in:
lib/advanced_billing/controllers/sales_commissions_controller.rb

Overview

SalesCommissionsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from AdvancedBilling::BaseController

Instance Method Details

#list_sales_commission_settings(options = {}) ⇒ Array[SaleRepSettings]

Endpoint returns subscriptions with associated sales reps ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. > Note: The request is at seller level, it means ‘<<subdomain>>` variable will be replaced by `app` seller account user API key. See details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). parameter indicates if records should be fetched from live mode sites. Default value is true. pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 100.

Parameters:

  • seller_id (String)

    Required parameter: The Chargify id of your

  • authorization (String)

    Optional parameter: For authorization use

  • live_mode (TrueClass | FalseClass)

    Optional parameter: This

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/advanced_billing/controllers/sales_commissions_controller.rb', line 45

def list_sales_commission_settings(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/sellers/{seller_id}/sales_commission_settings.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['seller_id'], key: 'seller_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(options['authorization'], key: 'Authorization'))
               .query_param(new_parameter(options['live_mode'], key: 'live_mode'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SaleRepSettings.method(:from_hash))
                .is_response_array(true))
    .execute
end

#list_sales_reps(options = {}) ⇒ Array[ListSaleRepItem]

Endpoint returns sales rep list with details ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. > Note: The request is at seller level, it means ‘<<subdomain>>` variable will be replaced by `app` seller account user API key. See details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). parameter indicates if records should be fetched from live mode sites. Default value is true. pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 100.

Parameters:

  • seller_id (String)

    Required parameter: The Chargify id of your

  • authorization (String)

    Optional parameter: For authorization use

  • live_mode (TrueClass | FalseClass)

    Optional parameter: This

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/advanced_billing/controllers/sales_commissions_controller.rb', line 102

def list_sales_reps(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/sellers/{seller_id}/sales_reps.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['seller_id'], key: 'seller_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(options['authorization'], key: 'Authorization'))
               .query_param(new_parameter(options['live_mode'], key: 'live_mode'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSaleRepItem.method(:from_hash))
                .is_response_array(true))
    .execute
end

#read_sales_rep(seller_id, sales_rep_id, authorization: 'Bearer <<apiKey>>', live_mode: nil, page: 1, per_page: 100) ⇒ SaleRep

Endpoint returns sales rep and attached subscriptions details. ## Modified Authentication Process The Sales Commission API differs from other Chargify API endpoints. This resource is associated with the seller itself. Up to now all available resources were at the level of the site, therefore creating the API Key per site was a sufficient solution. To share resources at the seller level, a new authentication method was introduced, which is user authentication. Creating an API Key for a user is a required step to correctly use the Sales Commission API, more details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). Access to the Sales Commission API endpoints is available to users with financial access, where the seller has the Advanced Analytics component enabled. For further information on getting access to Advanced Analytics please contact Maxio support. > Note: The request is at seller level, it means ‘<<subdomain>>` variable will be replaced by `app` seller account of sales rep. user API key. See details [here](developers.chargify.com/docs/developer-docs/ZG9jOjMyNzk5NTg 0-2020-04-20-new-api-authentication). parameter indicates if records should be fetched from live mode sites. Default value is true. pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 100.

Parameters:

  • seller_id (String)

    Required parameter: The Chargify id of your

  • sales_rep_id (String)

    Required parameter: The Advanced Billing id

  • authorization (String) (defaults to: 'Bearer <<apiKey>>')

    Optional parameter: For authorization use

  • live_mode (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: This

  • page (Integer) (defaults to: 1)

    Optional parameter: Result records are organized in

  • per_page (Integer) (defaults to: 100)

    Optional parameter: This parameter indicates how

Returns:

  • (SaleRep)

    response from the API call.



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/advanced_billing/controllers/sales_commissions_controller.rb', line 161

def read_sales_rep(seller_id,
                   sales_rep_id,
                   authorization: 'Bearer <<apiKey>>',
                   live_mode: nil,
                   page: 1,
                   per_page: 100)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/sellers/{seller_id}/sales_reps/{sales_rep_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(seller_id, key: 'seller_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(sales_rep_id, key: 'sales_rep_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(authorization, key: 'Authorization'))
               .query_param(new_parameter(live_mode, key: 'live_mode'))
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(per_page, key: 'per_page'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SaleRep.method(:from_hash)))
    .execute
end