processout 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +10 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/deploy.sh +25 -0
  12. data/lib/processout.rb +130 -0
  13. data/lib/processout/activity.rb +147 -0
  14. data/lib/processout/authorization_request.rb +248 -0
  15. data/lib/processout/card.rb +156 -0
  16. data/lib/processout/coupon.rb +284 -0
  17. data/lib/processout/customer.rb +418 -0
  18. data/lib/processout/customer_action.rb +50 -0
  19. data/lib/processout/discount.rb +217 -0
  20. data/lib/processout/errors/authentication_error.rb +7 -0
  21. data/lib/processout/errors/generic_error.rb +7 -0
  22. data/lib/processout/errors/internal_error.rb +7 -0
  23. data/lib/processout/errors/notfound_error.rb +7 -0
  24. data/lib/processout/errors/validation_error.rb +7 -0
  25. data/lib/processout/event.rb +176 -0
  26. data/lib/processout/gateway.rb +104 -0
  27. data/lib/processout/gateway_configuration.rb +91 -0
  28. data/lib/processout/invoice.rb +457 -0
  29. data/lib/processout/networking/request.rb +95 -0
  30. data/lib/processout/networking/response.rb +61 -0
  31. data/lib/processout/plan.rb +280 -0
  32. data/lib/processout/product.rb +313 -0
  33. data/lib/processout/project.rb +105 -0
  34. data/lib/processout/refund.rb +161 -0
  35. data/lib/processout/subscription.rb +633 -0
  36. data/lib/processout/token.rb +167 -0
  37. data/lib/processout/transaction.rb +302 -0
  38. data/lib/processout/version.rb +3 -0
  39. data/lib/processout/webhook.rb +154 -0
  40. data/processout.gemspec +26 -0
  41. metadata +125 -0
@@ -0,0 +1,156 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "processout/networking/request"
5
+ require "processout/networking/response"
6
+
7
+ module ProcessOut
8
+ class Card
9
+
10
+ attr_reader :id
11
+ attr_reader :project
12
+ attr_reader :brand
13
+ attr_reader :type
14
+ attr_reader :bank_name
15
+ attr_reader :level
16
+ attr_reader :iin
17
+ attr_reader :last_4_digits
18
+ attr_reader :exp_month
19
+ attr_reader :exp_year
20
+ attr_reader :metadata
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.instance_of? Project
31
+ @project = val
32
+ else
33
+ obj = Project.new(@client)
34
+ obj.fill_with_data(val)
35
+ @project = obj
36
+ end
37
+
38
+ end
39
+
40
+ def brand=(val)
41
+ @brand = val
42
+ end
43
+
44
+ def type=(val)
45
+ @type = val
46
+ end
47
+
48
+ def bank_name=(val)
49
+ @bank_name = val
50
+ end
51
+
52
+ def level=(val)
53
+ @level = val
54
+ end
55
+
56
+ def iin=(val)
57
+ @iin = val
58
+ end
59
+
60
+ def last_4_digits=(val)
61
+ @last_4_digits = val
62
+ end
63
+
64
+ def exp_month=(val)
65
+ @exp_month = val
66
+ end
67
+
68
+ def exp_year=(val)
69
+ @exp_year = val
70
+ end
71
+
72
+ def metadata=(val)
73
+ @metadata = val
74
+ end
75
+
76
+ def sandbox=(val)
77
+ @sandbox = val
78
+ end
79
+
80
+ def created_at=(val)
81
+ @created_at = val
82
+ end
83
+
84
+
85
+ # Initializes the Card object
86
+ # Params:
87
+ # +client+:: +ProcessOut+ client instance
88
+ def initialize(client)
89
+ @client = client
90
+
91
+ @id = ""
92
+ @project = nil
93
+ @brand = ""
94
+ @type = ""
95
+ @bank_name = ""
96
+ @level = ""
97
+ @iin = ""
98
+ @last_4_digits = ""
99
+ @exp_month = 0
100
+ @exp_year = 0
101
+ @metadata = Hash.new
102
+ @sandbox = false
103
+ @created_at = ""
104
+
105
+ end
106
+
107
+ # Fills the object with data coming from the API
108
+ # Params:
109
+ # +data+:: +Hash+ of data coming from the API
110
+ def fill_with_data(data)
111
+ if data.include? "id"
112
+ @id = data["id"]
113
+ end
114
+ if data.include? "project"
115
+ @project = data["project"]
116
+ end
117
+ if data.include? "brand"
118
+ @brand = data["brand"]
119
+ end
120
+ if data.include? "type"
121
+ @type = data["type"]
122
+ end
123
+ if data.include? "bank_name"
124
+ @bank_name = data["bank_name"]
125
+ end
126
+ if data.include? "level"
127
+ @level = data["level"]
128
+ end
129
+ if data.include? "iin"
130
+ @iin = data["iin"]
131
+ end
132
+ if data.include? "last_4_digits"
133
+ @last_4_digits = data["last_4_digits"]
134
+ end
135
+ if data.include? "exp_month"
136
+ @exp_month = data["exp_month"]
137
+ end
138
+ if data.include? "exp_year"
139
+ @exp_year = data["exp_year"]
140
+ end
141
+ if data.include? "metadata"
142
+ @metadata = data["metadata"]
143
+ end
144
+ if data.include? "sandbox"
145
+ @sandbox = data["sandbox"]
146
+ end
147
+ if data.include? "created_at"
148
+ @created_at = data["created_at"]
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+
155
+ end
156
+ end
@@ -0,0 +1,284 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "processout/networking/request"
5
+ require "processout/networking/response"
6
+
7
+ module ProcessOut
8
+ class Coupon
9
+
10
+ attr_reader :id
11
+ attr_reader :project
12
+ attr_reader :name
13
+ attr_reader :amount_off
14
+ attr_reader :percent_off
15
+ attr_reader :currency
16
+ attr_reader :max_redemptions
17
+ attr_reader :expires_at
18
+ attr_reader :metadata
19
+ attr_reader :iteration_count
20
+ attr_reader :redeemed_number
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.instance_of? Project
31
+ @project = val
32
+ else
33
+ obj = Project.new(@client)
34
+ obj.fill_with_data(val)
35
+ @project = obj
36
+ end
37
+
38
+ end
39
+
40
+ def name=(val)
41
+ @name = val
42
+ end
43
+
44
+ def amount_off=(val)
45
+ @amount_off = val
46
+ end
47
+
48
+ def percent_off=(val)
49
+ @percent_off = val
50
+ end
51
+
52
+ def currency=(val)
53
+ @currency = val
54
+ end
55
+
56
+ def max_redemptions=(val)
57
+ @max_redemptions = val
58
+ end
59
+
60
+ def expires_at=(val)
61
+ @expires_at = val
62
+ end
63
+
64
+ def metadata=(val)
65
+ @metadata = val
66
+ end
67
+
68
+ def iteration_count=(val)
69
+ @iteration_count = val
70
+ end
71
+
72
+ def redeemed_number=(val)
73
+ @redeemed_number = val
74
+ end
75
+
76
+ def sandbox=(val)
77
+ @sandbox = val
78
+ end
79
+
80
+ def created_at=(val)
81
+ @created_at = val
82
+ end
83
+
84
+
85
+ # Initializes the Coupon object
86
+ # Params:
87
+ # +client+:: +ProcessOut+ client instance
88
+ def initialize(client)
89
+ @client = client
90
+
91
+ @id = ""
92
+ @project = nil
93
+ @name = ""
94
+ @amount_off = ""
95
+ @percent_off = 0
96
+ @currency = ""
97
+ @max_redemptions = 0
98
+ @expires_at = ""
99
+ @metadata = Hash.new
100
+ @iteration_count = 0
101
+ @redeemed_number = 0
102
+ @sandbox = false
103
+ @created_at = ""
104
+
105
+ end
106
+
107
+ # Fills the object with data coming from the API
108
+ # Params:
109
+ # +data+:: +Hash+ of data coming from the API
110
+ def fill_with_data(data)
111
+ if data.include? "id"
112
+ @id = data["id"]
113
+ end
114
+ if data.include? "project"
115
+ @project = data["project"]
116
+ end
117
+ if data.include? "name"
118
+ @name = data["name"]
119
+ end
120
+ if data.include? "amount_off"
121
+ @amount_off = data["amount_off"]
122
+ end
123
+ if data.include? "percent_off"
124
+ @percent_off = data["percent_off"]
125
+ end
126
+ if data.include? "currency"
127
+ @currency = data["currency"]
128
+ end
129
+ if data.include? "max_redemptions"
130
+ @max_redemptions = data["max_redemptions"]
131
+ end
132
+ if data.include? "expires_at"
133
+ @expires_at = data["expires_at"]
134
+ end
135
+ if data.include? "metadata"
136
+ @metadata = data["metadata"]
137
+ end
138
+ if data.include? "iteration_count"
139
+ @iteration_count = data["iteration_count"]
140
+ end
141
+ if data.include? "redeemed_number"
142
+ @redeemed_number = data["redeemed_number"]
143
+ end
144
+ if data.include? "sandbox"
145
+ @sandbox = data["sandbox"]
146
+ end
147
+ if data.include? "created_at"
148
+ @created_at = data["created_at"]
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Get all the coupons.
155
+ # Params:
156
+ # +options+:: +Hash+ of options
157
+ def all(options = nil)
158
+ request = Request.new(@client)
159
+ path = "/coupons"
160
+ data = {
161
+
162
+ }
163
+
164
+ response = Response.new(request.get(path, data, options))
165
+ return_values = Array.new
166
+
167
+ a = Array.new
168
+ body = response.body
169
+ for v in body['coupons']
170
+ tmp = Coupon(@client)
171
+ tmp.fill_with_data(v)
172
+ a.push(tmp)
173
+ end
174
+
175
+ return_values.push(a)
176
+
177
+
178
+
179
+ return_values[0]
180
+ end
181
+
182
+ # Create a new coupon.
183
+ # Params:
184
+ # +options+:: +Hash+ of options
185
+ def create(options = nil)
186
+ request = Request.new(@client)
187
+ path = "/coupons"
188
+ data = {
189
+ "id": @id,
190
+ "amount_off": @amount_off,
191
+ "percent_off": @percent_off,
192
+ "currency": @currency,
193
+ "iteration_count": @iteration_count,
194
+ "max_redemptions": @max_redemptions,
195
+ "expires_at": @expires_at,
196
+ "metadata": @metadata
197
+ }
198
+
199
+ response = Response.new(request.post(path, data, options))
200
+ return_values = Array.new
201
+
202
+ body = response.body
203
+ body = body["coupon"]
204
+
205
+
206
+ return_values.push(self.fill_with_data(body))
207
+
208
+
209
+
210
+ return_values[0]
211
+ end
212
+
213
+ # Find a coupon by its ID.
214
+ # Params:
215
+ # +coupon_id+:: ID of the coupon
216
+ # +options+:: +Hash+ of options
217
+ def find(coupon_id, options = nil)
218
+ request = Request.new(@client)
219
+ path = "/coupons/" + CGI.escape(coupon_id) + ""
220
+ data = {
221
+
222
+ }
223
+
224
+ response = Response.new(request.get(path, data, options))
225
+ return_values = Array.new
226
+
227
+ body = response.body
228
+ body = body["coupon"]
229
+
230
+
231
+ obj = Coupon.new(@client)
232
+ return_values.push(obj.fill_with_data(body))
233
+
234
+
235
+
236
+ return_values[0]
237
+ end
238
+
239
+ # Save the updated coupon attributes.
240
+ # Params:
241
+ # +options+:: +Hash+ of options
242
+ def save(options = nil)
243
+ request = Request.new(@client)
244
+ path = "/coupons/" + CGI.escape(@id) + ""
245
+ data = {
246
+ "metadata": @metadata
247
+ }
248
+
249
+ response = Response.new(request.put(path, data, options))
250
+ return_values = Array.new
251
+
252
+ body = response.body
253
+ body = body["coupon"]
254
+
255
+
256
+ return_values.push(self.fill_with_data(body))
257
+
258
+
259
+
260
+ return_values[0]
261
+ end
262
+
263
+ # Delete the coupon.
264
+ # Params:
265
+ # +options+:: +Hash+ of options
266
+ def delete(options = nil)
267
+ request = Request.new(@client)
268
+ path = "/coupons/" + CGI.escape(@id) + ""
269
+ data = {
270
+
271
+ }
272
+
273
+ response = Response.new(request.delete(path, data, options))
274
+ return_values = Array.new
275
+
276
+ return_values.push(response.success)
277
+
278
+
279
+ return_values[0]
280
+ end
281
+
282
+
283
+ end
284
+ end
@@ -0,0 +1,418 @@
1
+ # The content of this file was automatically generated
2
+
3
+ require "cgi"
4
+ require "processout/networking/request"
5
+ require "processout/networking/response"
6
+
7
+ module ProcessOut
8
+ class Customer
9
+
10
+ attr_reader :id
11
+ attr_reader :project
12
+ attr_reader :email
13
+ attr_reader :first_name
14
+ attr_reader :last_name
15
+ attr_reader :address1
16
+ attr_reader :address2
17
+ attr_reader :city
18
+ attr_reader :state
19
+ attr_reader :zip
20
+ attr_reader :country_code
21
+ attr_reader :balance
22
+ attr_reader :currency
23
+ attr_reader :metadata
24
+ attr_reader :has_pin
25
+ attr_reader :sandbox
26
+ attr_reader :created_at
27
+
28
+
29
+ def id=(val)
30
+ @id = val
31
+ end
32
+
33
+ def project=(val)
34
+ if val.instance_of? Project
35
+ @project = val
36
+ else
37
+ obj = Project.new(@client)
38
+ obj.fill_with_data(val)
39
+ @project = obj
40
+ end
41
+
42
+ end
43
+
44
+ def email=(val)
45
+ @email = val
46
+ end
47
+
48
+ def first_name=(val)
49
+ @first_name = val
50
+ end
51
+
52
+ def last_name=(val)
53
+ @last_name = val
54
+ end
55
+
56
+ def address1=(val)
57
+ @address1 = val
58
+ end
59
+
60
+ def address2=(val)
61
+ @address2 = val
62
+ end
63
+
64
+ def city=(val)
65
+ @city = val
66
+ end
67
+
68
+ def state=(val)
69
+ @state = val
70
+ end
71
+
72
+ def zip=(val)
73
+ @zip = val
74
+ end
75
+
76
+ def country_code=(val)
77
+ @country_code = val
78
+ end
79
+
80
+ def balance=(val)
81
+ @balance = val
82
+ end
83
+
84
+ def currency=(val)
85
+ @currency = val
86
+ end
87
+
88
+ def metadata=(val)
89
+ @metadata = val
90
+ end
91
+
92
+ def has_pin=(val)
93
+ @has_pin = val
94
+ end
95
+
96
+ def sandbox=(val)
97
+ @sandbox = val
98
+ end
99
+
100
+ def created_at=(val)
101
+ @created_at = val
102
+ end
103
+
104
+
105
+ # Initializes the Customer object
106
+ # Params:
107
+ # +client+:: +ProcessOut+ client instance
108
+ def initialize(client)
109
+ @client = client
110
+
111
+ @id = ""
112
+ @project = nil
113
+ @email = ""
114
+ @first_name = ""
115
+ @last_name = ""
116
+ @address1 = ""
117
+ @address2 = ""
118
+ @city = ""
119
+ @state = ""
120
+ @zip = ""
121
+ @country_code = ""
122
+ @balance = "0"
123
+ @currency = ""
124
+ @metadata = Hash.new
125
+ @has_pin = false
126
+ @sandbox = false
127
+ @created_at = ""
128
+
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.include? "id"
136
+ @id = data["id"]
137
+ end
138
+ if data.include? "project"
139
+ @project = data["project"]
140
+ end
141
+ if data.include? "email"
142
+ @email = data["email"]
143
+ end
144
+ if data.include? "first_name"
145
+ @first_name = data["first_name"]
146
+ end
147
+ if data.include? "last_name"
148
+ @last_name = data["last_name"]
149
+ end
150
+ if data.include? "address1"
151
+ @address1 = data["address1"]
152
+ end
153
+ if data.include? "address2"
154
+ @address2 = data["address2"]
155
+ end
156
+ if data.include? "city"
157
+ @city = data["city"]
158
+ end
159
+ if data.include? "state"
160
+ @state = data["state"]
161
+ end
162
+ if data.include? "zip"
163
+ @zip = data["zip"]
164
+ end
165
+ if data.include? "country_code"
166
+ @country_code = data["country_code"]
167
+ end
168
+ if data.include? "balance"
169
+ @balance = data["balance"]
170
+ end
171
+ if data.include? "currency"
172
+ @currency = data["currency"]
173
+ end
174
+ if data.include? "metadata"
175
+ @metadata = data["metadata"]
176
+ end
177
+ if data.include? "has_pin"
178
+ @has_pin = data["has_pin"]
179
+ end
180
+ if data.include? "sandbox"
181
+ @sandbox = data["sandbox"]
182
+ end
183
+ if data.include? "created_at"
184
+ @created_at = data["created_at"]
185
+ end
186
+
187
+ self
188
+ end
189
+
190
+ # Get the subscriptions belonging to the customer.
191
+ # Params:
192
+ # +options+:: +Hash+ of options
193
+ def subscriptions(options = nil)
194
+ request = Request.new(@client)
195
+ path = "/customers/" + CGI.escape(@id) + "/subscriptions"
196
+ data = {
197
+
198
+ }
199
+
200
+ response = Response.new(request.get(path, data, options))
201
+ return_values = Array.new
202
+
203
+ a = Array.new
204
+ body = response.body
205
+ for v in body['subscriptions']
206
+ tmp = Subscription(@client)
207
+ tmp.fill_with_data(v)
208
+ a.push(tmp)
209
+ end
210
+
211
+ return_values.push(a)
212
+
213
+
214
+
215
+ return_values[0]
216
+ end
217
+
218
+ # Get the customer's tokens.
219
+ # Params:
220
+ # +options+:: +Hash+ of options
221
+ def tokens(options = nil)
222
+ request = Request.new(@client)
223
+ path = "/customers/" + CGI.escape(@id) + "/tokens"
224
+ data = {
225
+
226
+ }
227
+
228
+ response = Response.new(request.get(path, data, options))
229
+ return_values = Array.new
230
+
231
+ a = Array.new
232
+ body = response.body
233
+ for v in body['tokens']
234
+ tmp = Token(@client)
235
+ tmp.fill_with_data(v)
236
+ a.push(tmp)
237
+ end
238
+
239
+ return_values.push(a)
240
+
241
+
242
+
243
+ return_values[0]
244
+ end
245
+
246
+ # Get the transactions belonging to the customer.
247
+ # Params:
248
+ # +options+:: +Hash+ of options
249
+ def transactions(options = nil)
250
+ request = Request.new(@client)
251
+ path = "/customers/" + CGI.escape(@id) + "/transactions"
252
+ data = {
253
+
254
+ }
255
+
256
+ response = Response.new(request.get(path, data, options))
257
+ return_values = Array.new
258
+
259
+ a = Array.new
260
+ body = response.body
261
+ for v in body['transactions']
262
+ tmp = Transaction(@client)
263
+ tmp.fill_with_data(v)
264
+ a.push(tmp)
265
+ end
266
+
267
+ return_values.push(a)
268
+
269
+
270
+
271
+ return_values[0]
272
+ end
273
+
274
+ # Get all the customers.
275
+ # Params:
276
+ # +options+:: +Hash+ of options
277
+ def all(options = nil)
278
+ request = Request.new(@client)
279
+ path = "/customers"
280
+ data = {
281
+
282
+ }
283
+
284
+ response = Response.new(request.get(path, data, options))
285
+ return_values = Array.new
286
+
287
+ a = Array.new
288
+ body = response.body
289
+ for v in body['customers']
290
+ tmp = Customer(@client)
291
+ tmp.fill_with_data(v)
292
+ a.push(tmp)
293
+ end
294
+
295
+ return_values.push(a)
296
+
297
+
298
+
299
+ return_values[0]
300
+ end
301
+
302
+ # Create a new customer.
303
+ # Params:
304
+ # +options+:: +Hash+ of options
305
+ def create(options = nil)
306
+ request = Request.new(@client)
307
+ path = "/customers"
308
+ data = {
309
+ "balance": @balance,
310
+ "currency": @currency,
311
+ "email": @email,
312
+ "first_name": @first_name,
313
+ "last_name": @last_name,
314
+ "address1": @address1,
315
+ "address2": @address2,
316
+ "city": @city,
317
+ "state": @state,
318
+ "zip": @zip,
319
+ "country_code": @country_code,
320
+ "metadata": @metadata
321
+ }
322
+
323
+ response = Response.new(request.post(path, data, options))
324
+ return_values = Array.new
325
+
326
+ body = response.body
327
+ body = body["customer"]
328
+
329
+
330
+ return_values.push(self.fill_with_data(body))
331
+
332
+
333
+
334
+ return_values[0]
335
+ end
336
+
337
+ # Find a customer by its ID.
338
+ # Params:
339
+ # +customer_id+:: ID of the customer
340
+ # +options+:: +Hash+ of options
341
+ def find(customer_id, options = nil)
342
+ request = Request.new(@client)
343
+ path = "/customers/" + CGI.escape(customer_id) + ""
344
+ data = {
345
+
346
+ }
347
+
348
+ response = Response.new(request.get(path, data, options))
349
+ return_values = Array.new
350
+
351
+ body = response.body
352
+ body = body["customer"]
353
+
354
+
355
+ obj = Customer.new(@client)
356
+ return_values.push(obj.fill_with_data(body))
357
+
358
+
359
+
360
+ return_values[0]
361
+ end
362
+
363
+ # Save the updated customer attributes.
364
+ # Params:
365
+ # +options+:: +Hash+ of options
366
+ def save(options = nil)
367
+ request = Request.new(@client)
368
+ path = "/customers/" + CGI.escape(@id) + ""
369
+ data = {
370
+ "balance": @balance,
371
+ "email": @email,
372
+ "first_name": @first_name,
373
+ "last_name": @last_name,
374
+ "address1": @address1,
375
+ "address2": @address2,
376
+ "city": @city,
377
+ "state": @state,
378
+ "zip": @zip,
379
+ "country_code": @country_code,
380
+ "metadata": @metadata
381
+ }
382
+
383
+ response = Response.new(request.put(path, data, options))
384
+ return_values = Array.new
385
+
386
+ body = response.body
387
+ body = body["customer"]
388
+
389
+
390
+ return_values.push(self.fill_with_data(body))
391
+
392
+
393
+
394
+ return_values[0]
395
+ end
396
+
397
+ # Delete the customer.
398
+ # Params:
399
+ # +options+:: +Hash+ of options
400
+ def delete(options = nil)
401
+ request = Request.new(@client)
402
+ path = "/customers/" + CGI.escape(@id) + ""
403
+ data = {
404
+
405
+ }
406
+
407
+ response = Response.new(request.delete(path, data, options))
408
+ return_values = Array.new
409
+
410
+ return_values.push(response.success)
411
+
412
+
413
+ return_values[0]
414
+ end
415
+
416
+
417
+ end
418
+ end