ultracart_api 4.1.105 → 4.1.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,460 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module UltracartClient
16
+ class BulkApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+
23
+ def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false)
24
+ api_config = Configuration.new
25
+ api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key
26
+ api_config.api_version = '2017-03-01'
27
+ api_config.verify_ssl = verify_ssl
28
+
29
+ api_client = ApiClient.new(api_config)
30
+ api_client.config.debugging = debugging
31
+
32
+ UltracartClient::BulkApi.new(api_client)
33
+ end
34
+
35
+ # Request cancellation of a bulk job
36
+ # Queued jobs cancel immediately (200). In-progress jobs finalize as cancelled between records (202); already-processed records stand.
37
+ # @param object [String] Object type
38
+ # @param job_id [String] The bulk job id
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [nil]
41
+ def bulk_cancel_job(object, job_id, opts = {})
42
+ bulk_cancel_job_with_http_info(object, job_id, opts)
43
+ nil
44
+ end
45
+
46
+ # Request cancellation of a bulk job
47
+ # Queued jobs cancel immediately (200). In-progress jobs finalize as cancelled between records (202); already-processed records stand.
48
+ # @param object [String] Object type
49
+ # @param job_id [String] The bulk job id
50
+ # @param [Hash] opts the optional parameters
51
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
52
+ def bulk_cancel_job_with_http_info(object, job_id, opts = {})
53
+ if @api_client.config.debugging
54
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_cancel_job ...'
55
+ end
56
+ # verify the required parameter 'object' is set
57
+ if @api_client.config.client_side_validation && object.nil?
58
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_cancel_job"
59
+ end
60
+ # verify the required parameter 'job_id' is set
61
+ if @api_client.config.client_side_validation && job_id.nil?
62
+ fail ArgumentError, "Missing the required parameter 'job_id' when calling BulkApi.bulk_cancel_job"
63
+ end
64
+ # resource path
65
+ local_var_path = '/bulk/{object}/{job_id}'.sub('{' + 'object' + '}', CGI.escape(object.to_s)).sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
66
+
67
+ # query parameters
68
+ query_params = opts[:query_params] || {}
69
+
70
+ # header parameters
71
+ header_params = opts[:header_params] || {}
72
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
73
+ # HTTP header 'Accept' (if needed)
74
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
75
+
76
+ # form parameters
77
+ form_params = opts[:form_params] || {}
78
+
79
+ # http body (model)
80
+ post_body = opts[:debug_body]
81
+
82
+ # return_type
83
+ return_type = opts[:debug_return_type]
84
+
85
+ # auth_names
86
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
87
+
88
+ new_options = opts.merge(
89
+ :operation => :"BulkApi.bulk_cancel_job",
90
+ :header_params => header_params,
91
+ :query_params => query_params,
92
+ :form_params => form_params,
93
+ :body => post_body,
94
+ :auth_names => auth_names,
95
+ :return_type => return_type
96
+ )
97
+
98
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
99
+ if @api_client.config.debugging
100
+ @api_client.config.logger.debug "API called: BulkApi#bulk_cancel_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
101
+ end
102
+ return data, status_code, headers
103
+ end
104
+
105
+ # Generate a presigned upload URL for a bulk payload
106
+ # Returns a presigned S3 PUT URL the merchant uploads NDJSON to, plus the s3_key to pass to submit.
107
+ # @param object [String] Object type
108
+ # @param [Hash] opts the optional parameters
109
+ # @return [BulkUploadUrlResponse]
110
+ def bulk_generate_upload_url(object, opts = {})
111
+ data, _status_code, _headers = bulk_generate_upload_url_with_http_info(object, opts)
112
+ data
113
+ end
114
+
115
+ # Generate a presigned upload URL for a bulk payload
116
+ # Returns a presigned S3 PUT URL the merchant uploads NDJSON to, plus the s3_key to pass to submit.
117
+ # @param object [String] Object type
118
+ # @param [Hash] opts the optional parameters
119
+ # @return [Array<(BulkUploadUrlResponse, Integer, Hash)>] BulkUploadUrlResponse data, response status code and response headers
120
+ def bulk_generate_upload_url_with_http_info(object, opts = {})
121
+ if @api_client.config.debugging
122
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_generate_upload_url ...'
123
+ end
124
+ # verify the required parameter 'object' is set
125
+ if @api_client.config.client_side_validation && object.nil?
126
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_generate_upload_url"
127
+ end
128
+ # resource path
129
+ local_var_path = '/bulk/{object}/upload-url'.sub('{' + 'object' + '}', CGI.escape(object.to_s))
130
+
131
+ # query parameters
132
+ query_params = opts[:query_params] || {}
133
+
134
+ # header parameters
135
+ header_params = opts[:header_params] || {}
136
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
137
+ # HTTP header 'Accept' (if needed)
138
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
139
+
140
+ # form parameters
141
+ form_params = opts[:form_params] || {}
142
+
143
+ # http body (model)
144
+ post_body = opts[:debug_body]
145
+
146
+ # return_type
147
+ return_type = opts[:debug_return_type] || 'BulkUploadUrlResponse'
148
+
149
+ # auth_names
150
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
151
+
152
+ new_options = opts.merge(
153
+ :operation => :"BulkApi.bulk_generate_upload_url",
154
+ :header_params => header_params,
155
+ :query_params => query_params,
156
+ :form_params => form_params,
157
+ :body => post_body,
158
+ :auth_names => auth_names,
159
+ :return_type => return_type
160
+ )
161
+
162
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
163
+ if @api_client.config.debugging
164
+ @api_client.config.logger.debug "API called: BulkApi#bulk_generate_upload_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
165
+ end
166
+ return data, status_code, headers
167
+ end
168
+
169
+ # Retrieve a bulk job's status and counts
170
+ # @param object [String] Object type
171
+ # @param job_id [String] The bulk job id
172
+ # @param [Hash] opts the optional parameters
173
+ # @return [BulkJobResponse]
174
+ def bulk_get_job(object, job_id, opts = {})
175
+ data, _status_code, _headers = bulk_get_job_with_http_info(object, job_id, opts)
176
+ data
177
+ end
178
+
179
+ # Retrieve a bulk job&#39;s status and counts
180
+ # @param object [String] Object type
181
+ # @param job_id [String] The bulk job id
182
+ # @param [Hash] opts the optional parameters
183
+ # @return [Array<(BulkJobResponse, Integer, Hash)>] BulkJobResponse data, response status code and response headers
184
+ def bulk_get_job_with_http_info(object, job_id, opts = {})
185
+ if @api_client.config.debugging
186
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_get_job ...'
187
+ end
188
+ # verify the required parameter 'object' is set
189
+ if @api_client.config.client_side_validation && object.nil?
190
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_get_job"
191
+ end
192
+ # verify the required parameter 'job_id' is set
193
+ if @api_client.config.client_side_validation && job_id.nil?
194
+ fail ArgumentError, "Missing the required parameter 'job_id' when calling BulkApi.bulk_get_job"
195
+ end
196
+ # resource path
197
+ local_var_path = '/bulk/{object}/{job_id}'.sub('{' + 'object' + '}', CGI.escape(object.to_s)).sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
198
+
199
+ # query parameters
200
+ query_params = opts[:query_params] || {}
201
+
202
+ # header parameters
203
+ header_params = opts[:header_params] || {}
204
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
205
+ # HTTP header 'Accept' (if needed)
206
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
207
+
208
+ # form parameters
209
+ form_params = opts[:form_params] || {}
210
+
211
+ # http body (model)
212
+ post_body = opts[:debug_body]
213
+
214
+ # return_type
215
+ return_type = opts[:debug_return_type] || 'BulkJobResponse'
216
+
217
+ # auth_names
218
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
219
+
220
+ new_options = opts.merge(
221
+ :operation => :"BulkApi.bulk_get_job",
222
+ :header_params => header_params,
223
+ :query_params => query_params,
224
+ :form_params => form_params,
225
+ :body => post_body,
226
+ :auth_names => auth_names,
227
+ :return_type => return_type
228
+ )
229
+
230
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
231
+ if @api_client.config.debugging
232
+ @api_client.config.logger.debug "API called: BulkApi#bulk_get_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
233
+ end
234
+ return data, status_code, headers
235
+ end
236
+
237
+ # Paginate a bulk job's per-record results
238
+ # @param object [String] Object type
239
+ # @param job_id [String] The bulk job id
240
+ # @param [Hash] opts the optional parameters
241
+ # @option opts [String] :status Filter by per-record result status (success, failed, duplicate)
242
+ # @option opts [String] :cursor Opaque pagination cursor
243
+ # @option opts [Integer] :limit Page size (default 100, max 1000)
244
+ # @return [BulkRecordsResponse]
245
+ def bulk_get_job_records(object, job_id, opts = {})
246
+ data, _status_code, _headers = bulk_get_job_records_with_http_info(object, job_id, opts)
247
+ data
248
+ end
249
+
250
+ # Paginate a bulk job&#39;s per-record results
251
+ # @param object [String] Object type
252
+ # @param job_id [String] The bulk job id
253
+ # @param [Hash] opts the optional parameters
254
+ # @option opts [String] :status Filter by per-record result status (success, failed, duplicate)
255
+ # @option opts [String] :cursor Opaque pagination cursor
256
+ # @option opts [Integer] :limit Page size (default 100, max 1000)
257
+ # @return [Array<(BulkRecordsResponse, Integer, Hash)>] BulkRecordsResponse data, response status code and response headers
258
+ def bulk_get_job_records_with_http_info(object, job_id, opts = {})
259
+ if @api_client.config.debugging
260
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_get_job_records ...'
261
+ end
262
+ # verify the required parameter 'object' is set
263
+ if @api_client.config.client_side_validation && object.nil?
264
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_get_job_records"
265
+ end
266
+ # verify the required parameter 'job_id' is set
267
+ if @api_client.config.client_side_validation && job_id.nil?
268
+ fail ArgumentError, "Missing the required parameter 'job_id' when calling BulkApi.bulk_get_job_records"
269
+ end
270
+ # resource path
271
+ local_var_path = '/bulk/{object}/{job_id}/records'.sub('{' + 'object' + '}', CGI.escape(object.to_s)).sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))
272
+
273
+ # query parameters
274
+ query_params = opts[:query_params] || {}
275
+ query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
276
+ query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
277
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
278
+
279
+ # header parameters
280
+ header_params = opts[:header_params] || {}
281
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
282
+ # HTTP header 'Accept' (if needed)
283
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
284
+
285
+ # form parameters
286
+ form_params = opts[:form_params] || {}
287
+
288
+ # http body (model)
289
+ post_body = opts[:debug_body]
290
+
291
+ # return_type
292
+ return_type = opts[:debug_return_type] || 'BulkRecordsResponse'
293
+
294
+ # auth_names
295
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
296
+
297
+ new_options = opts.merge(
298
+ :operation => :"BulkApi.bulk_get_job_records",
299
+ :header_params => header_params,
300
+ :query_params => query_params,
301
+ :form_params => form_params,
302
+ :body => post_body,
303
+ :auth_names => auth_names,
304
+ :return_type => return_type
305
+ )
306
+
307
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
308
+ if @api_client.config.debugging
309
+ @api_client.config.logger.debug "API called: BulkApi#bulk_get_job_records\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
310
+ end
311
+ return data, status_code, headers
312
+ end
313
+
314
+ # List bulk jobs for the calling merchant
315
+ # @param object [String] Object type
316
+ # @param [Hash] opts the optional parameters
317
+ # @option opts [String] :status Filter by job status
318
+ # @option opts [String] :cursor Opaque pagination cursor
319
+ # @option opts [Integer] :limit Page size (default 100, max 1000)
320
+ # @return [BulkJobsResponse]
321
+ def bulk_list_jobs(object, opts = {})
322
+ data, _status_code, _headers = bulk_list_jobs_with_http_info(object, opts)
323
+ data
324
+ end
325
+
326
+ # List bulk jobs for the calling merchant
327
+ # @param object [String] Object type
328
+ # @param [Hash] opts the optional parameters
329
+ # @option opts [String] :status Filter by job status
330
+ # @option opts [String] :cursor Opaque pagination cursor
331
+ # @option opts [Integer] :limit Page size (default 100, max 1000)
332
+ # @return [Array<(BulkJobsResponse, Integer, Hash)>] BulkJobsResponse data, response status code and response headers
333
+ def bulk_list_jobs_with_http_info(object, opts = {})
334
+ if @api_client.config.debugging
335
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_list_jobs ...'
336
+ end
337
+ # verify the required parameter 'object' is set
338
+ if @api_client.config.client_side_validation && object.nil?
339
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_list_jobs"
340
+ end
341
+ # resource path
342
+ local_var_path = '/bulk/{object}'.sub('{' + 'object' + '}', CGI.escape(object.to_s))
343
+
344
+ # query parameters
345
+ query_params = opts[:query_params] || {}
346
+ query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
347
+ query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
348
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
349
+
350
+ # header parameters
351
+ header_params = opts[:header_params] || {}
352
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
353
+ # HTTP header 'Accept' (if needed)
354
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
355
+
356
+ # form parameters
357
+ form_params = opts[:form_params] || {}
358
+
359
+ # http body (model)
360
+ post_body = opts[:debug_body]
361
+
362
+ # return_type
363
+ return_type = opts[:debug_return_type] || 'BulkJobsResponse'
364
+
365
+ # auth_names
366
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
367
+
368
+ new_options = opts.merge(
369
+ :operation => :"BulkApi.bulk_list_jobs",
370
+ :header_params => header_params,
371
+ :query_params => query_params,
372
+ :form_params => form_params,
373
+ :body => post_body,
374
+ :auth_names => auth_names,
375
+ :return_type => return_type
376
+ )
377
+
378
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
379
+ if @api_client.config.debugging
380
+ @api_client.config.logger.debug "API called: BulkApi#bulk_list_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
381
+ end
382
+ return data, status_code, headers
383
+ end
384
+
385
+ # Submit a bulk job
386
+ # Submits a job referencing a previously uploaded NDJSON object. One active job per merchant; additional submissions queue. The bulk surface is write-only (insert / upsert); it has no bulk read or export operation.
387
+ # @param object [String] Object type
388
+ # @param bulk_job [BulkJobRequest] Bulk job submission
389
+ # @param [Hash] opts the optional parameters
390
+ # @return [BulkJobResponse]
391
+ def bulk_submit_job(object, bulk_job, opts = {})
392
+ data, _status_code, _headers = bulk_submit_job_with_http_info(object, bulk_job, opts)
393
+ data
394
+ end
395
+
396
+ # Submit a bulk job
397
+ # Submits a job referencing a previously uploaded NDJSON object. One active job per merchant; additional submissions queue. The bulk surface is write-only (insert / upsert); it has no bulk read or export operation.
398
+ # @param object [String] Object type
399
+ # @param bulk_job [BulkJobRequest] Bulk job submission
400
+ # @param [Hash] opts the optional parameters
401
+ # @return [Array<(BulkJobResponse, Integer, Hash)>] BulkJobResponse data, response status code and response headers
402
+ def bulk_submit_job_with_http_info(object, bulk_job, opts = {})
403
+ if @api_client.config.debugging
404
+ @api_client.config.logger.debug 'Calling API: BulkApi.bulk_submit_job ...'
405
+ end
406
+ # verify the required parameter 'object' is set
407
+ if @api_client.config.client_side_validation && object.nil?
408
+ fail ArgumentError, "Missing the required parameter 'object' when calling BulkApi.bulk_submit_job"
409
+ end
410
+ # verify the required parameter 'bulk_job' is set
411
+ if @api_client.config.client_side_validation && bulk_job.nil?
412
+ fail ArgumentError, "Missing the required parameter 'bulk_job' when calling BulkApi.bulk_submit_job"
413
+ end
414
+ # resource path
415
+ local_var_path = '/bulk/{object}'.sub('{' + 'object' + '}', CGI.escape(object.to_s))
416
+
417
+ # query parameters
418
+ query_params = opts[:query_params] || {}
419
+
420
+ # header parameters
421
+ header_params = opts[:header_params] || {}
422
+ header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
423
+ # HTTP header 'Accept' (if needed)
424
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
425
+ # HTTP header 'Content-Type'
426
+ content_type = @api_client.select_header_content_type(['application/json; charset=UTF-8'])
427
+ if !content_type.nil?
428
+ header_params['Content-Type'] = content_type
429
+ end
430
+
431
+ # form parameters
432
+ form_params = opts[:form_params] || {}
433
+
434
+ # http body (model)
435
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(bulk_job)
436
+
437
+ # return_type
438
+ return_type = opts[:debug_return_type] || 'BulkJobResponse'
439
+
440
+ # auth_names
441
+ auth_names = opts[:debug_auth_names] || ['ultraCartOauth', 'ultraCartSimpleApiKey']
442
+
443
+ new_options = opts.merge(
444
+ :operation => :"BulkApi.bulk_submit_job",
445
+ :header_params => header_params,
446
+ :query_params => query_params,
447
+ :form_params => form_params,
448
+ :body => post_body,
449
+ :auth_names => auth_names,
450
+ :return_type => return_type
451
+ )
452
+
453
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
454
+ if @api_client.config.debugging
455
+ @api_client.config.logger.debug "API called: BulkApi#bulk_submit_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
456
+ end
457
+ return data, status_code, headers
458
+ end
459
+ end
460
+ end