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,81 @@
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 CustomerAction
10
+
11
+ attr_reader :type
12
+ attr_reader :value
13
+
14
+
15
+ def type=(val)
16
+ @type = val
17
+ end
18
+
19
+ def value=(val)
20
+ @value = val
21
+ end
22
+
23
+
24
+ # Initializes the CustomerAction object
25
+ # Params:
26
+ # +client+:: +ProcessOut+ client instance
27
+ # +data+:: data that can be used to fill the object
28
+ def initialize(client, data = {})
29
+ @client = client
30
+
31
+ self.type = data.fetch(:type, nil)
32
+ self.value = data.fetch(:value, nil)
33
+
34
+ end
35
+
36
+ # Create a new CustomerAction using the current client
37
+ def new(data = {})
38
+ CustomerAction.new(@client, data)
39
+ end
40
+
41
+ # Overrides the JSON marshaller to only send the fields we want
42
+ def to_json(options)
43
+ {
44
+ "type": self.type,
45
+ "value": self.value,
46
+ }.to_json
47
+ end
48
+
49
+ # Fills the object with data coming from the API
50
+ # Params:
51
+ # +data+:: +Hash+ of data coming from the API
52
+ def fill_with_data(data)
53
+ if data.nil?
54
+ return self
55
+ end
56
+ if data.include? "type"
57
+ self.type = data["type"]
58
+ end
59
+ if data.include? "value"
60
+ self.value = data["value"]
61
+ end
62
+
63
+ self
64
+ end
65
+
66
+ # Prefills the object with the data passed as parameters
67
+ # Params:
68
+ # +data+:: +Hash+ of data
69
+ def prefill(data)
70
+ if data.nil?
71
+ return self
72
+ end
73
+ self.type = data.fetch(:type, self.type)
74
+ self.value = data.fetch(:value, self.value)
75
+
76
+ self
77
+ end
78
+
79
+
80
+ end
81
+ end
@@ -0,0 +1,360 @@
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 Discount
10
+
11
+ attr_reader :id
12
+ attr_reader :project
13
+ attr_reader :project_id
14
+ attr_reader :subscription
15
+ attr_reader :subscription_id
16
+ attr_reader :coupon
17
+ attr_reader :coupon_id
18
+ attr_reader :name
19
+ attr_reader :amount
20
+ attr_reader :percent
21
+ attr_reader :expires_at
22
+ attr_reader :metadata
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 subscription=(val)
52
+ if val.nil?
53
+ @subscription = val
54
+ return
55
+ end
56
+
57
+ if val.instance_of? Subscription
58
+ @subscription = val
59
+ else
60
+ obj = Subscription.new(@client)
61
+ obj.fill_with_data(val)
62
+ @subscription = obj
63
+ end
64
+
65
+ end
66
+
67
+ def subscription_id=(val)
68
+ @subscription_id = val
69
+ end
70
+
71
+ def coupon=(val)
72
+ if val.nil?
73
+ @coupon = val
74
+ return
75
+ end
76
+
77
+ if val.instance_of? Coupon
78
+ @coupon = val
79
+ else
80
+ obj = Coupon.new(@client)
81
+ obj.fill_with_data(val)
82
+ @coupon = obj
83
+ end
84
+
85
+ end
86
+
87
+ def coupon_id=(val)
88
+ @coupon_id = val
89
+ end
90
+
91
+ def name=(val)
92
+ @name = val
93
+ end
94
+
95
+ def amount=(val)
96
+ @amount = val
97
+ end
98
+
99
+ def percent=(val)
100
+ @percent = val
101
+ end
102
+
103
+ def expires_at=(val)
104
+ @expires_at = val
105
+ end
106
+
107
+ def metadata=(val)
108
+ @metadata = val
109
+ end
110
+
111
+ def sandbox=(val)
112
+ @sandbox = val
113
+ end
114
+
115
+ def created_at=(val)
116
+ @created_at = val
117
+ end
118
+
119
+
120
+ # Initializes the Discount object
121
+ # Params:
122
+ # +client+:: +ProcessOut+ client instance
123
+ # +data+:: data that can be used to fill the object
124
+ def initialize(client, data = {})
125
+ @client = client
126
+
127
+ self.id = data.fetch(:id, nil)
128
+ self.project = data.fetch(:project, nil)
129
+ self.project_id = data.fetch(:project_id, nil)
130
+ self.subscription = data.fetch(:subscription, nil)
131
+ self.subscription_id = data.fetch(:subscription_id, nil)
132
+ self.coupon = data.fetch(:coupon, nil)
133
+ self.coupon_id = data.fetch(:coupon_id, nil)
134
+ self.name = data.fetch(:name, nil)
135
+ self.amount = data.fetch(:amount, nil)
136
+ self.percent = data.fetch(:percent, nil)
137
+ self.expires_at = data.fetch(:expires_at, nil)
138
+ self.metadata = data.fetch(:metadata, nil)
139
+ self.sandbox = data.fetch(:sandbox, nil)
140
+ self.created_at = data.fetch(:created_at, nil)
141
+
142
+ end
143
+
144
+ # Create a new Discount using the current client
145
+ def new(data = {})
146
+ Discount.new(@client, data)
147
+ end
148
+
149
+ # Overrides the JSON marshaller to only send the fields we want
150
+ def to_json(options)
151
+ {
152
+ "id": self.id,
153
+ "project": self.project,
154
+ "project_id": self.project_id,
155
+ "subscription": self.subscription,
156
+ "subscription_id": self.subscription_id,
157
+ "coupon": self.coupon,
158
+ "coupon_id": self.coupon_id,
159
+ "name": self.name,
160
+ "amount": self.amount,
161
+ "percent": self.percent,
162
+ "expires_at": self.expires_at,
163
+ "metadata": self.metadata,
164
+ "sandbox": self.sandbox,
165
+ "created_at": self.created_at,
166
+ }.to_json
167
+ end
168
+
169
+ # Fills the object with data coming from the API
170
+ # Params:
171
+ # +data+:: +Hash+ of data coming from the API
172
+ def fill_with_data(data)
173
+ if data.nil?
174
+ return self
175
+ end
176
+ if data.include? "id"
177
+ self.id = data["id"]
178
+ end
179
+ if data.include? "project"
180
+ self.project = data["project"]
181
+ end
182
+ if data.include? "project_id"
183
+ self.project_id = data["project_id"]
184
+ end
185
+ if data.include? "subscription"
186
+ self.subscription = data["subscription"]
187
+ end
188
+ if data.include? "subscription_id"
189
+ self.subscription_id = data["subscription_id"]
190
+ end
191
+ if data.include? "coupon"
192
+ self.coupon = data["coupon"]
193
+ end
194
+ if data.include? "coupon_id"
195
+ self.coupon_id = data["coupon_id"]
196
+ end
197
+ if data.include? "name"
198
+ self.name = data["name"]
199
+ end
200
+ if data.include? "amount"
201
+ self.amount = data["amount"]
202
+ end
203
+ if data.include? "percent"
204
+ self.percent = data["percent"]
205
+ end
206
+ if data.include? "expires_at"
207
+ self.expires_at = data["expires_at"]
208
+ end
209
+ if data.include? "metadata"
210
+ self.metadata = data["metadata"]
211
+ end
212
+ if data.include? "sandbox"
213
+ self.sandbox = data["sandbox"]
214
+ end
215
+ if data.include? "created_at"
216
+ self.created_at = data["created_at"]
217
+ end
218
+
219
+ self
220
+ end
221
+
222
+ # Prefills the object with the data passed as parameters
223
+ # Params:
224
+ # +data+:: +Hash+ of data
225
+ def prefill(data)
226
+ if data.nil?
227
+ return self
228
+ end
229
+ self.id = data.fetch(:id, self.id)
230
+ self.project = data.fetch(:project, self.project)
231
+ self.project_id = data.fetch(:project_id, self.project_id)
232
+ self.subscription = data.fetch(:subscription, self.subscription)
233
+ self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
234
+ self.coupon = data.fetch(:coupon, self.coupon)
235
+ self.coupon_id = data.fetch(:coupon_id, self.coupon_id)
236
+ self.name = data.fetch(:name, self.name)
237
+ self.amount = data.fetch(:amount, self.amount)
238
+ self.percent = data.fetch(:percent, self.percent)
239
+ self.expires_at = data.fetch(:expires_at, self.expires_at)
240
+ self.metadata = data.fetch(:metadata, self.metadata)
241
+ self.sandbox = data.fetch(:sandbox, self.sandbox)
242
+ self.created_at = data.fetch(:created_at, self.created_at)
243
+
244
+ self
245
+ end
246
+
247
+ # Get the discounts applied to the subscription.
248
+ # Params:
249
+ # +subscription_id+:: ID of the subscription
250
+ # +options+:: +Hash+ of options
251
+ def fetch_subscription_discounts(subscription_id, options = {})
252
+ self.prefill(options)
253
+
254
+ request = Request.new(@client)
255
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
256
+ data = {
257
+
258
+ }
259
+
260
+ response = Response.new(request.get(path, data, options))
261
+ return_values = Array.new
262
+
263
+ a = Array.new
264
+ body = response.body
265
+ for v in body['discounts']
266
+ tmp = Discount.new(@client)
267
+ tmp.fill_with_data(v)
268
+ a.push(tmp)
269
+ end
270
+
271
+ return_values.push(a)
272
+
273
+
274
+
275
+ return_values[0]
276
+ end
277
+
278
+ # Create a new discount for the given subscription ID.
279
+ # Params:
280
+ # +options+:: +Hash+ of options
281
+ def create(options = {})
282
+ self.prefill(options)
283
+
284
+ request = Request.new(@client)
285
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts"
286
+ data = {
287
+ "coupon_id" => @coupon_id,
288
+ "name" => @name,
289
+ "amount" => @amount,
290
+ "expires_at" => @expires_at,
291
+ "metadata" => @metadata
292
+ }
293
+
294
+ response = Response.new(request.post(path, data, options))
295
+ return_values = Array.new
296
+
297
+ body = response.body
298
+ body = body["discount"]
299
+
300
+
301
+ return_values.push(self.fill_with_data(body))
302
+
303
+
304
+
305
+ return_values[0]
306
+ end
307
+
308
+ # Find a subscription's discount by its ID.
309
+ # Params:
310
+ # +subscription_id+:: ID of the subscription on which the discount was applied
311
+ # +discount_id+:: ID of the discount
312
+ # +options+:: +Hash+ of options
313
+ def find(subscription_id, discount_id, options = {})
314
+ self.prefill(options)
315
+
316
+ request = Request.new(@client)
317
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts/" + CGI.escape(discount_id) + ""
318
+ data = {
319
+
320
+ }
321
+
322
+ response = Response.new(request.get(path, data, options))
323
+ return_values = Array.new
324
+
325
+ body = response.body
326
+ body = body["discount"]
327
+
328
+
329
+ obj = Discount.new(@client)
330
+ return_values.push(obj.fill_with_data(body))
331
+
332
+
333
+
334
+ return_values[0]
335
+ end
336
+
337
+ # Delete a discount applied to a subscription.
338
+ # Params:
339
+ # +options+:: +Hash+ of options
340
+ def delete(options = {})
341
+ self.prefill(options)
342
+
343
+ request = Request.new(@client)
344
+ path = "/subscriptions/" + CGI.escape(@subscription_id) + "/discounts/" + CGI.escape(@id) + ""
345
+ data = {
346
+
347
+ }
348
+
349
+ response = Response.new(request.delete(path, data, options))
350
+ return_values = Array.new
351
+
352
+ return_values.push(response.success)
353
+
354
+
355
+ return_values[0]
356
+ end
357
+
358
+
359
+ end
360
+ end
@@ -0,0 +1,81 @@
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 DunningAction
10
+
11
+ attr_reader :action
12
+ attr_reader :delay_in_days
13
+
14
+
15
+ def action=(val)
16
+ @action = val
17
+ end
18
+
19
+ def delay_in_days=(val)
20
+ @delay_in_days = val
21
+ end
22
+
23
+
24
+ # Initializes the DunningAction object
25
+ # Params:
26
+ # +client+:: +ProcessOut+ client instance
27
+ # +data+:: data that can be used to fill the object
28
+ def initialize(client, data = {})
29
+ @client = client
30
+
31
+ self.action = data.fetch(:action, nil)
32
+ self.delay_in_days = data.fetch(:delay_in_days, nil)
33
+
34
+ end
35
+
36
+ # Create a new DunningAction using the current client
37
+ def new(data = {})
38
+ DunningAction.new(@client, data)
39
+ end
40
+
41
+ # Overrides the JSON marshaller to only send the fields we want
42
+ def to_json(options)
43
+ {
44
+ "action": self.action,
45
+ "delay_in_days": self.delay_in_days,
46
+ }.to_json
47
+ end
48
+
49
+ # Fills the object with data coming from the API
50
+ # Params:
51
+ # +data+:: +Hash+ of data coming from the API
52
+ def fill_with_data(data)
53
+ if data.nil?
54
+ return self
55
+ end
56
+ if data.include? "action"
57
+ self.action = data["action"]
58
+ end
59
+ if data.include? "delay_in_days"
60
+ self.delay_in_days = data["delay_in_days"]
61
+ end
62
+
63
+ self
64
+ end
65
+
66
+ # Prefills the object with the data passed as parameters
67
+ # Params:
68
+ # +data+:: +Hash+ of data
69
+ def prefill(data)
70
+ if data.nil?
71
+ return self
72
+ end
73
+ self.action = data.fetch(:action, self.action)
74
+ self.delay_in_days = data.fetch(:delay_in_days, self.delay_in_days)
75
+
76
+ self
77
+ end
78
+
79
+
80
+ end
81
+ end
@@ -0,0 +1,9 @@
1
+ module ProcessOut
2
+ class AuthenticationError < StandardError
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ProcessOut
2
+ class GenericError < StandardError
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ProcessOut
2
+ class InternalError < StandardError
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ProcessOut
2
+ class NotFoundError < StandardError
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ProcessOut
2
+ class ValidationError < StandardError
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
7
+ end
8
+ end
9
+ end