Class: AdvancedBilling::SitesController

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

Overview

SitesController

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_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

#clear_site(cleanup_scope: CleanupScope::ALL) ⇒ void

This method returns an undefined value.

Clears all data from a test site asynchronously. This call is asynchronous and there may be a delay before the site data is fully deleted. If you are clearing site data for an automated test, you will need to build in a delay and/or check that there are no products, etc., in the site before proceeding. This functionality will only work on sites in TEST mode. Attempts to perform this on sites in “live” mode will result in a response of 403 FORBIDDEN. all products, customers, and related subscriptions from the site. customers: Will clear only customers and related subscriptions (leaving the products untouched) for the site. Revenue will also be reset to 0. Use in query cleanup_scope=all.

Parameters:

  • cleanup_scope (CleanupScope) (defaults to: CleanupScope::ALL)

    Optional parameter: all: Will clear



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/advanced_billing/controllers/sites_controller.rb', line 54

def clear_site(cleanup_scope: CleanupScope::ALL)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/sites/clear_data.json',
                                 Server::PRODUCTION)
               .query_param(new_parameter(cleanup_scope, key: 'cleanup_scope'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_chargify_js_public_keys(options = {}) ⇒ ListPublicKeysResponse

Lists public keys used for Maxio.js (formerly Chargify.js). 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 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query per_page=200.

Parameters:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/advanced_billing/controllers/sites_controller.rb', line 79

def list_chargify_js_public_keys(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/chargify_js_keys.json',
                                 Server::PRODUCTION)
               .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(ListPublicKeysResponse.method(:from_hash)))
    .execute
end

#read_siteSiteResponse

Retrieves site data. For more information, see Sites in the product documentation. Specifically, the [Clearing Site Data](https://maxio.zendesk.com/hc/en-us/articles/24250617028365-Clearing- Site-Data) section is relevant to this endpoint.

Relationship invoicing enabled

If the site has Relationship invoicing enabled, additional properties are returned in the response:

"customer_hierarchy_enabled": true,
"whopays_enabled": true,
"whopays_default_payer": "self"

For more information, see [Who Pays & Customer Hierarchy](https://maxio.zendesk.com/hc/en-us/articles/24252185211533-Cust omer-Hierarchies-WhoPays).

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/controllers/sites_controller.rb', line 27

def read_site
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/site.json',
                                 Server::PRODUCTION)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SiteResponse.method(:from_hash)))
    .execute
end