processout 2.20.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +52 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Dockerfile +7 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/Makefile +4 -0
  9. data/README.md +12 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/processout/activity.rb +206 -0
  14. data/lib/processout/addon.rb +401 -0
  15. data/lib/processout/alternative_merchant_certificate.rb +115 -0
  16. data/lib/processout/api_request.rb +295 -0
  17. data/lib/processout/api_version.rb +92 -0
  18. data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
  19. data/lib/processout/balance.rb +92 -0
  20. data/lib/processout/balances.rb +111 -0
  21. data/lib/processout/card.rb +503 -0
  22. data/lib/processout/card_information.rb +164 -0
  23. data/lib/processout/coupon.rb +352 -0
  24. data/lib/processout/customer.rb +755 -0
  25. data/lib/processout/customer_action.rb +81 -0
  26. data/lib/processout/discount.rb +360 -0
  27. data/lib/processout/dunning_action.rb +81 -0
  28. data/lib/processout/errors/authentication_error.rb +9 -0
  29. data/lib/processout/errors/generic_error.rb +9 -0
  30. data/lib/processout/errors/internal_error.rb +9 -0
  31. data/lib/processout/errors/notfound_error.rb +9 -0
  32. data/lib/processout/errors/validation_error.rb +9 -0
  33. data/lib/processout/event.rb +237 -0
  34. data/lib/processout/gateway.rb +210 -0
  35. data/lib/processout/gateway_configuration.rb +346 -0
  36. data/lib/processout/gateway_request.rb +26 -0
  37. data/lib/processout/invoice.rb +984 -0
  38. data/lib/processout/invoice_detail.rb +235 -0
  39. data/lib/processout/invoice_device.rb +92 -0
  40. data/lib/processout/invoice_external_fraud_tools.rb +70 -0
  41. data/lib/processout/invoice_risk.rb +81 -0
  42. data/lib/processout/invoice_shipping.rb +202 -0
  43. data/lib/processout/invoice_tax.rb +81 -0
  44. data/lib/processout/networking/request.rb +102 -0
  45. data/lib/processout/networking/response.rb +67 -0
  46. data/lib/processout/payment_data_network_authentication.rb +70 -0
  47. data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
  48. data/lib/processout/payment_data_three_ds_request.rb +103 -0
  49. data/lib/processout/payout.rb +379 -0
  50. data/lib/processout/payout_item.rb +238 -0
  51. data/lib/processout/plan.rb +368 -0
  52. data/lib/processout/product.rb +368 -0
  53. data/lib/processout/project.rb +353 -0
  54. data/lib/processout/refund.rb +277 -0
  55. data/lib/processout/subscription.rb +910 -0
  56. data/lib/processout/three_ds.rb +158 -0
  57. data/lib/processout/token.rb +493 -0
  58. data/lib/processout/transaction.rb +905 -0
  59. data/lib/processout/transaction_operation.rb +418 -0
  60. data/lib/processout/version.rb +3 -0
  61. data/lib/processout/webhook.rb +237 -0
  62. data/lib/processout/webhook_endpoint.rb +149 -0
  63. data/lib/processout.rb +263 -0
  64. data/processout.gemspec +26 -0
  65. metadata +66 -3
@@ -0,0 +1,368 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "json"
5
+ require "processout/networking/request"
6
+ require "processout/networking/response"
7
+
8
+ module ProcessOut
9
+ class Plan
10
+
11
+ attr_reader :id
12
+ attr_reader :project
13
+ attr_reader :project_id
14
+ attr_reader :url
15
+ attr_reader :name
16
+ attr_reader :amount
17
+ attr_reader :currency
18
+ attr_reader :metadata
19
+ attr_reader :interval
20
+ attr_reader :trial_period
21
+ attr_reader :return_url
22
+ attr_reader :cancel_url
23
+ attr_reader :sandbox
24
+ attr_reader :created_at
25
+
26
+
27
+ def id=(val)
28
+ @id = val
29
+ end
30
+
31
+ def project=(val)
32
+ if val.nil?
33
+ @project = val
34
+ return
35
+ end
36
+
37
+ if val.instance_of? Project
38
+ @project = val
39
+ else
40
+ obj = Project.new(@client)
41
+ obj.fill_with_data(val)
42
+ @project = obj
43
+ end
44
+
45
+ end
46
+
47
+ def project_id=(val)
48
+ @project_id = val
49
+ end
50
+
51
+ def url=(val)
52
+ @url = val
53
+ end
54
+
55
+ def name=(val)
56
+ @name = val
57
+ end
58
+
59
+ def amount=(val)
60
+ @amount = val
61
+ end
62
+
63
+ def currency=(val)
64
+ @currency = val
65
+ end
66
+
67
+ def metadata=(val)
68
+ @metadata = val
69
+ end
70
+
71
+ def interval=(val)
72
+ @interval = val
73
+ end
74
+
75
+ def trial_period=(val)
76
+ @trial_period = val
77
+ end
78
+
79
+ def return_url=(val)
80
+ @return_url = val
81
+ end
82
+
83
+ def cancel_url=(val)
84
+ @cancel_url = val
85
+ end
86
+
87
+ def sandbox=(val)
88
+ @sandbox = val
89
+ end
90
+
91
+ def created_at=(val)
92
+ @created_at = val
93
+ end
94
+
95
+
96
+ # Initializes the Plan object
97
+ # Params:
98
+ # +client+:: +ProcessOut+ client instance
99
+ # +data+:: data that can be used to fill the object
100
+ def initialize(client, data = {})
101
+ @client = client
102
+
103
+ self.id = data.fetch(:id, nil)
104
+ self.project = data.fetch(:project, nil)
105
+ self.project_id = data.fetch(:project_id, nil)
106
+ self.url = data.fetch(:url, nil)
107
+ self.name = data.fetch(:name, nil)
108
+ self.amount = data.fetch(:amount, nil)
109
+ self.currency = data.fetch(:currency, nil)
110
+ self.metadata = data.fetch(:metadata, nil)
111
+ self.interval = data.fetch(:interval, nil)
112
+ self.trial_period = data.fetch(:trial_period, nil)
113
+ self.return_url = data.fetch(:return_url, nil)
114
+ self.cancel_url = data.fetch(:cancel_url, nil)
115
+ self.sandbox = data.fetch(:sandbox, nil)
116
+ self.created_at = data.fetch(:created_at, nil)
117
+
118
+ end
119
+
120
+ # Create a new Plan using the current client
121
+ def new(data = {})
122
+ Plan.new(@client, data)
123
+ end
124
+
125
+ # Overrides the JSON marshaller to only send the fields we want
126
+ def to_json(options)
127
+ {
128
+ "id": self.id,
129
+ "project": self.project,
130
+ "project_id": self.project_id,
131
+ "url": self.url,
132
+ "name": self.name,
133
+ "amount": self.amount,
134
+ "currency": self.currency,
135
+ "metadata": self.metadata,
136
+ "interval": self.interval,
137
+ "trial_period": self.trial_period,
138
+ "return_url": self.return_url,
139
+ "cancel_url": self.cancel_url,
140
+ "sandbox": self.sandbox,
141
+ "created_at": self.created_at,
142
+ }.to_json
143
+ end
144
+
145
+ # Fills the object with data coming from the API
146
+ # Params:
147
+ # +data+:: +Hash+ of data coming from the API
148
+ def fill_with_data(data)
149
+ if data.nil?
150
+ return self
151
+ end
152
+ if data.include? "id"
153
+ self.id = data["id"]
154
+ end
155
+ if data.include? "project"
156
+ self.project = data["project"]
157
+ end
158
+ if data.include? "project_id"
159
+ self.project_id = data["project_id"]
160
+ end
161
+ if data.include? "url"
162
+ self.url = data["url"]
163
+ end
164
+ if data.include? "name"
165
+ self.name = data["name"]
166
+ end
167
+ if data.include? "amount"
168
+ self.amount = data["amount"]
169
+ end
170
+ if data.include? "currency"
171
+ self.currency = data["currency"]
172
+ end
173
+ if data.include? "metadata"
174
+ self.metadata = data["metadata"]
175
+ end
176
+ if data.include? "interval"
177
+ self.interval = data["interval"]
178
+ end
179
+ if data.include? "trial_period"
180
+ self.trial_period = data["trial_period"]
181
+ end
182
+ if data.include? "return_url"
183
+ self.return_url = data["return_url"]
184
+ end
185
+ if data.include? "cancel_url"
186
+ self.cancel_url = data["cancel_url"]
187
+ end
188
+ if data.include? "sandbox"
189
+ self.sandbox = data["sandbox"]
190
+ end
191
+ if data.include? "created_at"
192
+ self.created_at = data["created_at"]
193
+ end
194
+
195
+ self
196
+ end
197
+
198
+ # Prefills the object with the data passed as parameters
199
+ # Params:
200
+ # +data+:: +Hash+ of data
201
+ def prefill(data)
202
+ if data.nil?
203
+ return self
204
+ end
205
+ self.id = data.fetch(:id, self.id)
206
+ self.project = data.fetch(:project, self.project)
207
+ self.project_id = data.fetch(:project_id, self.project_id)
208
+ self.url = data.fetch(:url, self.url)
209
+ self.name = data.fetch(:name, self.name)
210
+ self.amount = data.fetch(:amount, self.amount)
211
+ self.currency = data.fetch(:currency, self.currency)
212
+ self.metadata = data.fetch(:metadata, self.metadata)
213
+ self.interval = data.fetch(:interval, self.interval)
214
+ self.trial_period = data.fetch(:trial_period, self.trial_period)
215
+ self.return_url = data.fetch(:return_url, self.return_url)
216
+ self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
217
+ self.sandbox = data.fetch(:sandbox, self.sandbox)
218
+ self.created_at = data.fetch(:created_at, self.created_at)
219
+
220
+ self
221
+ end
222
+
223
+ # Get all the plans.
224
+ # Params:
225
+ # +options+:: +Hash+ of options
226
+ def all(options = {})
227
+ self.prefill(options)
228
+
229
+ request = Request.new(@client)
230
+ path = "/plans"
231
+ data = {
232
+
233
+ }
234
+
235
+ response = Response.new(request.get(path, data, options))
236
+ return_values = Array.new
237
+
238
+ a = Array.new
239
+ body = response.body
240
+ for v in body['plans']
241
+ tmp = Plan.new(@client)
242
+ tmp.fill_with_data(v)
243
+ a.push(tmp)
244
+ end
245
+
246
+ return_values.push(a)
247
+
248
+
249
+
250
+ return_values[0]
251
+ end
252
+
253
+ # Create a new plan.
254
+ # Params:
255
+ # +options+:: +Hash+ of options
256
+ def create(options = {})
257
+ self.prefill(options)
258
+
259
+ request = Request.new(@client)
260
+ path = "/plans"
261
+ data = {
262
+ "id" => @id,
263
+ "name" => @name,
264
+ "amount" => @amount,
265
+ "currency" => @currency,
266
+ "interval" => @interval,
267
+ "trial_period" => @trial_period,
268
+ "metadata" => @metadata,
269
+ "return_url" => @return_url,
270
+ "cancel_url" => @cancel_url
271
+ }
272
+
273
+ response = Response.new(request.post(path, data, options))
274
+ return_values = Array.new
275
+
276
+ body = response.body
277
+ body = body["plan"]
278
+
279
+
280
+ return_values.push(self.fill_with_data(body))
281
+
282
+
283
+
284
+ return_values[0]
285
+ end
286
+
287
+ # Find a plan by its ID.
288
+ # Params:
289
+ # +plan_id+:: ID of the plan
290
+ # +options+:: +Hash+ of options
291
+ def find(plan_id, options = {})
292
+ self.prefill(options)
293
+
294
+ request = Request.new(@client)
295
+ path = "/plans/" + CGI.escape(plan_id) + ""
296
+ data = {
297
+
298
+ }
299
+
300
+ response = Response.new(request.get(path, data, options))
301
+ return_values = Array.new
302
+
303
+ body = response.body
304
+ body = body["plan"]
305
+
306
+
307
+ obj = Plan.new(@client)
308
+ return_values.push(obj.fill_with_data(body))
309
+
310
+
311
+
312
+ return_values[0]
313
+ end
314
+
315
+ # Save the updated plan attributes. This action won't affect subscriptions already linked to this plan.
316
+ # Params:
317
+ # +options+:: +Hash+ of options
318
+ def save(options = {})
319
+ self.prefill(options)
320
+
321
+ request = Request.new(@client)
322
+ path = "/plans/" + CGI.escape(@id) + ""
323
+ data = {
324
+ "name" => @name,
325
+ "trial_period" => @trial_period,
326
+ "metadata" => @metadata,
327
+ "return_url" => @return_url,
328
+ "cancel_url" => @cancel_url
329
+ }
330
+
331
+ response = Response.new(request.put(path, data, options))
332
+ return_values = Array.new
333
+
334
+ body = response.body
335
+ body = body["plan"]
336
+
337
+
338
+ return_values.push(self.fill_with_data(body))
339
+
340
+
341
+
342
+ return_values[0]
343
+ end
344
+
345
+ # Delete a plan. Subscriptions linked to this plan won't be affected.
346
+ # Params:
347
+ # +options+:: +Hash+ of options
348
+ def end(options = {})
349
+ self.prefill(options)
350
+
351
+ request = Request.new(@client)
352
+ path = "/plans/" + CGI.escape(@id) + ""
353
+ data = {
354
+
355
+ }
356
+
357
+ response = Response.new(request.delete(path, data, options))
358
+ return_values = Array.new
359
+
360
+ return_values.push(response.success)
361
+
362
+
363
+ return_values[0]
364
+ end
365
+
366
+
367
+ end
368
+ end
@@ -0,0 +1,368 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "json"
5
+ require "processout/networking/request"
6
+ require "processout/networking/response"
7
+
8
+ module ProcessOut
9
+ class Product
10
+
11
+ attr_reader :id
12
+ attr_reader :project
13
+ attr_reader :project_id
14
+ attr_reader :url
15
+ attr_reader :name
16
+ attr_reader :amount
17
+ attr_reader :currency
18
+ attr_reader :metadata
19
+ attr_reader :return_url
20
+ attr_reader :cancel_url
21
+ attr_reader :sandbox
22
+ attr_reader :created_at
23
+
24
+
25
+ def id=(val)
26
+ @id = val
27
+ end
28
+
29
+ def project=(val)
30
+ if val.nil?
31
+ @project = val
32
+ return
33
+ end
34
+
35
+ if val.instance_of? Project
36
+ @project = val
37
+ else
38
+ obj = Project.new(@client)
39
+ obj.fill_with_data(val)
40
+ @project = obj
41
+ end
42
+
43
+ end
44
+
45
+ def project_id=(val)
46
+ @project_id = val
47
+ end
48
+
49
+ def url=(val)
50
+ @url = val
51
+ end
52
+
53
+ def name=(val)
54
+ @name = val
55
+ end
56
+
57
+ def amount=(val)
58
+ @amount = val
59
+ end
60
+
61
+ def currency=(val)
62
+ @currency = val
63
+ end
64
+
65
+ def metadata=(val)
66
+ @metadata = val
67
+ end
68
+
69
+ def return_url=(val)
70
+ @return_url = val
71
+ end
72
+
73
+ def cancel_url=(val)
74
+ @cancel_url = val
75
+ end
76
+
77
+ def sandbox=(val)
78
+ @sandbox = val
79
+ end
80
+
81
+ def created_at=(val)
82
+ @created_at = val
83
+ end
84
+
85
+
86
+ # Initializes the Product object
87
+ # Params:
88
+ # +client+:: +ProcessOut+ client instance
89
+ # +data+:: data that can be used to fill the object
90
+ def initialize(client, data = {})
91
+ @client = client
92
+
93
+ self.id = data.fetch(:id, nil)
94
+ self.project = data.fetch(:project, nil)
95
+ self.project_id = data.fetch(:project_id, nil)
96
+ self.url = data.fetch(:url, nil)
97
+ self.name = data.fetch(:name, nil)
98
+ self.amount = data.fetch(:amount, nil)
99
+ self.currency = data.fetch(:currency, nil)
100
+ self.metadata = data.fetch(:metadata, nil)
101
+ self.return_url = data.fetch(:return_url, nil)
102
+ self.cancel_url = data.fetch(:cancel_url, nil)
103
+ self.sandbox = data.fetch(:sandbox, nil)
104
+ self.created_at = data.fetch(:created_at, nil)
105
+
106
+ end
107
+
108
+ # Create a new Product using the current client
109
+ def new(data = {})
110
+ Product.new(@client, data)
111
+ end
112
+
113
+ # Overrides the JSON marshaller to only send the fields we want
114
+ def to_json(options)
115
+ {
116
+ "id": self.id,
117
+ "project": self.project,
118
+ "project_id": self.project_id,
119
+ "url": self.url,
120
+ "name": self.name,
121
+ "amount": self.amount,
122
+ "currency": self.currency,
123
+ "metadata": self.metadata,
124
+ "return_url": self.return_url,
125
+ "cancel_url": self.cancel_url,
126
+ "sandbox": self.sandbox,
127
+ "created_at": self.created_at,
128
+ }.to_json
129
+ end
130
+
131
+ # Fills the object with data coming from the API
132
+ # Params:
133
+ # +data+:: +Hash+ of data coming from the API
134
+ def fill_with_data(data)
135
+ if data.nil?
136
+ return self
137
+ end
138
+ if data.include? "id"
139
+ self.id = data["id"]
140
+ end
141
+ if data.include? "project"
142
+ self.project = data["project"]
143
+ end
144
+ if data.include? "project_id"
145
+ self.project_id = data["project_id"]
146
+ end
147
+ if data.include? "url"
148
+ self.url = data["url"]
149
+ end
150
+ if data.include? "name"
151
+ self.name = data["name"]
152
+ end
153
+ if data.include? "amount"
154
+ self.amount = data["amount"]
155
+ end
156
+ if data.include? "currency"
157
+ self.currency = data["currency"]
158
+ end
159
+ if data.include? "metadata"
160
+ self.metadata = data["metadata"]
161
+ end
162
+ if data.include? "return_url"
163
+ self.return_url = data["return_url"]
164
+ end
165
+ if data.include? "cancel_url"
166
+ self.cancel_url = data["cancel_url"]
167
+ end
168
+ if data.include? "sandbox"
169
+ self.sandbox = data["sandbox"]
170
+ end
171
+ if data.include? "created_at"
172
+ self.created_at = data["created_at"]
173
+ end
174
+
175
+ self
176
+ end
177
+
178
+ # Prefills the object with the data passed as parameters
179
+ # Params:
180
+ # +data+:: +Hash+ of data
181
+ def prefill(data)
182
+ if data.nil?
183
+ return self
184
+ end
185
+ self.id = data.fetch(:id, self.id)
186
+ self.project = data.fetch(:project, self.project)
187
+ self.project_id = data.fetch(:project_id, self.project_id)
188
+ self.url = data.fetch(:url, self.url)
189
+ self.name = data.fetch(:name, self.name)
190
+ self.amount = data.fetch(:amount, self.amount)
191
+ self.currency = data.fetch(:currency, self.currency)
192
+ self.metadata = data.fetch(:metadata, self.metadata)
193
+ self.return_url = data.fetch(:return_url, self.return_url)
194
+ self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
195
+ self.sandbox = data.fetch(:sandbox, self.sandbox)
196
+ self.created_at = data.fetch(:created_at, self.created_at)
197
+
198
+ self
199
+ end
200
+
201
+ # Create a new invoice from the product.
202
+ # Params:
203
+ # +options+:: +Hash+ of options
204
+ def create_invoice(options = {})
205
+ self.prefill(options)
206
+
207
+ request = Request.new(@client)
208
+ path = "/products/" + CGI.escape(@id) + "/invoices"
209
+ data = {
210
+
211
+ }
212
+
213
+ response = Response.new(request.post(path, data, options))
214
+ return_values = Array.new
215
+
216
+ body = response.body
217
+ body = body["invoice"]
218
+ invoice = Invoice.new(@client)
219
+ return_values.push(invoice.fill_with_data(body))
220
+
221
+
222
+ return_values[0]
223
+ end
224
+
225
+ # Get all the products.
226
+ # Params:
227
+ # +options+:: +Hash+ of options
228
+ def all(options = {})
229
+ self.prefill(options)
230
+
231
+ request = Request.new(@client)
232
+ path = "/products"
233
+ data = {
234
+
235
+ }
236
+
237
+ response = Response.new(request.get(path, data, options))
238
+ return_values = Array.new
239
+
240
+ a = Array.new
241
+ body = response.body
242
+ for v in body['products']
243
+ tmp = Product.new(@client)
244
+ tmp.fill_with_data(v)
245
+ a.push(tmp)
246
+ end
247
+
248
+ return_values.push(a)
249
+
250
+
251
+
252
+ return_values[0]
253
+ end
254
+
255
+ # Create a new product.
256
+ # Params:
257
+ # +options+:: +Hash+ of options
258
+ def create(options = {})
259
+ self.prefill(options)
260
+
261
+ request = Request.new(@client)
262
+ path = "/products"
263
+ data = {
264
+ "name" => @name,
265
+ "amount" => @amount,
266
+ "currency" => @currency,
267
+ "metadata" => @metadata,
268
+ "return_url" => @return_url,
269
+ "cancel_url" => @cancel_url
270
+ }
271
+
272
+ response = Response.new(request.post(path, data, options))
273
+ return_values = Array.new
274
+
275
+ body = response.body
276
+ body = body["product"]
277
+
278
+
279
+ return_values.push(self.fill_with_data(body))
280
+
281
+
282
+
283
+ return_values[0]
284
+ end
285
+
286
+ # Find a product by its ID.
287
+ # Params:
288
+ # +product_id+:: ID of the product
289
+ # +options+:: +Hash+ of options
290
+ def find(product_id, options = {})
291
+ self.prefill(options)
292
+
293
+ request = Request.new(@client)
294
+ path = "/products/" + CGI.escape(product_id) + ""
295
+ data = {
296
+
297
+ }
298
+
299
+ response = Response.new(request.get(path, data, options))
300
+ return_values = Array.new
301
+
302
+ body = response.body
303
+ body = body["product"]
304
+
305
+
306
+ obj = Product.new(@client)
307
+ return_values.push(obj.fill_with_data(body))
308
+
309
+
310
+
311
+ return_values[0]
312
+ end
313
+
314
+ # Save the updated product attributes.
315
+ # Params:
316
+ # +options+:: +Hash+ of options
317
+ def save(options = {})
318
+ self.prefill(options)
319
+
320
+ request = Request.new(@client)
321
+ path = "/products/" + CGI.escape(@id) + ""
322
+ data = {
323
+ "name" => @name,
324
+ "amount" => @amount,
325
+ "currency" => @currency,
326
+ "metadata" => @metadata,
327
+ "return_url" => @return_url,
328
+ "cancel_url" => @cancel_url
329
+ }
330
+
331
+ response = Response.new(request.put(path, data, options))
332
+ return_values = Array.new
333
+
334
+ body = response.body
335
+ body = body["product"]
336
+
337
+
338
+ return_values.push(self.fill_with_data(body))
339
+
340
+
341
+
342
+ return_values[0]
343
+ end
344
+
345
+ # Delete the product.
346
+ # Params:
347
+ # +options+:: +Hash+ of options
348
+ def delete(options = {})
349
+ self.prefill(options)
350
+
351
+ request = Request.new(@client)
352
+ path = "/products/" + CGI.escape(@id) + ""
353
+ data = {
354
+
355
+ }
356
+
357
+ response = Response.new(request.delete(path, data, options))
358
+ return_values = Array.new
359
+
360
+ return_values.push(response.success)
361
+
362
+
363
+ return_values[0]
364
+ end
365
+
366
+
367
+ end
368
+ end