processout 1.2.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/processout.rb +37 -0
- data/lib/processout/activity.rb +15 -0
- data/lib/processout/addon.rb +352 -0
- data/lib/processout/api_request.rb +274 -0
- data/lib/processout/api_version.rb +82 -0
- data/lib/processout/authorization_request.rb +62 -17
- data/lib/processout/card.rb +137 -10
- data/lib/processout/coupon.rb +22 -17
- data/lib/processout/customer.rb +180 -14
- data/lib/processout/discount.rb +69 -19
- data/lib/processout/dunning_action.rb +72 -0
- data/lib/processout/event.rb +15 -0
- data/lib/processout/gateway.rb +30 -0
- data/lib/processout/gateway_configuration.rb +90 -0
- data/lib/processout/gateway_request.rb +26 -0
- data/lib/processout/invoice.rb +119 -62
- data/lib/processout/invoice_detail.rb +20 -0
- data/lib/processout/networking/request.rb +1 -2
- data/lib/processout/plan.rb +15 -0
- data/lib/processout/product.rb +15 -0
- data/lib/processout/project.rb +100 -0
- data/lib/processout/refund.rb +32 -7
- data/lib/processout/subscription.rb +267 -117
- data/lib/processout/token.rb +62 -2
- data/lib/processout/transaction.rb +159 -0
- data/lib/processout/transaction_operation.rb +248 -0
- data/lib/processout/version.rb +1 -1
- data/lib/processout/webhook.rb +30 -0
- data/lib/processout/webhook_endpoint.rb +135 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e1163e73bcea9ce6653eba757252dafedca08f
|
4
|
+
data.tar.gz: 36553ed290dab6dedd47e7a5863b6f4e0722d687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad70b245a3d7d82da6777f23863a81cfa2468c08b64a729c7d4ebeda8320881b724635ec5edcc0f44b797687798fb4a1784fb8d387a4b590e082726481b2e57
|
7
|
+
data.tar.gz: 6c55f645cb87d5433f5a26184d912a7606a3dcc2775aa6d7390d45e30537ae5a6a5169a6052a1fe407ccfe914ac659cc81564f1ab81a093315562835bfa6d696
|
data/lib/processout.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require "processout/version"
|
2
|
+
require "processout/gateway_request"
|
2
3
|
require "processout/activity"
|
4
|
+
require "processout/addon"
|
5
|
+
require "processout/api_request"
|
6
|
+
require "processout/api_version"
|
3
7
|
require "processout/authorization_request"
|
4
8
|
require "processout/card"
|
5
9
|
require "processout/card_information"
|
@@ -13,13 +17,16 @@ require "processout/gateway_configuration"
|
|
13
17
|
require "processout/invoice"
|
14
18
|
require "processout/invoice_detail"
|
15
19
|
require "processout/customer_action"
|
20
|
+
require "processout/dunning_action"
|
16
21
|
require "processout/plan"
|
17
22
|
require "processout/product"
|
18
23
|
require "processout/project"
|
19
24
|
require "processout/refund"
|
20
25
|
require "processout/subscription"
|
21
26
|
require "processout/transaction"
|
27
|
+
require "processout/transaction_operation"
|
22
28
|
require "processout/webhook"
|
29
|
+
require "processout/webhook_endpoint"
|
23
30
|
|
24
31
|
module ProcessOut
|
25
32
|
class Client
|
@@ -37,6 +44,21 @@ module ProcessOut
|
|
37
44
|
obj = Activity.new(self, data)
|
38
45
|
end
|
39
46
|
|
47
|
+
# Create a new Addon instance
|
48
|
+
def addon(data = {})
|
49
|
+
obj = Addon.new(self, data)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Create a new APIRequest instance
|
53
|
+
def api_request(data = {})
|
54
|
+
obj = APIRequest.new(self, data)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Create a new APIVersion instance
|
58
|
+
def api_version(data = {})
|
59
|
+
obj = APIVersion.new(self, data)
|
60
|
+
end
|
61
|
+
|
40
62
|
# Create a new AuthorizationRequest instance
|
41
63
|
def authorization_request(data = {})
|
42
64
|
obj = AuthorizationRequest.new(self, data)
|
@@ -102,6 +124,11 @@ module ProcessOut
|
|
102
124
|
obj = CustomerAction.new(self, data)
|
103
125
|
end
|
104
126
|
|
127
|
+
# Create a new DunningAction instance
|
128
|
+
def dunning_action(data = {})
|
129
|
+
obj = DunningAction.new(self, data)
|
130
|
+
end
|
131
|
+
|
105
132
|
# Create a new Plan instance
|
106
133
|
def plan(data = {})
|
107
134
|
obj = Plan.new(self, data)
|
@@ -132,11 +159,21 @@ module ProcessOut
|
|
132
159
|
obj = Transaction.new(self, data)
|
133
160
|
end
|
134
161
|
|
162
|
+
# Create a new TransactionOperation instance
|
163
|
+
def transaction_operation(data = {})
|
164
|
+
obj = TransactionOperation.new(self, data)
|
165
|
+
end
|
166
|
+
|
135
167
|
# Create a new Webhook instance
|
136
168
|
def webhook(data = {})
|
137
169
|
obj = Webhook.new(self, data)
|
138
170
|
end
|
139
171
|
|
172
|
+
# Create a new WebhookEndpoint instance
|
173
|
+
def webhook_endpoint(data = {})
|
174
|
+
obj = WebhookEndpoint.new(self, data)
|
175
|
+
end
|
176
|
+
|
140
177
|
|
141
178
|
end
|
142
179
|
end
|
data/lib/processout/activity.rb
CHANGED
@@ -9,6 +9,7 @@ module ProcessOut
|
|
9
9
|
|
10
10
|
attr_reader :id
|
11
11
|
attr_reader :project
|
12
|
+
attr_reader :project_id
|
12
13
|
attr_reader :title
|
13
14
|
attr_reader :content
|
14
15
|
attr_reader :level
|
@@ -20,6 +21,11 @@ module ProcessOut
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def project=(val)
|
24
|
+
if val.nil?
|
25
|
+
@project = val
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
23
29
|
if val.instance_of? Project
|
24
30
|
@project = val
|
25
31
|
else
|
@@ -30,6 +36,10 @@ module ProcessOut
|
|
30
36
|
|
31
37
|
end
|
32
38
|
|
39
|
+
def project_id=(val)
|
40
|
+
@project_id = val
|
41
|
+
end
|
42
|
+
|
33
43
|
def title=(val)
|
34
44
|
@title = val
|
35
45
|
end
|
@@ -56,6 +66,7 @@ module ProcessOut
|
|
56
66
|
|
57
67
|
self.id = data.fetch(:id, nil)
|
58
68
|
self.project = data.fetch(:project, nil)
|
69
|
+
self.project_id = data.fetch(:project_id, nil)
|
59
70
|
self.title = data.fetch(:title, nil)
|
60
71
|
self.content = data.fetch(:content, nil)
|
61
72
|
self.level = data.fetch(:level, nil)
|
@@ -81,6 +92,9 @@ module ProcessOut
|
|
81
92
|
if data.include? "project"
|
82
93
|
self.project = data["project"]
|
83
94
|
end
|
95
|
+
if data.include? "project_id"
|
96
|
+
self.project_id = data["project_id"]
|
97
|
+
end
|
84
98
|
if data.include? "title"
|
85
99
|
self.title = data["title"]
|
86
100
|
end
|
@@ -106,6 +120,7 @@ module ProcessOut
|
|
106
120
|
end
|
107
121
|
self.id = data.fetch(:id, self.id)
|
108
122
|
self.project = data.fetch(:project, self.project)
|
123
|
+
self.project_id = data.fetch(:project_id, self.project_id)
|
109
124
|
self.title = data.fetch(:title, self.title)
|
110
125
|
self.content = data.fetch(:content, self.content)
|
111
126
|
self.level = data.fetch(:level, self.level)
|
@@ -0,0 +1,352 @@
|
|
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 Addon
|
9
|
+
|
10
|
+
attr_reader :id
|
11
|
+
attr_reader :project
|
12
|
+
attr_reader :project_id
|
13
|
+
attr_reader :subscription
|
14
|
+
attr_reader :subscription_id
|
15
|
+
attr_reader :plan
|
16
|
+
attr_reader :plan_id
|
17
|
+
attr_reader :type
|
18
|
+
attr_reader :name
|
19
|
+
attr_reader :amount
|
20
|
+
attr_reader :quantity
|
21
|
+
attr_reader :metadata
|
22
|
+
attr_reader :sandbox
|
23
|
+
attr_reader :created_at
|
24
|
+
|
25
|
+
|
26
|
+
def id=(val)
|
27
|
+
@id = val
|
28
|
+
end
|
29
|
+
|
30
|
+
def project=(val)
|
31
|
+
if val.nil?
|
32
|
+
@project = val
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
if val.instance_of? Project
|
37
|
+
@project = val
|
38
|
+
else
|
39
|
+
obj = Project.new(@client)
|
40
|
+
obj.fill_with_data(val)
|
41
|
+
@project = obj
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def project_id=(val)
|
47
|
+
@project_id = val
|
48
|
+
end
|
49
|
+
|
50
|
+
def subscription=(val)
|
51
|
+
if val.nil?
|
52
|
+
@subscription = val
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
if val.instance_of? Subscription
|
57
|
+
@subscription = val
|
58
|
+
else
|
59
|
+
obj = Subscription.new(@client)
|
60
|
+
obj.fill_with_data(val)
|
61
|
+
@subscription = obj
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def subscription_id=(val)
|
67
|
+
@subscription_id = val
|
68
|
+
end
|
69
|
+
|
70
|
+
def plan=(val)
|
71
|
+
if val.nil?
|
72
|
+
@plan = val
|
73
|
+
return
|
74
|
+
end
|
75
|
+
|
76
|
+
if val.instance_of? Plan
|
77
|
+
@plan = val
|
78
|
+
else
|
79
|
+
obj = Plan.new(@client)
|
80
|
+
obj.fill_with_data(val)
|
81
|
+
@plan = obj
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
def plan_id=(val)
|
87
|
+
@plan_id = val
|
88
|
+
end
|
89
|
+
|
90
|
+
def type=(val)
|
91
|
+
@type = val
|
92
|
+
end
|
93
|
+
|
94
|
+
def name=(val)
|
95
|
+
@name = val
|
96
|
+
end
|
97
|
+
|
98
|
+
def amount=(val)
|
99
|
+
@amount = val
|
100
|
+
end
|
101
|
+
|
102
|
+
def quantity=(val)
|
103
|
+
@quantity = val
|
104
|
+
end
|
105
|
+
|
106
|
+
def metadata=(val)
|
107
|
+
@metadata = val
|
108
|
+
end
|
109
|
+
|
110
|
+
def sandbox=(val)
|
111
|
+
@sandbox = val
|
112
|
+
end
|
113
|
+
|
114
|
+
def created_at=(val)
|
115
|
+
@created_at = val
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
# Initializes the Addon object
|
120
|
+
# Params:
|
121
|
+
# +client+:: +ProcessOut+ client instance
|
122
|
+
# +data+:: data that can be used to fill the object
|
123
|
+
def initialize(client, data = {})
|
124
|
+
@client = client
|
125
|
+
|
126
|
+
self.id = data.fetch(:id, nil)
|
127
|
+
self.project = data.fetch(:project, nil)
|
128
|
+
self.project_id = data.fetch(:project_id, nil)
|
129
|
+
self.subscription = data.fetch(:subscription, nil)
|
130
|
+
self.subscription_id = data.fetch(:subscription_id, nil)
|
131
|
+
self.plan = data.fetch(:plan, nil)
|
132
|
+
self.plan_id = data.fetch(:plan_id, nil)
|
133
|
+
self.type = data.fetch(:type, nil)
|
134
|
+
self.name = data.fetch(:name, nil)
|
135
|
+
self.amount = data.fetch(:amount, nil)
|
136
|
+
self.quantity = data.fetch(:quantity, nil)
|
137
|
+
self.metadata = data.fetch(:metadata, nil)
|
138
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
139
|
+
self.created_at = data.fetch(:created_at, nil)
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
# Create a new Addon using the current client
|
144
|
+
def new(data = {})
|
145
|
+
Addon.new(@client, data)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Fills the object with data coming from the API
|
149
|
+
# Params:
|
150
|
+
# +data+:: +Hash+ of data coming from the API
|
151
|
+
def fill_with_data(data)
|
152
|
+
if data.nil?
|
153
|
+
return self
|
154
|
+
end
|
155
|
+
if data.include? "id"
|
156
|
+
self.id = data["id"]
|
157
|
+
end
|
158
|
+
if data.include? "project"
|
159
|
+
self.project = data["project"]
|
160
|
+
end
|
161
|
+
if data.include? "project_id"
|
162
|
+
self.project_id = data["project_id"]
|
163
|
+
end
|
164
|
+
if data.include? "subscription"
|
165
|
+
self.subscription = data["subscription"]
|
166
|
+
end
|
167
|
+
if data.include? "subscription_id"
|
168
|
+
self.subscription_id = data["subscription_id"]
|
169
|
+
end
|
170
|
+
if data.include? "plan"
|
171
|
+
self.plan = data["plan"]
|
172
|
+
end
|
173
|
+
if data.include? "plan_id"
|
174
|
+
self.plan_id = data["plan_id"]
|
175
|
+
end
|
176
|
+
if data.include? "type"
|
177
|
+
self.type = data["type"]
|
178
|
+
end
|
179
|
+
if data.include? "name"
|
180
|
+
self.name = data["name"]
|
181
|
+
end
|
182
|
+
if data.include? "amount"
|
183
|
+
self.amount = data["amount"]
|
184
|
+
end
|
185
|
+
if data.include? "quantity"
|
186
|
+
self.quantity = data["quantity"]
|
187
|
+
end
|
188
|
+
if data.include? "metadata"
|
189
|
+
self.metadata = data["metadata"]
|
190
|
+
end
|
191
|
+
if data.include? "sandbox"
|
192
|
+
self.sandbox = data["sandbox"]
|
193
|
+
end
|
194
|
+
if data.include? "created_at"
|
195
|
+
self.created_at = data["created_at"]
|
196
|
+
end
|
197
|
+
|
198
|
+
self
|
199
|
+
end
|
200
|
+
|
201
|
+
# Prefills the object with the data passed as parameters
|
202
|
+
# Params:
|
203
|
+
# +data+:: +Hash+ of data
|
204
|
+
def prefill(data)
|
205
|
+
if data.nil?
|
206
|
+
return self
|
207
|
+
end
|
208
|
+
self.id = data.fetch(:id, self.id)
|
209
|
+
self.project = data.fetch(:project, self.project)
|
210
|
+
self.project_id = data.fetch(:project_id, self.project_id)
|
211
|
+
self.subscription = data.fetch(:subscription, self.subscription)
|
212
|
+
self.subscription_id = data.fetch(:subscription_id, self.subscription_id)
|
213
|
+
self.plan = data.fetch(:plan, self.plan)
|
214
|
+
self.plan_id = data.fetch(:plan_id, self.plan_id)
|
215
|
+
self.type = data.fetch(:type, self.type)
|
216
|
+
self.name = data.fetch(:name, self.name)
|
217
|
+
self.amount = data.fetch(:amount, self.amount)
|
218
|
+
self.quantity = data.fetch(:quantity, self.quantity)
|
219
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
220
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
221
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
222
|
+
|
223
|
+
self
|
224
|
+
end
|
225
|
+
|
226
|
+
# Apply a new addon to the given subscription ID.
|
227
|
+
# Params:
|
228
|
+
# +subscription_id+:: ID of the subscription
|
229
|
+
# +options+:: +Hash+ of options
|
230
|
+
def apply(subscription_id, options = {})
|
231
|
+
self.prefill(options)
|
232
|
+
|
233
|
+
request = Request.new(@client)
|
234
|
+
path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons"
|
235
|
+
data = {
|
236
|
+
"plan_id" => @plan_id,
|
237
|
+
"type" => @type,
|
238
|
+
"name" => @name,
|
239
|
+
"amount" => @amount,
|
240
|
+
"quantity" => @quantity,
|
241
|
+
"metadata" => @metadata,
|
242
|
+
"prorate" => options.fetch(:prorate, nil),
|
243
|
+
"proration_date" => options.fetch(:proration_date, nil),
|
244
|
+
"preview" => options.fetch(:preview, nil)
|
245
|
+
}
|
246
|
+
|
247
|
+
response = Response.new(request.post(path, data, options))
|
248
|
+
return_values = Array.new
|
249
|
+
|
250
|
+
body = response.body
|
251
|
+
body = body["addon"]
|
252
|
+
|
253
|
+
|
254
|
+
return_values.push(self.fill_with_data(body))
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
return_values[0]
|
259
|
+
end
|
260
|
+
|
261
|
+
# Find a subscription's addon by its ID.
|
262
|
+
# Params:
|
263
|
+
# +subscription_id+:: ID of the subscription on which the addon was applied
|
264
|
+
# +addon_id+:: ID of the addon
|
265
|
+
# +options+:: +Hash+ of options
|
266
|
+
def find(subscription_id, addon_id, options = {})
|
267
|
+
self.prefill(options)
|
268
|
+
|
269
|
+
request = Request.new(@client)
|
270
|
+
path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons/" + CGI.escape(addon_id) + ""
|
271
|
+
data = {
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
response = Response.new(request.get(path, data, options))
|
276
|
+
return_values = Array.new
|
277
|
+
|
278
|
+
body = response.body
|
279
|
+
body = body["addon"]
|
280
|
+
|
281
|
+
|
282
|
+
obj = Addon.new(@client)
|
283
|
+
return_values.push(obj.fill_with_data(body))
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
return_values[0]
|
288
|
+
end
|
289
|
+
|
290
|
+
# Save the updated addon attributes.
|
291
|
+
# Params:
|
292
|
+
# +options+:: +Hash+ of options
|
293
|
+
def save(options = {})
|
294
|
+
self.prefill(options)
|
295
|
+
|
296
|
+
request = Request.new(@client)
|
297
|
+
path = "/subscriptions/" + CGI.escape(@subscription_id) + "/addons/" + CGI.escape(@id) + ""
|
298
|
+
data = {
|
299
|
+
"plan_id" => @plan_id,
|
300
|
+
"type" => @type,
|
301
|
+
"name" => @name,
|
302
|
+
"amount" => @amount,
|
303
|
+
"quantity" => @quantity,
|
304
|
+
"metadata" => @metadata,
|
305
|
+
"prorate" => options.fetch(:prorate, nil),
|
306
|
+
"proration_date" => options.fetch(:proration_date, nil),
|
307
|
+
"preview" => options.fetch(:preview, nil),
|
308
|
+
"increment_quantity_by" => options.fetch(:increment_quantity_by, nil)
|
309
|
+
}
|
310
|
+
|
311
|
+
response = Response.new(request.put(path, data, options))
|
312
|
+
return_values = Array.new
|
313
|
+
|
314
|
+
body = response.body
|
315
|
+
body = body["addon"]
|
316
|
+
|
317
|
+
|
318
|
+
return_values.push(self.fill_with_data(body))
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
return_values[0]
|
323
|
+
end
|
324
|
+
|
325
|
+
# Remove an addon applied to a subscription.
|
326
|
+
# Params:
|
327
|
+
# +subscription_id+:: ID of the subscription on which the addon was applied
|
328
|
+
# +addon_id+:: ID of the addon
|
329
|
+
# +options+:: +Hash+ of options
|
330
|
+
def remove(subscription_id, addon_id, options = {})
|
331
|
+
self.prefill(options)
|
332
|
+
|
333
|
+
request = Request.new(@client)
|
334
|
+
path = "/subscriptions/" + CGI.escape(subscription_id) + "/addons/" + CGI.escape(addon_id) + ""
|
335
|
+
data = {
|
336
|
+
"prorate" => options.fetch(:prorate, nil),
|
337
|
+
"proration_date" => options.fetch(:proration_date, nil),
|
338
|
+
"preview" => options.fetch(:preview, nil)
|
339
|
+
}
|
340
|
+
|
341
|
+
response = Response.new(request.delete(path, data, options))
|
342
|
+
return_values = Array.new
|
343
|
+
|
344
|
+
return_values.push(response.success)
|
345
|
+
|
346
|
+
|
347
|
+
return_values[0]
|
348
|
+
end
|
349
|
+
|
350
|
+
|
351
|
+
end
|
352
|
+
end
|