Class: AdvancedBilling::APIExportsController

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

Overview

APIExportsController

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

#export_invoicesBatchJobResponse

This API creates an invoices export and returns a batchjob object.

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 157

def export_invoices
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/invoices.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(BatchJobResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException)
                .local_error_template('409',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      SingleErrorResponseException))
    .execute
end

#export_proforma_invoicesBatchJobResponse

This API creates a proforma invoices export and returns a batchjob object. It is only available for Relationship Invoicing architecture.

Returns:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 135

def export_proforma_invoices
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/proforma_invoices.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(BatchJobResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException)
                .local_error_template('409',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      SingleErrorResponseException))
    .execute
end

#export_subscriptionsBatchJobResponse

This API creates a subscriptions export and returns a batchjob object.

Returns:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 179

def export_subscriptions
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/subscriptions.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(BatchJobResponse.method(:from_hash))
                .local_error_template('409',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      SingleErrorResponseException))
    .execute
end

#list_exported_invoices(options = {}) ⇒ Array[Invoice]

This API returns an array of exported invoices for a provided ‘batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://subdomain.chargify.com/api_exports/invoices/123/rows?per_page=10 000&page=1`. many records to fetch in each request. Default value is 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000. 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`.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • page (Integer)

    Optional parameter: Result records are organized in

Returns:

  • (Array[Invoice])

    response from the API call.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 69

def list_exported_invoices(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/invoices/{batch_id}/rows.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['batch_id'], key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['page'], key: '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(Invoice.method(:from_hash))
                .is_response_array(true)
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end

#list_exported_proforma_invoices(options = {}) ⇒ Array[ProformaInvoice]

This API returns an array of exported proforma invoices for a provided ‘batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://subdomain.chargify.com/api_exports/proforma_invoices/123/rows?pe r_page=10000&page=1`. many records to fetch in each request. Default value is 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000. 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`.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • page (Integer)

    Optional parameter: Result records are organized in

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 28

def list_exported_proforma_invoices(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/proforma_invoices/{batch_id}/rows.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['batch_id'], key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['page'], key: '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(ProformaInvoice.method(:from_hash))
                .is_response_array(true)
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end

#list_exported_subscriptions(options = {}) ⇒ Array[Subscription]

This API returns an array of exported subscriptions for a provided ‘batch_id`. Pay close attention to pagination in order to control responses from the server. Example: `GET https://subdomain.chargify.com/api_exports/subscriptions/123/rows?per_pa ge=200&page=1`. many records to fetch in each request. Default value is 100. The maximum allowed values is 10000; any per_page value over 10000 will be changed to 10000. 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`.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • page (Integer)

    Optional parameter: Result records are organized in

Returns:



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/api_exports_controller.rb', line 110

def list_exported_subscriptions(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/subscriptions/{batch_id}/rows.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['batch_id'], key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['page'], key: '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(Subscription.method(:from_hash))
                .is_response_array(true)
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end

#read_invoices_export(batch_id) ⇒ BatchJobResponse

This API returns a batchjob object for invoices export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 221

def read_invoices_export(batch_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/invoices/{batch_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(batch_id, key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end

#read_proforma_invoices_export(batch_id) ⇒ BatchJobResponse

This API returns a batchjob object for proforma invoices export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 199

def read_proforma_invoices_export(batch_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/proforma_invoices/{batch_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(batch_id, key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end

#read_subscriptions_export(batch_id) ⇒ BatchJobResponse

This API returns a batchjob object for subscriptions export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 243

def read_subscriptions_export(batch_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/subscriptions/{batch_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(batch_id, key: 'batch_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException))
    .execute
end