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,50 @@
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 CustomerAction
9
+
10
+ attr_reader :type
11
+ attr_reader :value
12
+
13
+
14
+ def type=(val)
15
+ @type = val
16
+ end
17
+
18
+ def value=(val)
19
+ @value = val
20
+ end
21
+
22
+
23
+ # Initializes the CustomerAction object
24
+ # Params:
25
+ # +client+:: +ProcessOut+ client instance
26
+ def initialize(client)
27
+ @client = client
28
+
29
+ @type = ""
30
+ @value = ""
31
+
32
+ end
33
+
34
+ # Fills the object with data coming from the API
35
+ # Params:
36
+ # +data+:: +Hash+ of data coming from the API
37
+ def fill_with_data(data)
38
+ if data.include? "type"
39
+ @type = data["type"]
40
+ end
41
+ if data.include? "value"
42
+ @value = data["value"]
43
+ end
44
+
45
+ self
46
+ end
47
+
48
+
49
+ end
50
+ end
@@ -0,0 +1,217 @@
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 Discount
9
+
10
+ attr_reader :id
11
+ attr_reader :project
12
+ attr_reader :subscription
13
+ attr_reader :coupon
14
+ attr_reader :amount
15
+ attr_reader :expires_at
16
+ attr_reader :metadata
17
+ attr_reader :sandbox
18
+ attr_reader :created_at
19
+
20
+
21
+ def id=(val)
22
+ @id = val
23
+ end
24
+
25
+ def project=(val)
26
+ if val.instance_of? Project
27
+ @project = val
28
+ else
29
+ obj = Project.new(@client)
30
+ obj.fill_with_data(val)
31
+ @project = obj
32
+ end
33
+
34
+ end
35
+
36
+ def subscription=(val)
37
+ if val.instance_of? Subscription
38
+ @subscription = val
39
+ else
40
+ obj = Subscription.new(@client)
41
+ obj.fill_with_data(val)
42
+ @subscription = obj
43
+ end
44
+
45
+ end
46
+
47
+ def coupon=(val)
48
+ if val.instance_of? Coupon
49
+ @coupon = val
50
+ else
51
+ obj = Coupon.new(@client)
52
+ obj.fill_with_data(val)
53
+ @coupon = obj
54
+ end
55
+
56
+ end
57
+
58
+ def amount=(val)
59
+ @amount = val
60
+ end
61
+
62
+ def expires_at=(val)
63
+ @expires_at = val
64
+ end
65
+
66
+ def metadata=(val)
67
+ @metadata = val
68
+ end
69
+
70
+ def sandbox=(val)
71
+ @sandbox = val
72
+ end
73
+
74
+ def created_at=(val)
75
+ @created_at = val
76
+ end
77
+
78
+
79
+ # Initializes the Discount object
80
+ # Params:
81
+ # +client+:: +ProcessOut+ client instance
82
+ def initialize(client)
83
+ @client = client
84
+
85
+ @id = ""
86
+ @project = nil
87
+ @subscription = nil
88
+ @coupon = nil
89
+ @amount = ""
90
+ @expires_at = ""
91
+ @metadata = Hash.new
92
+ @sandbox = false
93
+ @created_at = ""
94
+
95
+ end
96
+
97
+ # Fills the object with data coming from the API
98
+ # Params:
99
+ # +data+:: +Hash+ of data coming from the API
100
+ def fill_with_data(data)
101
+ if data.include? "id"
102
+ @id = data["id"]
103
+ end
104
+ if data.include? "project"
105
+ @project = data["project"]
106
+ end
107
+ if data.include? "subscription"
108
+ @subscription = data["subscription"]
109
+ end
110
+ if data.include? "coupon"
111
+ @coupon = data["coupon"]
112
+ end
113
+ if data.include? "amount"
114
+ @amount = data["amount"]
115
+ end
116
+ if data.include? "expires_at"
117
+ @expires_at = data["expires_at"]
118
+ end
119
+ if data.include? "metadata"
120
+ @metadata = data["metadata"]
121
+ end
122
+ if data.include? "sandbox"
123
+ @sandbox = data["sandbox"]
124
+ end
125
+ if data.include? "created_at"
126
+ @created_at = data["created_at"]
127
+ end
128
+
129
+ self
130
+ end
131
+
132
+ # Apply a new discount to the given subscription ID.
133
+ # Params:
134
+ # +subscription_id+:: ID of the subscription
135
+ # +options+:: +Hash+ of options
136
+ def apply(subscription_id, options = nil)
137
+ request = Request.new(@client)
138
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
139
+ data = {
140
+ "amount": @amount,
141
+ "expires_at": @expires_at,
142
+ "metadata": @metadata
143
+ }
144
+
145
+ response = Response.new(request.post(path, data, options))
146
+ return_values = Array.new
147
+
148
+ body = response.body
149
+ body = body["discount"]
150
+
151
+
152
+ return_values.push(self.fill_with_data(body))
153
+
154
+
155
+
156
+ return_values[0]
157
+ end
158
+
159
+ # Apply a new discount to the given subscription ID from a coupon ID.
160
+ # Params:
161
+ # +subscription_id+:: ID of the subscription
162
+ # +coupon_id+:: ID of the coupon
163
+ # +options+:: +Hash+ of options
164
+ def apply_coupon(subscription_id, coupon_id, options = nil)
165
+ request = Request.new(@client)
166
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts"
167
+ data = {
168
+ "amount": @amount,
169
+ "expires_at": @expires_at,
170
+ "metadata": @metadata,
171
+ 'coupon_id': coupon_id
172
+ }
173
+
174
+ response = Response.new(request.post(path, data, options))
175
+ return_values = Array.new
176
+
177
+ body = response.body
178
+ body = body["discount"]
179
+
180
+
181
+ return_values.push(self.fill_with_data(body))
182
+
183
+
184
+
185
+ return_values[0]
186
+ end
187
+
188
+ # Find a subscription's discount by its ID.
189
+ # Params:
190
+ # +subscription_id+:: ID of the subscription
191
+ # +discount_id+:: ID of the discount
192
+ # +options+:: +Hash+ of options
193
+ def find(subscription_id, discount_id, options = nil)
194
+ request = Request.new(@client)
195
+ path = "/subscriptions/" + CGI.escape(subscription_id) + "/discounts/" + CGI.escape(discount_id) + ""
196
+ data = {
197
+
198
+ }
199
+
200
+ response = Response.new(request.get(path, data, options))
201
+ return_values = Array.new
202
+
203
+ body = response.body
204
+ body = body["discount"]
205
+
206
+
207
+ obj = Discount.new(@client)
208
+ return_values.push(obj.fill_with_data(body))
209
+
210
+
211
+
212
+ return_values[0]
213
+ end
214
+
215
+
216
+ end
217
+ end
@@ -0,0 +1,7 @@
1
+ module ProcessOut
2
+ class AuthenticationError < StandardError
3
+ def initialize(msg)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module ProcessOut
2
+ class GenericError < StandardError
3
+ def initialize(msg)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module ProcessOut
2
+ class InternalError < StandardError
3
+ def initialize(msg)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module ProcessOut
2
+ class NotFoundError < StandardError
3
+ def initialize(msg)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module ProcessOut
2
+ class ValidationError < StandardError
3
+ def initialize(msg)
4
+ super
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,176 @@
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 Event
9
+
10
+ attr_reader :id
11
+ attr_reader :project
12
+ attr_reader :name
13
+ attr_reader :data
14
+ attr_reader :sandbox
15
+ attr_reader :fired_at
16
+
17
+
18
+ def id=(val)
19
+ @id = val
20
+ end
21
+
22
+ def project=(val)
23
+ if val.instance_of? Project
24
+ @project = val
25
+ else
26
+ obj = Project.new(@client)
27
+ obj.fill_with_data(val)
28
+ @project = obj
29
+ end
30
+
31
+ end
32
+
33
+ def name=(val)
34
+ @name = val
35
+ end
36
+
37
+ def data=(val)
38
+ @data = val
39
+
40
+ end
41
+
42
+ def sandbox=(val)
43
+ @sandbox = val
44
+ end
45
+
46
+ def fired_at=(val)
47
+ @fired_at = val
48
+ end
49
+
50
+
51
+ # Initializes the Event object
52
+ # Params:
53
+ # +client+:: +ProcessOut+ client instance
54
+ def initialize(client)
55
+ @client = client
56
+
57
+ @id = ""
58
+ @project = nil
59
+ @name = ""
60
+ @data = nil
61
+ @sandbox = false
62
+ @fired_at = ""
63
+
64
+ end
65
+
66
+ # Fills the object with data coming from the API
67
+ # Params:
68
+ # +data+:: +Hash+ of data coming from the API
69
+ def fill_with_data(data)
70
+ if data.include? "id"
71
+ @id = data["id"]
72
+ end
73
+ if data.include? "project"
74
+ @project = data["project"]
75
+ end
76
+ if data.include? "name"
77
+ @name = data["name"]
78
+ end
79
+ if data.include? "data"
80
+ @data = data["data"]
81
+ end
82
+ if data.include? "sandbox"
83
+ @sandbox = data["sandbox"]
84
+ end
85
+ if data.include? "fired_at"
86
+ @fired_at = data["fired_at"]
87
+ end
88
+
89
+ self
90
+ end
91
+
92
+ # Get all the webhooks of the event.
93
+ # Params:
94
+ # +options+:: +Hash+ of options
95
+ def webhooks(options = nil)
96
+ request = Request.new(@client)
97
+ path = "/events/" + CGI.escape(@id) + "/webhooks"
98
+ data = {
99
+
100
+ }
101
+
102
+ response = Response.new(request.get(path, data, options))
103
+ return_values = Array.new
104
+
105
+ a = Array.new
106
+ body = response.body
107
+ for v in body['webhooks']
108
+ tmp = Webhook(@client)
109
+ tmp.fill_with_data(v)
110
+ a.push(tmp)
111
+ end
112
+
113
+ return_values.push(a)
114
+
115
+
116
+
117
+ return_values[0]
118
+ end
119
+
120
+ # Get all the events.
121
+ # Params:
122
+ # +options+:: +Hash+ of options
123
+ def all(options = nil)
124
+ request = Request.new(@client)
125
+ path = "/events"
126
+ data = {
127
+
128
+ }
129
+
130
+ response = Response.new(request.get(path, data, options))
131
+ return_values = Array.new
132
+
133
+ a = Array.new
134
+ body = response.body
135
+ for v in body['events']
136
+ tmp = Event(@client)
137
+ tmp.fill_with_data(v)
138
+ a.push(tmp)
139
+ end
140
+
141
+ return_values.push(a)
142
+
143
+
144
+
145
+ return_values[0]
146
+ end
147
+
148
+ # Find an event by its ID.
149
+ # Params:
150
+ # +event_id+:: ID of the event
151
+ # +options+:: +Hash+ of options
152
+ def find(event_id, options = nil)
153
+ request = Request.new(@client)
154
+ path = "/events/" + CGI.escape(event_id) + ""
155
+ data = {
156
+
157
+ }
158
+
159
+ response = Response.new(request.get(path, data, options))
160
+ return_values = Array.new
161
+
162
+ body = response.body
163
+ body = body["event"]
164
+
165
+
166
+ obj = Event.new(@client)
167
+ return_values.push(obj.fill_with_data(body))
168
+
169
+
170
+
171
+ return_values[0]
172
+ end
173
+
174
+
175
+ end
176
+ end