processout 2.19.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +4 -67
- data/.gitignore +0 -52
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/Dockerfile +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -21
- data/Makefile +0 -4
- data/README.md +0 -12
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/processout/activity.rb +0 -206
- data/lib/processout/addon.rb +0 -401
- data/lib/processout/alternative_merchant_certificate.rb +0 -94
- data/lib/processout/api_request.rb +0 -295
- data/lib/processout/api_version.rb +0 -92
- data/lib/processout/apple_pay_alternative_merchant_certificates.rb +0 -110
- data/lib/processout/balance.rb +0 -81
- data/lib/processout/balances.rb +0 -111
- data/lib/processout/card.rb +0 -503
- data/lib/processout/card_information.rb +0 -164
- data/lib/processout/coupon.rb +0 -352
- data/lib/processout/customer.rb +0 -755
- data/lib/processout/customer_action.rb +0 -81
- data/lib/processout/discount.rb +0 -360
- data/lib/processout/dunning_action.rb +0 -81
- data/lib/processout/errors/authentication_error.rb +0 -9
- data/lib/processout/errors/generic_error.rb +0 -9
- data/lib/processout/errors/internal_error.rb +0 -9
- data/lib/processout/errors/notfound_error.rb +0 -9
- data/lib/processout/errors/validation_error.rb +0 -9
- data/lib/processout/event.rb +0 -237
- data/lib/processout/gateway.rb +0 -210
- data/lib/processout/gateway_configuration.rb +0 -346
- data/lib/processout/gateway_request.rb +0 -26
- data/lib/processout/invoice.rb +0 -945
- data/lib/processout/invoice_detail.rb +0 -235
- data/lib/processout/invoice_device.rb +0 -92
- data/lib/processout/invoice_external_fraud_tools.rb +0 -70
- data/lib/processout/invoice_risk.rb +0 -81
- data/lib/processout/invoice_shipping.rb +0 -191
- data/lib/processout/invoice_tax.rb +0 -81
- data/lib/processout/networking/request.rb +0 -102
- data/lib/processout/networking/response.rb +0 -67
- data/lib/processout/payment_data_network_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_authentication.rb +0 -70
- data/lib/processout/payment_data_three_ds_request.rb +0 -103
- data/lib/processout/payout.rb +0 -379
- data/lib/processout/payout_item.rb +0 -238
- data/lib/processout/plan.rb +0 -368
- data/lib/processout/product.rb +0 -368
- data/lib/processout/project.rb +0 -353
- data/lib/processout/refund.rb +0 -277
- data/lib/processout/subscription.rb +0 -910
- data/lib/processout/three_ds.rb +0 -158
- data/lib/processout/token.rb +0 -493
- data/lib/processout/transaction.rb +0 -905
- data/lib/processout/transaction_operation.rb +0 -418
- data/lib/processout/version.rb +0 -3
- data/lib/processout/webhook.rb +0 -237
- data/lib/processout/webhook_endpoint.rb +0 -149
- data/lib/processout.rb +0 -263
- data/processout.gemspec +0 -26
data/lib/processout/product.rb
DELETED
@@ -1,368 +0,0 @@
|
|
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 Product
|
10
|
-
|
11
|
-
attr_reader :id
|
12
|
-
attr_reader :project
|
13
|
-
attr_reader :project_id
|
14
|
-
attr_reader :url
|
15
|
-
attr_reader :name
|
16
|
-
attr_reader :amount
|
17
|
-
attr_reader :currency
|
18
|
-
attr_reader :metadata
|
19
|
-
attr_reader :return_url
|
20
|
-
attr_reader :cancel_url
|
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.nil?
|
31
|
-
@project = val
|
32
|
-
return
|
33
|
-
end
|
34
|
-
|
35
|
-
if val.instance_of? Project
|
36
|
-
@project = val
|
37
|
-
else
|
38
|
-
obj = Project.new(@client)
|
39
|
-
obj.fill_with_data(val)
|
40
|
-
@project = obj
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def project_id=(val)
|
46
|
-
@project_id = val
|
47
|
-
end
|
48
|
-
|
49
|
-
def url=(val)
|
50
|
-
@url = val
|
51
|
-
end
|
52
|
-
|
53
|
-
def name=(val)
|
54
|
-
@name = val
|
55
|
-
end
|
56
|
-
|
57
|
-
def amount=(val)
|
58
|
-
@amount = val
|
59
|
-
end
|
60
|
-
|
61
|
-
def currency=(val)
|
62
|
-
@currency = val
|
63
|
-
end
|
64
|
-
|
65
|
-
def metadata=(val)
|
66
|
-
@metadata = val
|
67
|
-
end
|
68
|
-
|
69
|
-
def return_url=(val)
|
70
|
-
@return_url = val
|
71
|
-
end
|
72
|
-
|
73
|
-
def cancel_url=(val)
|
74
|
-
@cancel_url = val
|
75
|
-
end
|
76
|
-
|
77
|
-
def sandbox=(val)
|
78
|
-
@sandbox = val
|
79
|
-
end
|
80
|
-
|
81
|
-
def created_at=(val)
|
82
|
-
@created_at = val
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
# Initializes the Product object
|
87
|
-
# Params:
|
88
|
-
# +client+:: +ProcessOut+ client instance
|
89
|
-
# +data+:: data that can be used to fill the object
|
90
|
-
def initialize(client, data = {})
|
91
|
-
@client = client
|
92
|
-
|
93
|
-
self.id = data.fetch(:id, nil)
|
94
|
-
self.project = data.fetch(:project, nil)
|
95
|
-
self.project_id = data.fetch(:project_id, nil)
|
96
|
-
self.url = data.fetch(:url, nil)
|
97
|
-
self.name = data.fetch(:name, nil)
|
98
|
-
self.amount = data.fetch(:amount, nil)
|
99
|
-
self.currency = data.fetch(:currency, nil)
|
100
|
-
self.metadata = data.fetch(:metadata, nil)
|
101
|
-
self.return_url = data.fetch(:return_url, nil)
|
102
|
-
self.cancel_url = data.fetch(:cancel_url, nil)
|
103
|
-
self.sandbox = data.fetch(:sandbox, nil)
|
104
|
-
self.created_at = data.fetch(:created_at, nil)
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
# Create a new Product using the current client
|
109
|
-
def new(data = {})
|
110
|
-
Product.new(@client, data)
|
111
|
-
end
|
112
|
-
|
113
|
-
# Overrides the JSON marshaller to only send the fields we want
|
114
|
-
def to_json(options)
|
115
|
-
{
|
116
|
-
"id": self.id,
|
117
|
-
"project": self.project,
|
118
|
-
"project_id": self.project_id,
|
119
|
-
"url": self.url,
|
120
|
-
"name": self.name,
|
121
|
-
"amount": self.amount,
|
122
|
-
"currency": self.currency,
|
123
|
-
"metadata": self.metadata,
|
124
|
-
"return_url": self.return_url,
|
125
|
-
"cancel_url": self.cancel_url,
|
126
|
-
"sandbox": self.sandbox,
|
127
|
-
"created_at": self.created_at,
|
128
|
-
}.to_json
|
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.nil?
|
136
|
-
return self
|
137
|
-
end
|
138
|
-
if data.include? "id"
|
139
|
-
self.id = data["id"]
|
140
|
-
end
|
141
|
-
if data.include? "project"
|
142
|
-
self.project = data["project"]
|
143
|
-
end
|
144
|
-
if data.include? "project_id"
|
145
|
-
self.project_id = data["project_id"]
|
146
|
-
end
|
147
|
-
if data.include? "url"
|
148
|
-
self.url = data["url"]
|
149
|
-
end
|
150
|
-
if data.include? "name"
|
151
|
-
self.name = data["name"]
|
152
|
-
end
|
153
|
-
if data.include? "amount"
|
154
|
-
self.amount = data["amount"]
|
155
|
-
end
|
156
|
-
if data.include? "currency"
|
157
|
-
self.currency = data["currency"]
|
158
|
-
end
|
159
|
-
if data.include? "metadata"
|
160
|
-
self.metadata = data["metadata"]
|
161
|
-
end
|
162
|
-
if data.include? "return_url"
|
163
|
-
self.return_url = data["return_url"]
|
164
|
-
end
|
165
|
-
if data.include? "cancel_url"
|
166
|
-
self.cancel_url = data["cancel_url"]
|
167
|
-
end
|
168
|
-
if data.include? "sandbox"
|
169
|
-
self.sandbox = data["sandbox"]
|
170
|
-
end
|
171
|
-
if data.include? "created_at"
|
172
|
-
self.created_at = data["created_at"]
|
173
|
-
end
|
174
|
-
|
175
|
-
self
|
176
|
-
end
|
177
|
-
|
178
|
-
# Prefills the object with the data passed as parameters
|
179
|
-
# Params:
|
180
|
-
# +data+:: +Hash+ of data
|
181
|
-
def prefill(data)
|
182
|
-
if data.nil?
|
183
|
-
return self
|
184
|
-
end
|
185
|
-
self.id = data.fetch(:id, self.id)
|
186
|
-
self.project = data.fetch(:project, self.project)
|
187
|
-
self.project_id = data.fetch(:project_id, self.project_id)
|
188
|
-
self.url = data.fetch(:url, self.url)
|
189
|
-
self.name = data.fetch(:name, self.name)
|
190
|
-
self.amount = data.fetch(:amount, self.amount)
|
191
|
-
self.currency = data.fetch(:currency, self.currency)
|
192
|
-
self.metadata = data.fetch(:metadata, self.metadata)
|
193
|
-
self.return_url = data.fetch(:return_url, self.return_url)
|
194
|
-
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
195
|
-
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
196
|
-
self.created_at = data.fetch(:created_at, self.created_at)
|
197
|
-
|
198
|
-
self
|
199
|
-
end
|
200
|
-
|
201
|
-
# Create a new invoice from the product.
|
202
|
-
# Params:
|
203
|
-
# +options+:: +Hash+ of options
|
204
|
-
def create_invoice(options = {})
|
205
|
-
self.prefill(options)
|
206
|
-
|
207
|
-
request = Request.new(@client)
|
208
|
-
path = "/products/" + CGI.escape(@id) + "/invoices"
|
209
|
-
data = {
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
response = Response.new(request.post(path, data, options))
|
214
|
-
return_values = Array.new
|
215
|
-
|
216
|
-
body = response.body
|
217
|
-
body = body["invoice"]
|
218
|
-
invoice = Invoice.new(@client)
|
219
|
-
return_values.push(invoice.fill_with_data(body))
|
220
|
-
|
221
|
-
|
222
|
-
return_values[0]
|
223
|
-
end
|
224
|
-
|
225
|
-
# Get all the products.
|
226
|
-
# Params:
|
227
|
-
# +options+:: +Hash+ of options
|
228
|
-
def all(options = {})
|
229
|
-
self.prefill(options)
|
230
|
-
|
231
|
-
request = Request.new(@client)
|
232
|
-
path = "/products"
|
233
|
-
data = {
|
234
|
-
|
235
|
-
}
|
236
|
-
|
237
|
-
response = Response.new(request.get(path, data, options))
|
238
|
-
return_values = Array.new
|
239
|
-
|
240
|
-
a = Array.new
|
241
|
-
body = response.body
|
242
|
-
for v in body['products']
|
243
|
-
tmp = Product.new(@client)
|
244
|
-
tmp.fill_with_data(v)
|
245
|
-
a.push(tmp)
|
246
|
-
end
|
247
|
-
|
248
|
-
return_values.push(a)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
return_values[0]
|
253
|
-
end
|
254
|
-
|
255
|
-
# Create a new product.
|
256
|
-
# Params:
|
257
|
-
# +options+:: +Hash+ of options
|
258
|
-
def create(options = {})
|
259
|
-
self.prefill(options)
|
260
|
-
|
261
|
-
request = Request.new(@client)
|
262
|
-
path = "/products"
|
263
|
-
data = {
|
264
|
-
"name" => @name,
|
265
|
-
"amount" => @amount,
|
266
|
-
"currency" => @currency,
|
267
|
-
"metadata" => @metadata,
|
268
|
-
"return_url" => @return_url,
|
269
|
-
"cancel_url" => @cancel_url
|
270
|
-
}
|
271
|
-
|
272
|
-
response = Response.new(request.post(path, data, options))
|
273
|
-
return_values = Array.new
|
274
|
-
|
275
|
-
body = response.body
|
276
|
-
body = body["product"]
|
277
|
-
|
278
|
-
|
279
|
-
return_values.push(self.fill_with_data(body))
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
return_values[0]
|
284
|
-
end
|
285
|
-
|
286
|
-
# Find a product by its ID.
|
287
|
-
# Params:
|
288
|
-
# +product_id+:: ID of the product
|
289
|
-
# +options+:: +Hash+ of options
|
290
|
-
def find(product_id, options = {})
|
291
|
-
self.prefill(options)
|
292
|
-
|
293
|
-
request = Request.new(@client)
|
294
|
-
path = "/products/" + CGI.escape(product_id) + ""
|
295
|
-
data = {
|
296
|
-
|
297
|
-
}
|
298
|
-
|
299
|
-
response = Response.new(request.get(path, data, options))
|
300
|
-
return_values = Array.new
|
301
|
-
|
302
|
-
body = response.body
|
303
|
-
body = body["product"]
|
304
|
-
|
305
|
-
|
306
|
-
obj = Product.new(@client)
|
307
|
-
return_values.push(obj.fill_with_data(body))
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
return_values[0]
|
312
|
-
end
|
313
|
-
|
314
|
-
# Save the updated product attributes.
|
315
|
-
# Params:
|
316
|
-
# +options+:: +Hash+ of options
|
317
|
-
def save(options = {})
|
318
|
-
self.prefill(options)
|
319
|
-
|
320
|
-
request = Request.new(@client)
|
321
|
-
path = "/products/" + CGI.escape(@id) + ""
|
322
|
-
data = {
|
323
|
-
"name" => @name,
|
324
|
-
"amount" => @amount,
|
325
|
-
"currency" => @currency,
|
326
|
-
"metadata" => @metadata,
|
327
|
-
"return_url" => @return_url,
|
328
|
-
"cancel_url" => @cancel_url
|
329
|
-
}
|
330
|
-
|
331
|
-
response = Response.new(request.put(path, data, options))
|
332
|
-
return_values = Array.new
|
333
|
-
|
334
|
-
body = response.body
|
335
|
-
body = body["product"]
|
336
|
-
|
337
|
-
|
338
|
-
return_values.push(self.fill_with_data(body))
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
return_values[0]
|
343
|
-
end
|
344
|
-
|
345
|
-
# Delete the product.
|
346
|
-
# Params:
|
347
|
-
# +options+:: +Hash+ of options
|
348
|
-
def delete(options = {})
|
349
|
-
self.prefill(options)
|
350
|
-
|
351
|
-
request = Request.new(@client)
|
352
|
-
path = "/products/" + CGI.escape(@id) + ""
|
353
|
-
data = {
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
response = Response.new(request.delete(path, data, options))
|
358
|
-
return_values = Array.new
|
359
|
-
|
360
|
-
return_values.push(response.success)
|
361
|
-
|
362
|
-
|
363
|
-
return_values[0]
|
364
|
-
end
|
365
|
-
|
366
|
-
|
367
|
-
end
|
368
|
-
end
|
data/lib/processout/project.rb
DELETED
@@ -1,353 +0,0 @@
|
|
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 Project
|
10
|
-
|
11
|
-
attr_reader :id
|
12
|
-
attr_reader :supervisor_project
|
13
|
-
attr_reader :supervisor_project_id
|
14
|
-
attr_reader :api_version
|
15
|
-
attr_reader :name
|
16
|
-
attr_reader :logo_url
|
17
|
-
attr_reader :email
|
18
|
-
attr_reader :default_currency
|
19
|
-
attr_reader :private_key
|
20
|
-
attr_reader :dunning_configuration
|
21
|
-
attr_reader :created_at
|
22
|
-
|
23
|
-
|
24
|
-
def id=(val)
|
25
|
-
@id = val
|
26
|
-
end
|
27
|
-
|
28
|
-
def supervisor_project=(val)
|
29
|
-
if val.nil?
|
30
|
-
@supervisor_project = val
|
31
|
-
return
|
32
|
-
end
|
33
|
-
|
34
|
-
if val.instance_of? Project
|
35
|
-
@supervisor_project = val
|
36
|
-
else
|
37
|
-
obj = Project.new(@client)
|
38
|
-
obj.fill_with_data(val)
|
39
|
-
@supervisor_project = obj
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
def supervisor_project_id=(val)
|
45
|
-
@supervisor_project_id = val
|
46
|
-
end
|
47
|
-
|
48
|
-
def api_version=(val)
|
49
|
-
if val.nil?
|
50
|
-
@api_version = val
|
51
|
-
return
|
52
|
-
end
|
53
|
-
|
54
|
-
if val.instance_of? APIVersion
|
55
|
-
@api_version = val
|
56
|
-
else
|
57
|
-
obj = APIVersion.new(@client)
|
58
|
-
obj.fill_with_data(val)
|
59
|
-
@api_version = obj
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def name=(val)
|
65
|
-
@name = val
|
66
|
-
end
|
67
|
-
|
68
|
-
def logo_url=(val)
|
69
|
-
@logo_url = val
|
70
|
-
end
|
71
|
-
|
72
|
-
def email=(val)
|
73
|
-
@email = val
|
74
|
-
end
|
75
|
-
|
76
|
-
def default_currency=(val)
|
77
|
-
@default_currency = val
|
78
|
-
end
|
79
|
-
|
80
|
-
def private_key=(val)
|
81
|
-
@private_key = val
|
82
|
-
end
|
83
|
-
|
84
|
-
def dunning_configuration=(val)
|
85
|
-
if val.nil?
|
86
|
-
@dunning_configuration = []
|
87
|
-
return
|
88
|
-
end
|
89
|
-
|
90
|
-
if val.length > 0 and val[0].instance_of? DunningAction
|
91
|
-
@dunning_configuration = val
|
92
|
-
else
|
93
|
-
l = Array.new
|
94
|
-
for v in val
|
95
|
-
obj = DunningAction.new(@client)
|
96
|
-
obj.fill_with_data(v)
|
97
|
-
l.push(obj)
|
98
|
-
end
|
99
|
-
@dunning_configuration = l
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
def created_at=(val)
|
105
|
-
@created_at = val
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
# Initializes the Project object
|
110
|
-
# Params:
|
111
|
-
# +client+:: +ProcessOut+ client instance
|
112
|
-
# +data+:: data that can be used to fill the object
|
113
|
-
def initialize(client, data = {})
|
114
|
-
@client = client
|
115
|
-
|
116
|
-
self.id = data.fetch(:id, nil)
|
117
|
-
self.supervisor_project = data.fetch(:supervisor_project, nil)
|
118
|
-
self.supervisor_project_id = data.fetch(:supervisor_project_id, nil)
|
119
|
-
self.api_version = data.fetch(:api_version, nil)
|
120
|
-
self.name = data.fetch(:name, nil)
|
121
|
-
self.logo_url = data.fetch(:logo_url, nil)
|
122
|
-
self.email = data.fetch(:email, nil)
|
123
|
-
self.default_currency = data.fetch(:default_currency, nil)
|
124
|
-
self.private_key = data.fetch(:private_key, nil)
|
125
|
-
self.dunning_configuration = data.fetch(:dunning_configuration, nil)
|
126
|
-
self.created_at = data.fetch(:created_at, nil)
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
# Create a new Project using the current client
|
131
|
-
def new(data = {})
|
132
|
-
Project.new(@client, data)
|
133
|
-
end
|
134
|
-
|
135
|
-
# Overrides the JSON marshaller to only send the fields we want
|
136
|
-
def to_json(options)
|
137
|
-
{
|
138
|
-
"id": self.id,
|
139
|
-
"supervisor_project": self.supervisor_project,
|
140
|
-
"supervisor_project_id": self.supervisor_project_id,
|
141
|
-
"api_version": self.api_version,
|
142
|
-
"name": self.name,
|
143
|
-
"logo_url": self.logo_url,
|
144
|
-
"email": self.email,
|
145
|
-
"default_currency": self.default_currency,
|
146
|
-
"private_key": self.private_key,
|
147
|
-
"dunning_configuration": self.dunning_configuration,
|
148
|
-
"created_at": self.created_at,
|
149
|
-
}.to_json
|
150
|
-
end
|
151
|
-
|
152
|
-
# Fills the object with data coming from the API
|
153
|
-
# Params:
|
154
|
-
# +data+:: +Hash+ of data coming from the API
|
155
|
-
def fill_with_data(data)
|
156
|
-
if data.nil?
|
157
|
-
return self
|
158
|
-
end
|
159
|
-
if data.include? "id"
|
160
|
-
self.id = data["id"]
|
161
|
-
end
|
162
|
-
if data.include? "supervisor_project"
|
163
|
-
self.supervisor_project = data["supervisor_project"]
|
164
|
-
end
|
165
|
-
if data.include? "supervisor_project_id"
|
166
|
-
self.supervisor_project_id = data["supervisor_project_id"]
|
167
|
-
end
|
168
|
-
if data.include? "api_version"
|
169
|
-
self.api_version = data["api_version"]
|
170
|
-
end
|
171
|
-
if data.include? "name"
|
172
|
-
self.name = data["name"]
|
173
|
-
end
|
174
|
-
if data.include? "logo_url"
|
175
|
-
self.logo_url = data["logo_url"]
|
176
|
-
end
|
177
|
-
if data.include? "email"
|
178
|
-
self.email = data["email"]
|
179
|
-
end
|
180
|
-
if data.include? "default_currency"
|
181
|
-
self.default_currency = data["default_currency"]
|
182
|
-
end
|
183
|
-
if data.include? "private_key"
|
184
|
-
self.private_key = data["private_key"]
|
185
|
-
end
|
186
|
-
if data.include? "dunning_configuration"
|
187
|
-
self.dunning_configuration = data["dunning_configuration"]
|
188
|
-
end
|
189
|
-
if data.include? "created_at"
|
190
|
-
self.created_at = data["created_at"]
|
191
|
-
end
|
192
|
-
|
193
|
-
self
|
194
|
-
end
|
195
|
-
|
196
|
-
# Prefills the object with the data passed as parameters
|
197
|
-
# Params:
|
198
|
-
# +data+:: +Hash+ of data
|
199
|
-
def prefill(data)
|
200
|
-
if data.nil?
|
201
|
-
return self
|
202
|
-
end
|
203
|
-
self.id = data.fetch(:id, self.id)
|
204
|
-
self.supervisor_project = data.fetch(:supervisor_project, self.supervisor_project)
|
205
|
-
self.supervisor_project_id = data.fetch(:supervisor_project_id, self.supervisor_project_id)
|
206
|
-
self.api_version = data.fetch(:api_version, self.api_version)
|
207
|
-
self.name = data.fetch(:name, self.name)
|
208
|
-
self.logo_url = data.fetch(:logo_url, self.logo_url)
|
209
|
-
self.email = data.fetch(:email, self.email)
|
210
|
-
self.default_currency = data.fetch(:default_currency, self.default_currency)
|
211
|
-
self.private_key = data.fetch(:private_key, self.private_key)
|
212
|
-
self.dunning_configuration = data.fetch(:dunning_configuration, self.dunning_configuration)
|
213
|
-
self.created_at = data.fetch(:created_at, self.created_at)
|
214
|
-
|
215
|
-
self
|
216
|
-
end
|
217
|
-
|
218
|
-
# Fetch the current project information.
|
219
|
-
# Params:
|
220
|
-
# +options+:: +Hash+ of options
|
221
|
-
def fetch(options = {})
|
222
|
-
self.prefill(options)
|
223
|
-
|
224
|
-
request = Request.new(@client)
|
225
|
-
path = "/projects/" + CGI.escape(@id) + ""
|
226
|
-
data = {
|
227
|
-
|
228
|
-
}
|
229
|
-
|
230
|
-
response = Response.new(request.get(path, data, options))
|
231
|
-
return_values = Array.new
|
232
|
-
|
233
|
-
body = response.body
|
234
|
-
body = body["project"]
|
235
|
-
|
236
|
-
|
237
|
-
return_values.push(self.fill_with_data(body))
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
return_values[0]
|
242
|
-
end
|
243
|
-
|
244
|
-
# Save the updated project's attributes.
|
245
|
-
# Params:
|
246
|
-
# +options+:: +Hash+ of options
|
247
|
-
def save(options = {})
|
248
|
-
self.prefill(options)
|
249
|
-
|
250
|
-
request = Request.new(@client)
|
251
|
-
path = "/projects/" + CGI.escape(@id) + ""
|
252
|
-
data = {
|
253
|
-
|
254
|
-
}
|
255
|
-
|
256
|
-
response = Response.new(request.put(path, data, options))
|
257
|
-
return_values = Array.new
|
258
|
-
|
259
|
-
body = response.body
|
260
|
-
body = body["project"]
|
261
|
-
|
262
|
-
|
263
|
-
return_values.push(self.fill_with_data(body))
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
return_values[0]
|
268
|
-
end
|
269
|
-
|
270
|
-
# Delete the project. Be careful! Executing this request will prevent any further interaction with the API that uses this project.
|
271
|
-
# Params:
|
272
|
-
# +options+:: +Hash+ of options
|
273
|
-
def delete(options = {})
|
274
|
-
self.prefill(options)
|
275
|
-
|
276
|
-
request = Request.new(@client)
|
277
|
-
path = "/projects/{project_id}"
|
278
|
-
data = {
|
279
|
-
|
280
|
-
}
|
281
|
-
|
282
|
-
response = Response.new(request.delete(path, data, options))
|
283
|
-
return_values = Array.new
|
284
|
-
|
285
|
-
return_values.push(response.success)
|
286
|
-
|
287
|
-
|
288
|
-
return_values[0]
|
289
|
-
end
|
290
|
-
|
291
|
-
# Get all the supervised projects.
|
292
|
-
# Params:
|
293
|
-
# +options+:: +Hash+ of options
|
294
|
-
def fetch_supervised(options = {})
|
295
|
-
self.prefill(options)
|
296
|
-
|
297
|
-
request = Request.new(@client)
|
298
|
-
path = "/supervised-projects"
|
299
|
-
data = {
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
response = Response.new(request.get(path, data, options))
|
304
|
-
return_values = Array.new
|
305
|
-
|
306
|
-
a = Array.new
|
307
|
-
body = response.body
|
308
|
-
for v in body['projects']
|
309
|
-
tmp = Project.new(@client)
|
310
|
-
tmp.fill_with_data(v)
|
311
|
-
a.push(tmp)
|
312
|
-
end
|
313
|
-
|
314
|
-
return_values.push(a)
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
return_values[0]
|
319
|
-
end
|
320
|
-
|
321
|
-
# Create a new supervised project.
|
322
|
-
# Params:
|
323
|
-
# +options+:: +Hash+ of options
|
324
|
-
def create_supervised(options = {})
|
325
|
-
self.prefill(options)
|
326
|
-
|
327
|
-
request = Request.new(@client)
|
328
|
-
path = "/supervised-projects"
|
329
|
-
data = {
|
330
|
-
"id" => @id,
|
331
|
-
"name" => @name,
|
332
|
-
"default_currency" => @default_currency,
|
333
|
-
"dunning_configuration" => @dunning_configuration,
|
334
|
-
"applepay_settings" => options.fetch(:applepay_settings, nil)
|
335
|
-
}
|
336
|
-
|
337
|
-
response = Response.new(request.post(path, data, options))
|
338
|
-
return_values = Array.new
|
339
|
-
|
340
|
-
body = response.body
|
341
|
-
body = body["project"]
|
342
|
-
|
343
|
-
|
344
|
-
return_values.push(self.fill_with_data(body))
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
return_values[0]
|
349
|
-
end
|
350
|
-
|
351
|
-
|
352
|
-
end
|
353
|
-
end
|