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

#create_subscription_group_prepayment(uid, body: nil) ⇒ SubscriptionGroupPrepaymentResponse

A prepayment can be added for a subscription group identified by the group’s ‘uid`. This endpoint requires a `amount`, `details`, `method`, and `memo`. On success, the prepayment will be added to the group’s prepayment balance. group Example:



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

def create_subscription_group_prepayment(uid,
                                         body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/prepayments.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionGroupPrepaymentResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#deduct_subscription_group_service_credits(uid, body: nil) ⇒ ServiceCredit

Credit can be deducted for a subscription group identified by the group’s ‘uid`. Credit will be deducted from the group in the amount specified in the request body. group



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 139

def deduct_subscription_group_service_credits(uid,
                                              body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/service_credit_deductions.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ServiceCredit.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#issue_subscription_group_service_credits(uid, body: nil) ⇒ ServiceCreditResponse

Credit can be issued for a subscription group identified by the group’s ‘uid`. 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



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 108

def issue_subscription_group_service_credits(uid,
                                             body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscription_groups/{uid}/service_credits.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ServiceCreditResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#list_prepayments_for_subscription_group(options = {}) ⇒ ListSubscriptionGroupPrepaymentResponse

This request will list a subscription group’s prepayments. group Optional parameter: The type of filter you would like to apply to your search. Use in query: ‘filter=created_at`. YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query: ‘filter=2011-12-15`. (format YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query: ‘filter=2011-12-15`. 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`.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/advanced_billing/controllers/subscription_group_invoice_account_controller.rb', line 69

def list_prepayments_for_subscription_group(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscription_groups/{uid}/prepayments.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['uid'], key: 'uid')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['filter_date_field'], key: 'filter[date_field]'))
               .query_param(new_parameter(options['filter_end_date'], key: 'filter[end_date]'))
               .query_param(new_parameter(options['filter_start_date'], key: 'filter[start_date]'))
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListSubscriptionGroupPrepaymentResponse.method(:from_hash))
                .local_error('401',
                             'Unauthorized',
                             APIException)
                .local_error('403',
                             'Forbidden',
                             APIException)
                .local_error('404',
                             'Not Found',
                             APIException))
    .execute
end