processout 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/processout/activity.rb +30 -6
- data/lib/processout/authorization_request.rb +44 -22
- data/lib/processout/card.rb +40 -13
- data/lib/processout/coupon.rb +50 -13
- data/lib/processout/customer.rb +66 -25
- data/lib/processout/customer_action.rb +18 -2
- data/lib/processout/discount.rb +38 -9
- data/lib/processout/event.rb +32 -6
- data/lib/processout/gateway.rb +30 -8
- data/lib/processout/gateway_configuration.rb +24 -5
- data/lib/processout/invoice.rb +66 -16
- data/lib/processout/plan.rb +50 -14
- data/lib/processout/product.rb +52 -13
- data/lib/processout/project.rb +26 -5
- data/lib/processout/refund.rb +34 -8
- data/lib/processout/subscription.rb +107 -37
- data/lib/processout/token.rb +38 -8
- data/lib/processout/transaction.rb +56 -17
- data/lib/processout/version.rb +1 -1
- data/lib/processout/webhook.rb +38 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b2404eb8a87ec21152d52ba6524d0fedc261bb
|
4
|
+
data.tar.gz: 6cbfdd364e7b5686184619ad13cccef9838952ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f529dc34677098ecb3a8b33bdf4ee37fc5baffef55ddbe776b778892ffc8ba2debc57f27e299c5a051bb9399ce4b4dcb685118e5adbe50a758e334e43732002
|
7
|
+
data.tar.gz: 0ea855dbec75edfc07a44c262a1df2b8d6c603aa707b85870094dccafb76a745716e3dd1c82e2120849ce5dafce553c0e13409ea75a2720d2a1f52347347f75a
|
data/lib/processout/activity.rb
CHANGED
@@ -54,12 +54,12 @@ module ProcessOut
|
|
54
54
|
def initialize(client, data = {})
|
55
55
|
@client = client
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
self.id = data.fetch(:id, nil)
|
58
|
+
self.project = data.fetch(:project, nil)
|
59
|
+
self.title = data.fetch(:title, nil)
|
60
|
+
self.content = data.fetch(:content, nil)
|
61
|
+
self.level = data.fetch(:level, nil)
|
62
|
+
self.created_at = data.fetch(:created_at, nil)
|
63
63
|
|
64
64
|
end
|
65
65
|
|
@@ -72,6 +72,9 @@ module ProcessOut
|
|
72
72
|
# Params:
|
73
73
|
# +data+:: +Hash+ of data coming from the API
|
74
74
|
def fill_with_data(data)
|
75
|
+
if data.nil?
|
76
|
+
return self
|
77
|
+
end
|
75
78
|
if data.include? "id"
|
76
79
|
self.id = data["id"]
|
77
80
|
end
|
@@ -94,10 +97,29 @@ module ProcessOut
|
|
94
97
|
self
|
95
98
|
end
|
96
99
|
|
100
|
+
# Prefills the object with the data passed as Parameters
|
101
|
+
# Params:
|
102
|
+
# +data+:: +Hash+ of data
|
103
|
+
def prefill(data)
|
104
|
+
if data.nil?
|
105
|
+
return self
|
106
|
+
end
|
107
|
+
self.id = data.fetch(:id, self.id)
|
108
|
+
self.project = data.fetch(:project, self.project)
|
109
|
+
self.title = data.fetch(:title, self.title)
|
110
|
+
self.content = data.fetch(:content, self.content)
|
111
|
+
self.level = data.fetch(:level, self.level)
|
112
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
113
|
+
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
97
117
|
# Get all the project activities.
|
98
118
|
# Params:
|
99
119
|
# +options+:: +Hash+ of options
|
100
120
|
def all(options = {})
|
121
|
+
self.prefill(options)
|
122
|
+
|
101
123
|
request = Request.new(@client)
|
102
124
|
path = "/activities"
|
103
125
|
data = {
|
@@ -127,6 +149,8 @@ module ProcessOut
|
|
127
149
|
# +activity_id+:: ID of the activity
|
128
150
|
# +options+:: +Hash+ of options
|
129
151
|
def find(activity_id, options = {})
|
152
|
+
self.prefill(options)
|
153
|
+
|
130
154
|
request = Request.new(@client)
|
131
155
|
path = "/activities/" + CGI.escape(activity_id) + ""
|
132
156
|
data = {
|
@@ -17,7 +17,6 @@ module ProcessOut
|
|
17
17
|
attr_reader :currency
|
18
18
|
attr_reader :return_url
|
19
19
|
attr_reader :cancel_url
|
20
|
-
attr_reader :custom
|
21
20
|
attr_reader :sandbox
|
22
21
|
attr_reader :created_at
|
23
22
|
|
@@ -83,10 +82,6 @@ module ProcessOut
|
|
83
82
|
@cancel_url = val
|
84
83
|
end
|
85
84
|
|
86
|
-
def custom=(val)
|
87
|
-
@custom = val
|
88
|
-
end
|
89
|
-
|
90
85
|
def sandbox=(val)
|
91
86
|
@sandbox = val
|
92
87
|
end
|
@@ -103,19 +98,18 @@ module ProcessOut
|
|
103
98
|
def initialize(client, data = {})
|
104
99
|
@client = client
|
105
100
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
@created_at = data.fetch(:created_at, "")
|
101
|
+
self.id = data.fetch(:id, nil)
|
102
|
+
self.project = data.fetch(:project, nil)
|
103
|
+
self.customer = data.fetch(:customer, nil)
|
104
|
+
self.token = data.fetch(:token, nil)
|
105
|
+
self.url = data.fetch(:url, nil)
|
106
|
+
self.authorized = data.fetch(:authorized, nil)
|
107
|
+
self.name = data.fetch(:name, nil)
|
108
|
+
self.currency = data.fetch(:currency, nil)
|
109
|
+
self.return_url = data.fetch(:return_url, nil)
|
110
|
+
self.cancel_url = data.fetch(:cancel_url, nil)
|
111
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
112
|
+
self.created_at = data.fetch(:created_at, nil)
|
119
113
|
|
120
114
|
end
|
121
115
|
|
@@ -128,6 +122,9 @@ module ProcessOut
|
|
128
122
|
# Params:
|
129
123
|
# +data+:: +Hash+ of data coming from the API
|
130
124
|
def fill_with_data(data)
|
125
|
+
if data.nil?
|
126
|
+
return self
|
127
|
+
end
|
131
128
|
if data.include? "id"
|
132
129
|
self.id = data["id"]
|
133
130
|
end
|
@@ -158,9 +155,6 @@ module ProcessOut
|
|
158
155
|
if data.include? "cancel_url"
|
159
156
|
self.cancel_url = data["cancel_url"]
|
160
157
|
end
|
161
|
-
if data.include? "custom"
|
162
|
-
self.custom = data["custom"]
|
163
|
-
end
|
164
158
|
if data.include? "sandbox"
|
165
159
|
self.sandbox = data["sandbox"]
|
166
160
|
end
|
@@ -171,10 +165,35 @@ module ProcessOut
|
|
171
165
|
self
|
172
166
|
end
|
173
167
|
|
168
|
+
# Prefills the object with the data passed as Parameters
|
169
|
+
# Params:
|
170
|
+
# +data+:: +Hash+ of data
|
171
|
+
def prefill(data)
|
172
|
+
if data.nil?
|
173
|
+
return self
|
174
|
+
end
|
175
|
+
self.id = data.fetch(:id, self.id)
|
176
|
+
self.project = data.fetch(:project, self.project)
|
177
|
+
self.customer = data.fetch(:customer, self.customer)
|
178
|
+
self.token = data.fetch(:token, self.token)
|
179
|
+
self.url = data.fetch(:url, self.url)
|
180
|
+
self.authorized = data.fetch(:authorized, self.authorized)
|
181
|
+
self.name = data.fetch(:name, self.name)
|
182
|
+
self.currency = data.fetch(:currency, self.currency)
|
183
|
+
self.return_url = data.fetch(:return_url, self.return_url)
|
184
|
+
self.cancel_url = data.fetch(:cancel_url, self.cancel_url)
|
185
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
186
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
187
|
+
|
188
|
+
self
|
189
|
+
end
|
190
|
+
|
174
191
|
# Get the customer linked to the authorization request.
|
175
192
|
# Params:
|
176
193
|
# +options+:: +Hash+ of options
|
177
194
|
def fetch_customer(options = {})
|
195
|
+
self.prefill(options)
|
196
|
+
|
178
197
|
request = Request.new(@client)
|
179
198
|
path = "/authorization-requests/" + CGI.escape(@id) + "/customers"
|
180
199
|
data = {
|
@@ -198,6 +217,8 @@ module ProcessOut
|
|
198
217
|
# +customer_id+:: ID of the customer
|
199
218
|
# +options+:: +Hash+ of options
|
200
219
|
def create(customer_id, options = {})
|
220
|
+
self.prefill(options)
|
221
|
+
|
201
222
|
request = Request.new(@client)
|
202
223
|
path = "/authorization-requests"
|
203
224
|
data = {
|
@@ -205,7 +226,6 @@ module ProcessOut
|
|
205
226
|
"currency" => @currency,
|
206
227
|
"return_url" => @return_url,
|
207
228
|
"cancel_url" => @cancel_url,
|
208
|
-
"custom" => @custom,
|
209
229
|
"customer_id" => customer_id
|
210
230
|
}
|
211
231
|
|
@@ -228,6 +248,8 @@ module ProcessOut
|
|
228
248
|
# +authorization_request_id+:: ID of the authorization request
|
229
249
|
# +options+:: +Hash+ of options
|
230
250
|
def find(authorization_request_id, options = {})
|
251
|
+
self.prefill(options)
|
252
|
+
|
231
253
|
request = Request.new(@client)
|
232
254
|
path = "/authorization-requests/" + CGI.escape(authorization_request_id) + ""
|
233
255
|
data = {
|
data/lib/processout/card.rb
CHANGED
@@ -89,19 +89,19 @@ module ProcessOut
|
|
89
89
|
def initialize(client, data = {})
|
90
90
|
@client = client
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
92
|
+
self.id = data.fetch(:id, nil)
|
93
|
+
self.project = data.fetch(:project, nil)
|
94
|
+
self.scheme = data.fetch(:scheme, nil)
|
95
|
+
self.type = data.fetch(:type, nil)
|
96
|
+
self.bank_name = data.fetch(:bank_name, nil)
|
97
|
+
self.brand = data.fetch(:brand, nil)
|
98
|
+
self.iin = data.fetch(:iin, nil)
|
99
|
+
self.last_4_digits = data.fetch(:last_4_digits, nil)
|
100
|
+
self.exp_month = data.fetch(:exp_month, nil)
|
101
|
+
self.exp_year = data.fetch(:exp_year, nil)
|
102
|
+
self.metadata = data.fetch(:metadata, nil)
|
103
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
104
|
+
self.created_at = data.fetch(:created_at, nil)
|
105
105
|
|
106
106
|
end
|
107
107
|
|
@@ -114,6 +114,9 @@ module ProcessOut
|
|
114
114
|
# Params:
|
115
115
|
# +data+:: +Hash+ of data coming from the API
|
116
116
|
def fill_with_data(data)
|
117
|
+
if data.nil?
|
118
|
+
return self
|
119
|
+
end
|
117
120
|
if data.include? "id"
|
118
121
|
self.id = data["id"]
|
119
122
|
end
|
@@ -157,6 +160,30 @@ module ProcessOut
|
|
157
160
|
self
|
158
161
|
end
|
159
162
|
|
163
|
+
# Prefills the object with the data passed as Parameters
|
164
|
+
# Params:
|
165
|
+
# +data+:: +Hash+ of data
|
166
|
+
def prefill(data)
|
167
|
+
if data.nil?
|
168
|
+
return self
|
169
|
+
end
|
170
|
+
self.id = data.fetch(:id, self.id)
|
171
|
+
self.project = data.fetch(:project, self.project)
|
172
|
+
self.scheme = data.fetch(:scheme, self.scheme)
|
173
|
+
self.type = data.fetch(:type, self.type)
|
174
|
+
self.bank_name = data.fetch(:bank_name, self.bank_name)
|
175
|
+
self.brand = data.fetch(:brand, self.brand)
|
176
|
+
self.iin = data.fetch(:iin, self.iin)
|
177
|
+
self.last_4_digits = data.fetch(:last_4_digits, self.last_4_digits)
|
178
|
+
self.exp_month = data.fetch(:exp_month, self.exp_month)
|
179
|
+
self.exp_year = data.fetch(:exp_year, self.exp_year)
|
180
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
181
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
182
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
183
|
+
|
184
|
+
self
|
185
|
+
end
|
186
|
+
|
160
187
|
|
161
188
|
end
|
162
189
|
end
|
data/lib/processout/coupon.rb
CHANGED
@@ -89,19 +89,19 @@ module ProcessOut
|
|
89
89
|
def initialize(client, data = {})
|
90
90
|
@client = client
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
92
|
+
self.id = data.fetch(:id, nil)
|
93
|
+
self.project = data.fetch(:project, nil)
|
94
|
+
self.name = data.fetch(:name, nil)
|
95
|
+
self.amount_off = data.fetch(:amount_off, nil)
|
96
|
+
self.percent_off = data.fetch(:percent_off, nil)
|
97
|
+
self.currency = data.fetch(:currency, nil)
|
98
|
+
self.max_redemptions = data.fetch(:max_redemptions, nil)
|
99
|
+
self.expires_at = data.fetch(:expires_at, nil)
|
100
|
+
self.metadata = data.fetch(:metadata, nil)
|
101
|
+
self.iteration_count = data.fetch(:iteration_count, nil)
|
102
|
+
self.redeemed_number = data.fetch(:redeemed_number, nil)
|
103
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
104
|
+
self.created_at = data.fetch(:created_at, nil)
|
105
105
|
|
106
106
|
end
|
107
107
|
|
@@ -114,6 +114,9 @@ module ProcessOut
|
|
114
114
|
# Params:
|
115
115
|
# +data+:: +Hash+ of data coming from the API
|
116
116
|
def fill_with_data(data)
|
117
|
+
if data.nil?
|
118
|
+
return self
|
119
|
+
end
|
117
120
|
if data.include? "id"
|
118
121
|
self.id = data["id"]
|
119
122
|
end
|
@@ -157,10 +160,36 @@ module ProcessOut
|
|
157
160
|
self
|
158
161
|
end
|
159
162
|
|
163
|
+
# Prefills the object with the data passed as Parameters
|
164
|
+
# Params:
|
165
|
+
# +data+:: +Hash+ of data
|
166
|
+
def prefill(data)
|
167
|
+
if data.nil?
|
168
|
+
return self
|
169
|
+
end
|
170
|
+
self.id = data.fetch(:id, self.id)
|
171
|
+
self.project = data.fetch(:project, self.project)
|
172
|
+
self.name = data.fetch(:name, self.name)
|
173
|
+
self.amount_off = data.fetch(:amount_off, self.amount_off)
|
174
|
+
self.percent_off = data.fetch(:percent_off, self.percent_off)
|
175
|
+
self.currency = data.fetch(:currency, self.currency)
|
176
|
+
self.max_redemptions = data.fetch(:max_redemptions, self.max_redemptions)
|
177
|
+
self.expires_at = data.fetch(:expires_at, self.expires_at)
|
178
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
179
|
+
self.iteration_count = data.fetch(:iteration_count, self.iteration_count)
|
180
|
+
self.redeemed_number = data.fetch(:redeemed_number, self.redeemed_number)
|
181
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
182
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
183
|
+
|
184
|
+
self
|
185
|
+
end
|
186
|
+
|
160
187
|
# Get all the coupons.
|
161
188
|
# Params:
|
162
189
|
# +options+:: +Hash+ of options
|
163
190
|
def all(options = {})
|
191
|
+
self.prefill(options)
|
192
|
+
|
164
193
|
request = Request.new(@client)
|
165
194
|
path = "/coupons"
|
166
195
|
data = {
|
@@ -189,6 +218,8 @@ module ProcessOut
|
|
189
218
|
# Params:
|
190
219
|
# +options+:: +Hash+ of options
|
191
220
|
def create(options = {})
|
221
|
+
self.prefill(options)
|
222
|
+
|
192
223
|
request = Request.new(@client)
|
193
224
|
path = "/coupons"
|
194
225
|
data = {
|
@@ -221,6 +252,8 @@ module ProcessOut
|
|
221
252
|
# +coupon_id+:: ID of the coupon
|
222
253
|
# +options+:: +Hash+ of options
|
223
254
|
def find(coupon_id, options = {})
|
255
|
+
self.prefill(options)
|
256
|
+
|
224
257
|
request = Request.new(@client)
|
225
258
|
path = "/coupons/" + CGI.escape(coupon_id) + ""
|
226
259
|
data = {
|
@@ -246,6 +279,8 @@ module ProcessOut
|
|
246
279
|
# Params:
|
247
280
|
# +options+:: +Hash+ of options
|
248
281
|
def save(options = {})
|
282
|
+
self.prefill(options)
|
283
|
+
|
249
284
|
request = Request.new(@client)
|
250
285
|
path = "/coupons/" + CGI.escape(@id) + ""
|
251
286
|
data = {
|
@@ -270,6 +305,8 @@ module ProcessOut
|
|
270
305
|
# Params:
|
271
306
|
# +options+:: +Hash+ of options
|
272
307
|
def delete(options = {})
|
308
|
+
self.prefill(options)
|
309
|
+
|
273
310
|
request = Request.new(@client)
|
274
311
|
path = "/coupons/" + CGI.escape(@id) + ""
|
275
312
|
data = {
|
data/lib/processout/customer.rb
CHANGED
@@ -21,7 +21,6 @@ module ProcessOut
|
|
21
21
|
attr_reader :balance
|
22
22
|
attr_reader :currency
|
23
23
|
attr_reader :metadata
|
24
|
-
attr_reader :has_pin
|
25
24
|
attr_reader :sandbox
|
26
25
|
attr_reader :created_at
|
27
26
|
|
@@ -89,10 +88,6 @@ module ProcessOut
|
|
89
88
|
@metadata = val
|
90
89
|
end
|
91
90
|
|
92
|
-
def has_pin=(val)
|
93
|
-
@has_pin = val
|
94
|
-
end
|
95
|
-
|
96
91
|
def sandbox=(val)
|
97
92
|
@sandbox = val
|
98
93
|
end
|
@@ -109,23 +104,22 @@ module ProcessOut
|
|
109
104
|
def initialize(client, data = {})
|
110
105
|
@client = client
|
111
106
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
@created_at = data.fetch(:created_at, "")
|
107
|
+
self.id = data.fetch(:id, nil)
|
108
|
+
self.project = data.fetch(:project, nil)
|
109
|
+
self.email = data.fetch(:email, nil)
|
110
|
+
self.first_name = data.fetch(:first_name, nil)
|
111
|
+
self.last_name = data.fetch(:last_name, nil)
|
112
|
+
self.address1 = data.fetch(:address1, nil)
|
113
|
+
self.address2 = data.fetch(:address2, nil)
|
114
|
+
self.city = data.fetch(:city, nil)
|
115
|
+
self.state = data.fetch(:state, nil)
|
116
|
+
self.zip = data.fetch(:zip, nil)
|
117
|
+
self.country_code = data.fetch(:country_code, nil)
|
118
|
+
self.balance = data.fetch(:balance, nil)
|
119
|
+
self.currency = data.fetch(:currency, nil)
|
120
|
+
self.metadata = data.fetch(:metadata, nil)
|
121
|
+
self.sandbox = data.fetch(:sandbox, nil)
|
122
|
+
self.created_at = data.fetch(:created_at, nil)
|
129
123
|
|
130
124
|
end
|
131
125
|
|
@@ -138,6 +132,9 @@ module ProcessOut
|
|
138
132
|
# Params:
|
139
133
|
# +data+:: +Hash+ of data coming from the API
|
140
134
|
def fill_with_data(data)
|
135
|
+
if data.nil?
|
136
|
+
return self
|
137
|
+
end
|
141
138
|
if data.include? "id"
|
142
139
|
self.id = data["id"]
|
143
140
|
end
|
@@ -180,9 +177,6 @@ module ProcessOut
|
|
180
177
|
if data.include? "metadata"
|
181
178
|
self.metadata = data["metadata"]
|
182
179
|
end
|
183
|
-
if data.include? "has_pin"
|
184
|
-
self.has_pin = data["has_pin"]
|
185
|
-
end
|
186
180
|
if data.include? "sandbox"
|
187
181
|
self.sandbox = data["sandbox"]
|
188
182
|
end
|
@@ -193,10 +187,39 @@ module ProcessOut
|
|
193
187
|
self
|
194
188
|
end
|
195
189
|
|
190
|
+
# Prefills the object with the data passed as Parameters
|
191
|
+
# Params:
|
192
|
+
# +data+:: +Hash+ of data
|
193
|
+
def prefill(data)
|
194
|
+
if data.nil?
|
195
|
+
return self
|
196
|
+
end
|
197
|
+
self.id = data.fetch(:id, self.id)
|
198
|
+
self.project = data.fetch(:project, self.project)
|
199
|
+
self.email = data.fetch(:email, self.email)
|
200
|
+
self.first_name = data.fetch(:first_name, self.first_name)
|
201
|
+
self.last_name = data.fetch(:last_name, self.last_name)
|
202
|
+
self.address1 = data.fetch(:address1, self.address1)
|
203
|
+
self.address2 = data.fetch(:address2, self.address2)
|
204
|
+
self.city = data.fetch(:city, self.city)
|
205
|
+
self.state = data.fetch(:state, self.state)
|
206
|
+
self.zip = data.fetch(:zip, self.zip)
|
207
|
+
self.country_code = data.fetch(:country_code, self.country_code)
|
208
|
+
self.balance = data.fetch(:balance, self.balance)
|
209
|
+
self.currency = data.fetch(:currency, self.currency)
|
210
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
211
|
+
self.sandbox = data.fetch(:sandbox, self.sandbox)
|
212
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
213
|
+
|
214
|
+
self
|
215
|
+
end
|
216
|
+
|
196
217
|
# Get the subscriptions belonging to the customer.
|
197
218
|
# Params:
|
198
219
|
# +options+:: +Hash+ of options
|
199
220
|
def fetch_subscriptions(options = {})
|
221
|
+
self.prefill(options)
|
222
|
+
|
200
223
|
request = Request.new(@client)
|
201
224
|
path = "/customers/" + CGI.escape(@id) + "/subscriptions"
|
202
225
|
data = {
|
@@ -225,6 +248,8 @@ module ProcessOut
|
|
225
248
|
# Params:
|
226
249
|
# +options+:: +Hash+ of options
|
227
250
|
def fetch_tokens(options = {})
|
251
|
+
self.prefill(options)
|
252
|
+
|
228
253
|
request = Request.new(@client)
|
229
254
|
path = "/customers/" + CGI.escape(@id) + "/tokens"
|
230
255
|
data = {
|
@@ -254,6 +279,8 @@ module ProcessOut
|
|
254
279
|
# +token_id+:: ID of the token
|
255
280
|
# +options+:: +Hash+ of options
|
256
281
|
def find_token(token_id, options = {})
|
282
|
+
self.prefill(options)
|
283
|
+
|
257
284
|
request = Request.new(@client)
|
258
285
|
path = "/customers/" + CGI.escape(@id) + "/tokens/" + CGI.escape(token_id) + ""
|
259
286
|
data = {
|
@@ -277,6 +304,8 @@ module ProcessOut
|
|
277
304
|
# +token_id+:: ID of the token
|
278
305
|
# +options+:: +Hash+ of options
|
279
306
|
def delete_token(token_id, options = {})
|
307
|
+
self.prefill(options)
|
308
|
+
|
280
309
|
request = Request.new(@client)
|
281
310
|
path = "customers/" + CGI.escape(@id) + "/tokens/" + CGI.escape(token_id) + ""
|
282
311
|
data = {
|
@@ -296,6 +325,8 @@ module ProcessOut
|
|
296
325
|
# Params:
|
297
326
|
# +options+:: +Hash+ of options
|
298
327
|
def fetch_transactions(options = {})
|
328
|
+
self.prefill(options)
|
329
|
+
|
299
330
|
request = Request.new(@client)
|
300
331
|
path = "/customers/" + CGI.escape(@id) + "/transactions"
|
301
332
|
data = {
|
@@ -324,6 +355,8 @@ module ProcessOut
|
|
324
355
|
# Params:
|
325
356
|
# +options+:: +Hash+ of options
|
326
357
|
def all(options = {})
|
358
|
+
self.prefill(options)
|
359
|
+
|
327
360
|
request = Request.new(@client)
|
328
361
|
path = "/customers"
|
329
362
|
data = {
|
@@ -352,6 +385,8 @@ module ProcessOut
|
|
352
385
|
# Params:
|
353
386
|
# +options+:: +Hash+ of options
|
354
387
|
def create(options = {})
|
388
|
+
self.prefill(options)
|
389
|
+
|
355
390
|
request = Request.new(@client)
|
356
391
|
path = "/customers"
|
357
392
|
data = {
|
@@ -388,6 +423,8 @@ module ProcessOut
|
|
388
423
|
# +customer_id+:: ID of the customer
|
389
424
|
# +options+:: +Hash+ of options
|
390
425
|
def find(customer_id, options = {})
|
426
|
+
self.prefill(options)
|
427
|
+
|
391
428
|
request = Request.new(@client)
|
392
429
|
path = "/customers/" + CGI.escape(customer_id) + ""
|
393
430
|
data = {
|
@@ -413,6 +450,8 @@ module ProcessOut
|
|
413
450
|
# Params:
|
414
451
|
# +options+:: +Hash+ of options
|
415
452
|
def save(options = {})
|
453
|
+
self.prefill(options)
|
454
|
+
|
416
455
|
request = Request.new(@client)
|
417
456
|
path = "/customers/" + CGI.escape(@id) + ""
|
418
457
|
data = {
|
@@ -447,6 +486,8 @@ module ProcessOut
|
|
447
486
|
# Params:
|
448
487
|
# +options+:: +Hash+ of options
|
449
488
|
def delete(options = {})
|
489
|
+
self.prefill(options)
|
490
|
+
|
450
491
|
request = Request.new(@client)
|
451
492
|
path = "/customers/" + CGI.escape(@id) + ""
|
452
493
|
data = {
|
@@ -27,8 +27,8 @@ module ProcessOut
|
|
27
27
|
def initialize(client, data = {})
|
28
28
|
@client = client
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
self.type = data.fetch(:type, nil)
|
31
|
+
self.value = data.fetch(:value, nil)
|
32
32
|
|
33
33
|
end
|
34
34
|
|
@@ -41,6 +41,9 @@ module ProcessOut
|
|
41
41
|
# Params:
|
42
42
|
# +data+:: +Hash+ of data coming from the API
|
43
43
|
def fill_with_data(data)
|
44
|
+
if data.nil?
|
45
|
+
return self
|
46
|
+
end
|
44
47
|
if data.include? "type"
|
45
48
|
self.type = data["type"]
|
46
49
|
end
|
@@ -51,6 +54,19 @@ module ProcessOut
|
|
51
54
|
self
|
52
55
|
end
|
53
56
|
|
57
|
+
# Prefills the object with the data passed as Parameters
|
58
|
+
# Params:
|
59
|
+
# +data+:: +Hash+ of data
|
60
|
+
def prefill(data)
|
61
|
+
if data.nil?
|
62
|
+
return self
|
63
|
+
end
|
64
|
+
self.type = data.fetch(:type, self.type)
|
65
|
+
self.value = data.fetch(:value, self.value)
|
66
|
+
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
54
70
|
|
55
71
|
end
|
56
72
|
end
|