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:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 11

def export_invoices
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/invoices.json',
                                 Server::DEFAULT)
               .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(BatchJobResponse.method(:from_hash))
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             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:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 206

def export_proforma_invoices
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/proforma_invoices.json',
                                 Server::DEFAULT)
               .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(BatchJobResponse.method(:from_hash))
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             SingleErrorResponseException))
    .execute
end

#export_subscriptionsBatchJobResponse

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

Returns:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 251

def export_subscriptions
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api_exports/subscriptions.json',
                                 Server::DEFAULT)
               .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(BatchJobResponse.method(:from_hash))
                .local_error('409',
                             'Conflict',
                             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.



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 180

def list_exported_invoices(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/invoices/{batch_id}/rows.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Invoice.method(:from_hash))
                .is_response_array(true)
                .local_error('404',
                             'Not Found',
                             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:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 50

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::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProformaInvoice.method(:from_hash))
                .is_response_array(true)
                .local_error('404',
                             'Not Found',
                             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:



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

def list_exported_subscriptions(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/subscriptions/{batch_id}/rows.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_response_array(true)
                .local_error('404',
                             'Not Found',
                             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:



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 229

def read_invoices_export(batch_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/invoices/{batch_id}.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error('404',
                             'Not Found',
                             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:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 76

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::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error('404',
                             'Not Found',
                             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:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/advanced_billing/controllers/api_exports_controller.rb', line 99

def read_subscriptions_export(batch_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api_exports/subscriptions/{batch_id}.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BatchJobResponse.method(:from_hash))
                .local_error('404',
                             'Not Found',
                             APIException))
    .execute
end