Class: AdvancedBilling::SubscriptionGroupInvoiceAccountController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb

Overview

SubscriptionGroupInvoiceAccountController

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

#create_subscription_group_prepayment(uid, body: nil) ⇒ SubscriptionGroupPrepaymentResponse

Adds a prepayment for a subscription group. This endpoint requires an ‘amount`, `details`, `method`, and `memo`. On success, the prepayment will be added to the group’s prepayment balance. group type description here

Parameters:

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 17

def create_subscription_group_prepayment(uid,
                                         body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/prepayments.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(uid, key: 'uid')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionGroupPrepaymentResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#deduct_subscription_group_service_credit(uid, body: nil) ⇒ ServiceCredit

Deducts service credit for a subscription group. Credit will be deducted from the group in the amount specified in the request body. group description here

Parameters:

  • uid (String)

    Required parameter: The uid of the subscription

  • body (DeductServiceCreditRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 120

def deduct_subscription_group_service_credit(uid,
                                             body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/service_credit_deductions.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(uid, key: 'uid')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ServiceCredit.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#issue_subscription_group_service_credit(uid, body: nil) ⇒ ServiceCreditResponse

Issues service credit for a subscription group. Credit will be added to the group in the amount specified in the request body. The credit will be applied to group member invoices as they are generated. group description here

Parameters:

  • uid (String)

    Required parameter: The uid of the subscription

  • body (IssueServiceCreditRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 89

def issue_subscription_group_service_credit(uid,
                                            body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/service_credits.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(uid, key: 'uid')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ServiceCreditResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#list_prepayments_for_subscription_group(options = {}) ⇒ ListSubscriptionGroupPrepaymentResponse

Lists a subscription group’s prepayments. group 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`. for List Prepayments operations

Parameters:

  • uid (String)

    Required parameter: The uid of the subscription

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter (ListPrepaymentsFilter)

    Optional parameter: Filter to use

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 58

def list_prepayments_for_subscription_group(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscription_groups/{uid}/prepayments.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['uid'], key: 'uid')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['filter'], key: 'filter'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSubscriptionGroupPrepaymentResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end