processout 2.20.0 → 2.22.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 +985 -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,295 @@
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 APIRequest
10
+
11
+ attr_reader :id
12
+ attr_reader :project
13
+ attr_reader :api_version
14
+ attr_reader :idempotency_key
15
+ attr_reader :url
16
+ attr_reader :method
17
+ attr_reader :headers
18
+ attr_reader :body
19
+ attr_reader :response_code
20
+ attr_reader :response_headers
21
+ attr_reader :response_body
22
+ attr_reader :response_ms
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 api_version=(val)
48
+ if val.nil?
49
+ @api_version = val
50
+ return
51
+ end
52
+
53
+ if val.instance_of? APIVersion
54
+ @api_version = val
55
+ else
56
+ obj = APIVersion.new(@client)
57
+ obj.fill_with_data(val)
58
+ @api_version = obj
59
+ end
60
+
61
+ end
62
+
63
+ def idempotency_key=(val)
64
+ @idempotency_key = val
65
+ end
66
+
67
+ def url=(val)
68
+ @url = val
69
+ end
70
+
71
+ def method=(val)
72
+ @method = val
73
+ end
74
+
75
+ def headers=(val)
76
+ @headers = val
77
+ end
78
+
79
+ def body=(val)
80
+ @body = val
81
+ end
82
+
83
+ def response_code=(val)
84
+ @response_code = val
85
+ end
86
+
87
+ def response_headers=(val)
88
+ @response_headers = val
89
+ end
90
+
91
+ def response_body=(val)
92
+ @response_body = val
93
+ end
94
+
95
+ def response_ms=(val)
96
+ @response_ms = val
97
+ end
98
+
99
+ def sandbox=(val)
100
+ @sandbox = val
101
+ end
102
+
103
+ def created_at=(val)
104
+ @created_at = val
105
+ end
106
+
107
+
108
+ # Initializes the APIRequest object
109
+ # Params:
110
+ # +client+:: +ProcessOut+ client instance
111
+ # +data+:: data that can be used to fill the object
112
+ def initialize(client, data = {})
113
+ @client = client
114
+
115
+ self.id = data.fetch(:id, nil)
116
+ self.project = data.fetch(:project, nil)
117
+ self.api_version = data.fetch(:api_version, nil)
118
+ self.idempotency_key = data.fetch(:idempotency_key, nil)
119
+ self.url = data.fetch(:url, nil)
120
+ self.method = data.fetch(:method, nil)
121
+ self.headers = data.fetch(:headers, nil)
122
+ self.body = data.fetch(:body, nil)
123
+ self.response_code = data.fetch(:response_code, nil)
124
+ self.response_headers = data.fetch(:response_headers, nil)
125
+ self.response_body = data.fetch(:response_body, nil)
126
+ self.response_ms = data.fetch(:response_ms, nil)
127
+ self.sandbox = data.fetch(:sandbox, nil)
128
+ self.created_at = data.fetch(:created_at, nil)
129
+
130
+ end
131
+
132
+ # Create a new APIRequest using the current client
133
+ def new(data = {})
134
+ APIRequest.new(@client, data)
135
+ end
136
+
137
+ # Overrides the JSON marshaller to only send the fields we want
138
+ def to_json(options)
139
+ {
140
+ "id": self.id,
141
+ "project": self.project,
142
+ "api_version": self.api_version,
143
+ "idempotency_key": self.idempotency_key,
144
+ "url": self.url,
145
+ "method": self.method,
146
+ "headers": self.headers,
147
+ "body": self.body,
148
+ "response_code": self.response_code,
149
+ "response_headers": self.response_headers,
150
+ "response_body": self.response_body,
151
+ "response_ms": self.response_ms,
152
+ "sandbox": self.sandbox,
153
+ "created_at": self.created_at,
154
+ }.to_json
155
+ end
156
+
157
+ # Fills the object with data coming from the API
158
+ # Params:
159
+ # +data+:: +Hash+ of data coming from the API
160
+ def fill_with_data(data)
161
+ if data.nil?
162
+ return self
163
+ end
164
+ if data.include? "id"
165
+ self.id = data["id"]
166
+ end
167
+ if data.include? "project"
168
+ self.project = data["project"]
169
+ end
170
+ if data.include? "api_version"
171
+ self.api_version = data["api_version"]
172
+ end
173
+ if data.include? "idempotency_key"
174
+ self.idempotency_key = data["idempotency_key"]
175
+ end
176
+ if data.include? "url"
177
+ self.url = data["url"]
178
+ end
179
+ if data.include? "method"
180
+ self.method = data["method"]
181
+ end
182
+ if data.include? "headers"
183
+ self.headers = data["headers"]
184
+ end
185
+ if data.include? "body"
186
+ self.body = data["body"]
187
+ end
188
+ if data.include? "response_code"
189
+ self.response_code = data["response_code"]
190
+ end
191
+ if data.include? "response_headers"
192
+ self.response_headers = data["response_headers"]
193
+ end
194
+ if data.include? "response_body"
195
+ self.response_body = data["response_body"]
196
+ end
197
+ if data.include? "response_ms"
198
+ self.response_ms = data["response_ms"]
199
+ end
200
+ if data.include? "sandbox"
201
+ self.sandbox = data["sandbox"]
202
+ end
203
+ if data.include? "created_at"
204
+ self.created_at = data["created_at"]
205
+ end
206
+
207
+ self
208
+ end
209
+
210
+ # Prefills the object with the data passed as parameters
211
+ # Params:
212
+ # +data+:: +Hash+ of data
213
+ def prefill(data)
214
+ if data.nil?
215
+ return self
216
+ end
217
+ self.id = data.fetch(:id, self.id)
218
+ self.project = data.fetch(:project, self.project)
219
+ self.api_version = data.fetch(:api_version, self.api_version)
220
+ self.idempotency_key = data.fetch(:idempotency_key, self.idempotency_key)
221
+ self.url = data.fetch(:url, self.url)
222
+ self.method = data.fetch(:method, self.method)
223
+ self.headers = data.fetch(:headers, self.headers)
224
+ self.body = data.fetch(:body, self.body)
225
+ self.response_code = data.fetch(:response_code, self.response_code)
226
+ self.response_headers = data.fetch(:response_headers, self.response_headers)
227
+ self.response_body = data.fetch(:response_body, self.response_body)
228
+ self.response_ms = data.fetch(:response_ms, self.response_ms)
229
+ self.sandbox = data.fetch(:sandbox, self.sandbox)
230
+ self.created_at = data.fetch(:created_at, self.created_at)
231
+
232
+ self
233
+ end
234
+
235
+ # Get all the API requests.
236
+ # Params:
237
+ # +options+:: +Hash+ of options
238
+ def all(options = {})
239
+ self.prefill(options)
240
+
241
+ request = Request.new(@client)
242
+ path = "/api-requests"
243
+ data = {
244
+
245
+ }
246
+
247
+ response = Response.new(request.get(path, data, options))
248
+ return_values = Array.new
249
+
250
+ a = Array.new
251
+ body = response.body
252
+ for v in body['api_requests']
253
+ tmp = APIRequest.new(@client)
254
+ tmp.fill_with_data(v)
255
+ a.push(tmp)
256
+ end
257
+
258
+ return_values.push(a)
259
+
260
+
261
+
262
+ return_values[0]
263
+ end
264
+
265
+ # Find an API request by its ID.
266
+ # Params:
267
+ # +api_request_id+:: ID of the API request
268
+ # +options+:: +Hash+ of options
269
+ def find(api_request_id, options = {})
270
+ self.prefill(options)
271
+
272
+ request = Request.new(@client)
273
+ path = "/api-requests/{request_id}"
274
+ data = {
275
+
276
+ }
277
+
278
+ response = Response.new(request.get(path, data, options))
279
+ return_values = Array.new
280
+
281
+ body = response.body
282
+ body = body["api_request"]
283
+
284
+
285
+ obj = APIRequest.new(@client)
286
+ return_values.push(obj.fill_with_data(body))
287
+
288
+
289
+
290
+ return_values[0]
291
+ end
292
+
293
+
294
+ end
295
+ end
@@ -0,0 +1,92 @@
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 APIVersion
10
+
11
+ attr_reader :name
12
+ attr_reader :description
13
+ attr_reader :created_at
14
+
15
+
16
+ def name=(val)
17
+ @name = val
18
+ end
19
+
20
+ def description=(val)
21
+ @description = val
22
+ end
23
+
24
+ def created_at=(val)
25
+ @created_at = val
26
+ end
27
+
28
+
29
+ # Initializes the APIVersion object
30
+ # Params:
31
+ # +client+:: +ProcessOut+ client instance
32
+ # +data+:: data that can be used to fill the object
33
+ def initialize(client, data = {})
34
+ @client = client
35
+
36
+ self.name = data.fetch(:name, nil)
37
+ self.description = data.fetch(:description, nil)
38
+ self.created_at = data.fetch(:created_at, nil)
39
+
40
+ end
41
+
42
+ # Create a new APIVersion using the current client
43
+ def new(data = {})
44
+ APIVersion.new(@client, data)
45
+ end
46
+
47
+ # Overrides the JSON marshaller to only send the fields we want
48
+ def to_json(options)
49
+ {
50
+ "name": self.name,
51
+ "description": self.description,
52
+ "created_at": self.created_at,
53
+ }.to_json
54
+ end
55
+
56
+ # Fills the object with data coming from the API
57
+ # Params:
58
+ # +data+:: +Hash+ of data coming from the API
59
+ def fill_with_data(data)
60
+ if data.nil?
61
+ return self
62
+ end
63
+ if data.include? "name"
64
+ self.name = data["name"]
65
+ end
66
+ if data.include? "description"
67
+ self.description = data["description"]
68
+ end
69
+ if data.include? "created_at"
70
+ self.created_at = data["created_at"]
71
+ end
72
+
73
+ self
74
+ end
75
+
76
+ # Prefills the object with the data passed as parameters
77
+ # Params:
78
+ # +data+:: +Hash+ of data
79
+ def prefill(data)
80
+ if data.nil?
81
+ return self
82
+ end
83
+ self.name = data.fetch(:name, self.name)
84
+ self.description = data.fetch(:description, self.description)
85
+ self.created_at = data.fetch(:created_at, self.created_at)
86
+
87
+ self
88
+ end
89
+
90
+
91
+ end
92
+ end
@@ -0,0 +1,121 @@
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 ApplePayAlternativeMerchantCertificates
10
+
11
+ attr_reader :count
12
+ attr_reader :alternative_merchant_certificates
13
+
14
+
15
+ def count=(val)
16
+ @count = val
17
+ end
18
+
19
+ def alternative_merchant_certificates=(val)
20
+ if val.nil?
21
+ @alternative_merchant_certificates = []
22
+ return
23
+ end
24
+
25
+ if val.length > 0 and val[0].instance_of? AlternativeMerchantCertificate
26
+ @alternative_merchant_certificates = val
27
+ else
28
+ l = Array.new
29
+ for v in val
30
+ obj = AlternativeMerchantCertificate.new(@client)
31
+ obj.fill_with_data(v)
32
+ l.push(obj)
33
+ end
34
+ @alternative_merchant_certificates = l
35
+ end
36
+
37
+ end
38
+
39
+
40
+ # Initializes the ApplePayAlternativeMerchantCertificates object
41
+ # Params:
42
+ # +client+:: +ProcessOut+ client instance
43
+ # +data+:: data that can be used to fill the object
44
+ def initialize(client, data = {})
45
+ @client = client
46
+
47
+ self.count = data.fetch(:count, nil)
48
+ self.alternative_merchant_certificates = data.fetch(:alternative_merchant_certificates, nil)
49
+
50
+ end
51
+
52
+ # Create a new ApplePayAlternativeMerchantCertificates using the current client
53
+ def new(data = {})
54
+ ApplePayAlternativeMerchantCertificates.new(@client, data)
55
+ end
56
+
57
+ # Overrides the JSON marshaller to only send the fields we want
58
+ def to_json(options)
59
+ {
60
+ "count": self.count,
61
+ "alternative_merchant_certificates": self.alternative_merchant_certificates,
62
+ }.to_json
63
+ end
64
+
65
+ # Fills the object with data coming from the API
66
+ # Params:
67
+ # +data+:: +Hash+ of data coming from the API
68
+ def fill_with_data(data)
69
+ if data.nil?
70
+ return self
71
+ end
72
+ if data.include? "count"
73
+ self.count = data["count"]
74
+ end
75
+ if data.include? "alternative_merchant_certificates"
76
+ self.alternative_merchant_certificates = data["alternative_merchant_certificates"]
77
+ end
78
+
79
+ self
80
+ end
81
+
82
+ # Prefills the object with the data passed as parameters
83
+ # Params:
84
+ # +data+:: +Hash+ of data
85
+ def prefill(data)
86
+ if data.nil?
87
+ return self
88
+ end
89
+ self.count = data.fetch(:count, self.count)
90
+ self.alternative_merchant_certificates = data.fetch(:alternative_merchant_certificates, self.alternative_merchant_certificates)
91
+
92
+ self
93
+ end
94
+
95
+ # Fetch the project's alternative certificates by ID
96
+ # Params:
97
+ # +options+:: +Hash+ of options
98
+ def fetch(options = {})
99
+ self.prefill(options)
100
+
101
+ request = Request.new(@client)
102
+ path = "/projects/applepay/alternative-merchant-certificates"
103
+ data = {
104
+
105
+ }
106
+
107
+ response = Response.new(request.get(path, data, options))
108
+ return_values = Array.new
109
+
110
+ body = response.body
111
+ body = body["applepay_certificates"]
112
+ apple_pay_alternative_merchant_certificates = ApplePayAlternativeMerchantCertificates.new(@client)
113
+ return_values.push(apple_pay_alternative_merchant_certificates.fill_with_data(body))
114
+
115
+
116
+ return_values[0]
117
+ end
118
+
119
+
120
+ end
121
+ end
@@ -0,0 +1,92 @@
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 Balance
10
+
11
+ attr_reader :amount
12
+ attr_reader :currency
13
+ attr_reader :expiry
14
+
15
+
16
+ def amount=(val)
17
+ @amount = val
18
+ end
19
+
20
+ def currency=(val)
21
+ @currency = val
22
+ end
23
+
24
+ def expiry=(val)
25
+ @expiry = val
26
+ end
27
+
28
+
29
+ # Initializes the Balance object
30
+ # Params:
31
+ # +client+:: +ProcessOut+ client instance
32
+ # +data+:: data that can be used to fill the object
33
+ def initialize(client, data = {})
34
+ @client = client
35
+
36
+ self.amount = data.fetch(:amount, nil)
37
+ self.currency = data.fetch(:currency, nil)
38
+ self.expiry = data.fetch(:expiry, nil)
39
+
40
+ end
41
+
42
+ # Create a new Balance using the current client
43
+ def new(data = {})
44
+ Balance.new(@client, data)
45
+ end
46
+
47
+ # Overrides the JSON marshaller to only send the fields we want
48
+ def to_json(options)
49
+ {
50
+ "amount": self.amount,
51
+ "currency": self.currency,
52
+ "expiry": self.expiry,
53
+ }.to_json
54
+ end
55
+
56
+ # Fills the object with data coming from the API
57
+ # Params:
58
+ # +data+:: +Hash+ of data coming from the API
59
+ def fill_with_data(data)
60
+ if data.nil?
61
+ return self
62
+ end
63
+ if data.include? "amount"
64
+ self.amount = data["amount"]
65
+ end
66
+ if data.include? "currency"
67
+ self.currency = data["currency"]
68
+ end
69
+ if data.include? "expiry"
70
+ self.expiry = data["expiry"]
71
+ end
72
+
73
+ self
74
+ end
75
+
76
+ # Prefills the object with the data passed as parameters
77
+ # Params:
78
+ # +data+:: +Hash+ of data
79
+ def prefill(data)
80
+ if data.nil?
81
+ return self
82
+ end
83
+ self.amount = data.fetch(:amount, self.amount)
84
+ self.currency = data.fetch(:currency, self.currency)
85
+ self.expiry = data.fetch(:expiry, self.expiry)
86
+
87
+ self
88
+ end
89
+
90
+
91
+ end
92
+ end
@@ -0,0 +1,111 @@
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 Balances
10
+
11
+ attr_reader :vouchers
12
+
13
+
14
+ def vouchers=(val)
15
+ if val.nil?
16
+ @vouchers = []
17
+ return
18
+ end
19
+
20
+ if val.length > 0 and val[0].instance_of? Balance
21
+ @vouchers = val
22
+ else
23
+ l = Array.new
24
+ for v in val
25
+ obj = Balance.new(@client)
26
+ obj.fill_with_data(v)
27
+ l.push(obj)
28
+ end
29
+ @vouchers = l
30
+ end
31
+
32
+ end
33
+
34
+
35
+ # Initializes the Balances object
36
+ # Params:
37
+ # +client+:: +ProcessOut+ client instance
38
+ # +data+:: data that can be used to fill the object
39
+ def initialize(client, data = {})
40
+ @client = client
41
+
42
+ self.vouchers = data.fetch(:vouchers, nil)
43
+
44
+ end
45
+
46
+ # Create a new Balances using the current client
47
+ def new(data = {})
48
+ Balances.new(@client, data)
49
+ end
50
+
51
+ # Overrides the JSON marshaller to only send the fields we want
52
+ def to_json(options)
53
+ {
54
+ "vouchers": self.vouchers,
55
+ }.to_json
56
+ end
57
+
58
+ # Fills the object with data coming from the API
59
+ # Params:
60
+ # +data+:: +Hash+ of data coming from the API
61
+ def fill_with_data(data)
62
+ if data.nil?
63
+ return self
64
+ end
65
+ if data.include? "vouchers"
66
+ self.vouchers = data["vouchers"]
67
+ end
68
+
69
+ self
70
+ end
71
+
72
+ # Prefills the object with the data passed as parameters
73
+ # Params:
74
+ # +data+:: +Hash+ of data
75
+ def prefill(data)
76
+ if data.nil?
77
+ return self
78
+ end
79
+ self.vouchers = data.fetch(:vouchers, self.vouchers)
80
+
81
+ self
82
+ end
83
+
84
+ # Fetch a customer token's balance
85
+ # Params:
86
+ # +token_id+:: ID of the customer's token
87
+ # +options+:: +Hash+ of options
88
+ def find(token_id, options = {})
89
+ self.prefill(options)
90
+
91
+ request = Request.new(@client)
92
+ path = "/balances/tokens/" + CGI.escape(token_id) + ""
93
+ data = {
94
+
95
+ }
96
+
97
+ response = Response.new(request.get(path, data, options))
98
+ return_values = Array.new
99
+
100
+ body = response.body
101
+ body = body["balances"]
102
+ balances = Balances.new(@client)
103
+ return_values.push(balances.fill_with_data(body))
104
+
105
+
106
+ return_values[0]
107
+ end
108
+
109
+
110
+ end
111
+ end