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

Creates an invoices export and returns a batch job object.

Returns:



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

def export_invoices
  @api_call
    .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

Creates a proforma invoices export and returns a batch job object. It is only available for Relationship Invoicing architecture.

Returns:



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

def export_proforma_invoices
  @api_call
    .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

Creates a subscriptions export and returns a batch job object.

Returns:



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

def export_subscriptions
  @api_call
    .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]

Lists exported invoices for a provided ‘batch_id`. Use pagination to control responses returned 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.



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

def list_exported_invoices(options = {})
  @api_call
    .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]

Lists exported proforma invoices for a provided ‘batch_id`. Use pagination to control responses returned 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:



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

def list_exported_proforma_invoices(options = {})
  @api_call
    .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]

Lists exported subscriptions for a provided ‘batch_id`. Use pagination to control responses returned 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:



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

def list_exported_subscriptions(options = {})
  @api_call
    .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

Returns a batch job object for an invoices export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



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

def read_invoices_export(batch_id)
  @api_call
    .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

Returns a batch job object for a proforma invoices export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



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

def read_proforma_invoices_export(batch_id)
  @api_call
    .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

Returns a batch job object for a subscriptions export.

Parameters:

  • batch_id (String)

    Required parameter: Id of a Batch Job.

Returns:



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

def read_subscriptions_export(batch_id)
  @api_call
    .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