processout 2.27.1 → 2.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/processout/card_contact.rb +125 -0
- data/lib/processout/card_create_request.rb +309 -0
- data/lib/processout/card_shipping.rb +148 -0
- data/lib/processout/card_update_request.rb +120 -0
- data/lib/processout/device.rb +202 -0
- data/lib/processout/invoice.rb +25 -1
- data/lib/processout/networking/request.rb +1 -1
- data/lib/processout/payout.rb +22 -0
- data/lib/processout/payout_item.rb +23 -0
- data/lib/processout/payout_item_amount_breakdowns.rb +125 -0
- data/lib/processout/phone.rb +81 -0
- data/lib/processout/transaction.rb +33 -0
- data/lib/processout/version.rb +1 -1
- data/lib/processout.rb +42 -6
- metadata +9 -4
- data/.DS_Store +0 -0
- data/lib/processout/api_request.rb +0 -295
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c1310f5b0805fdec37b79d6ca50503f9843bba0e81238fa1fc80187e3a6777
|
4
|
+
data.tar.gz: 5d17d3ec08d5f0b336ad53f7ce1575d21f9cffa37204e43f9d22ac5bade517f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 979c9c5e3d065a54013ef30b3a431a5ef854809b4c038ff3c98413a31e6a45e718593cc18fc1aefaaf1b9b9245eebf2db20a340fbd8171b07a971d3dd29249a2
|
7
|
+
data.tar.gz: 5c1095d0a955c15e3d01a9867b1470b2ad1fbd0cb0427cddb6a4e23a75986ae602e6dab0a42d146b7f87ce9caaa8f0ccca4290bc70a6c18078607b3dd7ea3018
|
data/.gitignore
CHANGED
@@ -0,0 +1,125 @@
|
|
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 CardContact
|
10
|
+
|
11
|
+
attr_reader :address1
|
12
|
+
attr_reader :address2
|
13
|
+
attr_reader :city
|
14
|
+
attr_reader :state
|
15
|
+
attr_reader :country_code
|
16
|
+
attr_reader :zip
|
17
|
+
|
18
|
+
|
19
|
+
def address1=(val)
|
20
|
+
@address1 = val
|
21
|
+
end
|
22
|
+
|
23
|
+
def address2=(val)
|
24
|
+
@address2 = val
|
25
|
+
end
|
26
|
+
|
27
|
+
def city=(val)
|
28
|
+
@city = val
|
29
|
+
end
|
30
|
+
|
31
|
+
def state=(val)
|
32
|
+
@state = val
|
33
|
+
end
|
34
|
+
|
35
|
+
def country_code=(val)
|
36
|
+
@country_code = val
|
37
|
+
end
|
38
|
+
|
39
|
+
def zip=(val)
|
40
|
+
@zip = val
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# Initializes the CardContact object
|
45
|
+
# Params:
|
46
|
+
# +client+:: +ProcessOut+ client instance
|
47
|
+
# +data+:: data that can be used to fill the object
|
48
|
+
def initialize(client, data = {})
|
49
|
+
@client = client
|
50
|
+
|
51
|
+
self.address1 = data.fetch(:address1, nil)
|
52
|
+
self.address2 = data.fetch(:address2, nil)
|
53
|
+
self.city = data.fetch(:city, nil)
|
54
|
+
self.state = data.fetch(:state, nil)
|
55
|
+
self.country_code = data.fetch(:country_code, nil)
|
56
|
+
self.zip = data.fetch(:zip, nil)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# Create a new CardContact using the current client
|
61
|
+
def new(data = {})
|
62
|
+
CardContact.new(@client, data)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Overrides the JSON marshaller to only send the fields we want
|
66
|
+
def to_json(options)
|
67
|
+
{
|
68
|
+
"address1": self.address1,
|
69
|
+
"address2": self.address2,
|
70
|
+
"city": self.city,
|
71
|
+
"state": self.state,
|
72
|
+
"country_code": self.country_code,
|
73
|
+
"zip": self.zip,
|
74
|
+
}.to_json
|
75
|
+
end
|
76
|
+
|
77
|
+
# Fills the object with data coming from the API
|
78
|
+
# Params:
|
79
|
+
# +data+:: +Hash+ of data coming from the API
|
80
|
+
def fill_with_data(data)
|
81
|
+
if data.nil?
|
82
|
+
return self
|
83
|
+
end
|
84
|
+
if data.include? "address1"
|
85
|
+
self.address1 = data["address1"]
|
86
|
+
end
|
87
|
+
if data.include? "address2"
|
88
|
+
self.address2 = data["address2"]
|
89
|
+
end
|
90
|
+
if data.include? "city"
|
91
|
+
self.city = data["city"]
|
92
|
+
end
|
93
|
+
if data.include? "state"
|
94
|
+
self.state = data["state"]
|
95
|
+
end
|
96
|
+
if data.include? "country_code"
|
97
|
+
self.country_code = data["country_code"]
|
98
|
+
end
|
99
|
+
if data.include? "zip"
|
100
|
+
self.zip = data["zip"]
|
101
|
+
end
|
102
|
+
|
103
|
+
self
|
104
|
+
end
|
105
|
+
|
106
|
+
# Prefills the object with the data passed as parameters
|
107
|
+
# Params:
|
108
|
+
# +data+:: +Hash+ of data
|
109
|
+
def prefill(data)
|
110
|
+
if data.nil?
|
111
|
+
return self
|
112
|
+
end
|
113
|
+
self.address1 = data.fetch(:address1, self.address1)
|
114
|
+
self.address2 = data.fetch(:address2, self.address2)
|
115
|
+
self.city = data.fetch(:city, self.city)
|
116
|
+
self.state = data.fetch(:state, self.state)
|
117
|
+
self.country_code = data.fetch(:country_code, self.country_code)
|
118
|
+
self.zip = data.fetch(:zip, self.zip)
|
119
|
+
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,309 @@
|
|
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 CardCreateRequest
|
10
|
+
|
11
|
+
attr_reader :device
|
12
|
+
attr_reader :name
|
13
|
+
attr_reader :number
|
14
|
+
attr_reader :exp_day
|
15
|
+
attr_reader :exp_month
|
16
|
+
attr_reader :exp_year
|
17
|
+
attr_reader :cvc2
|
18
|
+
attr_reader :preferred_scheme
|
19
|
+
attr_reader :metadata
|
20
|
+
attr_reader :token_type
|
21
|
+
attr_reader :eci
|
22
|
+
attr_reader :cryptogram
|
23
|
+
attr_reader :applepay_response
|
24
|
+
attr_reader :applepay_mid
|
25
|
+
attr_reader :payment_token
|
26
|
+
attr_reader :contact
|
27
|
+
attr_reader :shipping
|
28
|
+
|
29
|
+
|
30
|
+
def device=(val)
|
31
|
+
if val.nil?
|
32
|
+
@device = val
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
if val.instance_of? Device
|
37
|
+
@device = val
|
38
|
+
else
|
39
|
+
obj = Device.new(@client)
|
40
|
+
obj.fill_with_data(val)
|
41
|
+
@device = obj
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def name=(val)
|
47
|
+
@name = val
|
48
|
+
end
|
49
|
+
|
50
|
+
def number=(val)
|
51
|
+
@number = val
|
52
|
+
end
|
53
|
+
|
54
|
+
def exp_day=(val)
|
55
|
+
@exp_day = val
|
56
|
+
end
|
57
|
+
|
58
|
+
def exp_month=(val)
|
59
|
+
@exp_month = val
|
60
|
+
end
|
61
|
+
|
62
|
+
def exp_year=(val)
|
63
|
+
@exp_year = val
|
64
|
+
end
|
65
|
+
|
66
|
+
def cvc2=(val)
|
67
|
+
@cvc2 = val
|
68
|
+
end
|
69
|
+
|
70
|
+
def preferred_scheme=(val)
|
71
|
+
@preferred_scheme = val
|
72
|
+
end
|
73
|
+
|
74
|
+
def metadata=(val)
|
75
|
+
@metadata = val
|
76
|
+
end
|
77
|
+
|
78
|
+
def token_type=(val)
|
79
|
+
@token_type = val
|
80
|
+
end
|
81
|
+
|
82
|
+
def eci=(val)
|
83
|
+
@eci = val
|
84
|
+
end
|
85
|
+
|
86
|
+
def cryptogram=(val)
|
87
|
+
@cryptogram = val
|
88
|
+
end
|
89
|
+
|
90
|
+
def applepay_response=(val)
|
91
|
+
@applepay_response = val
|
92
|
+
end
|
93
|
+
|
94
|
+
def applepay_mid=(val)
|
95
|
+
@applepay_mid = val
|
96
|
+
end
|
97
|
+
|
98
|
+
def payment_token=(val)
|
99
|
+
@payment_token = val
|
100
|
+
end
|
101
|
+
|
102
|
+
def contact=(val)
|
103
|
+
if val.nil?
|
104
|
+
@contact = val
|
105
|
+
return
|
106
|
+
end
|
107
|
+
|
108
|
+
if val.instance_of? CardContact
|
109
|
+
@contact = val
|
110
|
+
else
|
111
|
+
obj = CardContact.new(@client)
|
112
|
+
obj.fill_with_data(val)
|
113
|
+
@contact = obj
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
def shipping=(val)
|
119
|
+
if val.nil?
|
120
|
+
@shipping = val
|
121
|
+
return
|
122
|
+
end
|
123
|
+
|
124
|
+
if val.instance_of? CardShipping
|
125
|
+
@shipping = val
|
126
|
+
else
|
127
|
+
obj = CardShipping.new(@client)
|
128
|
+
obj.fill_with_data(val)
|
129
|
+
@shipping = obj
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
# Initializes the CardCreateRequest object
|
136
|
+
# Params:
|
137
|
+
# +client+:: +ProcessOut+ client instance
|
138
|
+
# +data+:: data that can be used to fill the object
|
139
|
+
def initialize(client, data = {})
|
140
|
+
@client = client
|
141
|
+
|
142
|
+
self.device = data.fetch(:device, nil)
|
143
|
+
self.name = data.fetch(:name, nil)
|
144
|
+
self.number = data.fetch(:number, nil)
|
145
|
+
self.exp_day = data.fetch(:exp_day, nil)
|
146
|
+
self.exp_month = data.fetch(:exp_month, nil)
|
147
|
+
self.exp_year = data.fetch(:exp_year, nil)
|
148
|
+
self.cvc2 = data.fetch(:cvc2, nil)
|
149
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, nil)
|
150
|
+
self.metadata = data.fetch(:metadata, nil)
|
151
|
+
self.token_type = data.fetch(:token_type, nil)
|
152
|
+
self.eci = data.fetch(:eci, nil)
|
153
|
+
self.cryptogram = data.fetch(:cryptogram, nil)
|
154
|
+
self.applepay_response = data.fetch(:applepay_response, nil)
|
155
|
+
self.applepay_mid = data.fetch(:applepay_mid, nil)
|
156
|
+
self.payment_token = data.fetch(:payment_token, nil)
|
157
|
+
self.contact = data.fetch(:contact, nil)
|
158
|
+
self.shipping = data.fetch(:shipping, nil)
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
# Create a new CardCreateRequest using the current client
|
163
|
+
def new(data = {})
|
164
|
+
CardCreateRequest.new(@client, data)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Overrides the JSON marshaller to only send the fields we want
|
168
|
+
def to_json(options)
|
169
|
+
{
|
170
|
+
"device": self.device,
|
171
|
+
"name": self.name,
|
172
|
+
"number": self.number,
|
173
|
+
"exp_day": self.exp_day,
|
174
|
+
"exp_month": self.exp_month,
|
175
|
+
"exp_year": self.exp_year,
|
176
|
+
"cvc2": self.cvc2,
|
177
|
+
"preferred_scheme": self.preferred_scheme,
|
178
|
+
"metadata": self.metadata,
|
179
|
+
"token_type": self.token_type,
|
180
|
+
"eci": self.eci,
|
181
|
+
"cryptogram": self.cryptogram,
|
182
|
+
"applepay_response": self.applepay_response,
|
183
|
+
"applepay_mid": self.applepay_mid,
|
184
|
+
"payment_token": self.payment_token,
|
185
|
+
"contact": self.contact,
|
186
|
+
"shipping": self.shipping,
|
187
|
+
}.to_json
|
188
|
+
end
|
189
|
+
|
190
|
+
# Fills the object with data coming from the API
|
191
|
+
# Params:
|
192
|
+
# +data+:: +Hash+ of data coming from the API
|
193
|
+
def fill_with_data(data)
|
194
|
+
if data.nil?
|
195
|
+
return self
|
196
|
+
end
|
197
|
+
if data.include? "device"
|
198
|
+
self.device = data["device"]
|
199
|
+
end
|
200
|
+
if data.include? "name"
|
201
|
+
self.name = data["name"]
|
202
|
+
end
|
203
|
+
if data.include? "number"
|
204
|
+
self.number = data["number"]
|
205
|
+
end
|
206
|
+
if data.include? "exp_day"
|
207
|
+
self.exp_day = data["exp_day"]
|
208
|
+
end
|
209
|
+
if data.include? "exp_month"
|
210
|
+
self.exp_month = data["exp_month"]
|
211
|
+
end
|
212
|
+
if data.include? "exp_year"
|
213
|
+
self.exp_year = data["exp_year"]
|
214
|
+
end
|
215
|
+
if data.include? "cvc2"
|
216
|
+
self.cvc2 = data["cvc2"]
|
217
|
+
end
|
218
|
+
if data.include? "preferred_scheme"
|
219
|
+
self.preferred_scheme = data["preferred_scheme"]
|
220
|
+
end
|
221
|
+
if data.include? "metadata"
|
222
|
+
self.metadata = data["metadata"]
|
223
|
+
end
|
224
|
+
if data.include? "token_type"
|
225
|
+
self.token_type = data["token_type"]
|
226
|
+
end
|
227
|
+
if data.include? "eci"
|
228
|
+
self.eci = data["eci"]
|
229
|
+
end
|
230
|
+
if data.include? "cryptogram"
|
231
|
+
self.cryptogram = data["cryptogram"]
|
232
|
+
end
|
233
|
+
if data.include? "applepay_response"
|
234
|
+
self.applepay_response = data["applepay_response"]
|
235
|
+
end
|
236
|
+
if data.include? "applepay_mid"
|
237
|
+
self.applepay_mid = data["applepay_mid"]
|
238
|
+
end
|
239
|
+
if data.include? "payment_token"
|
240
|
+
self.payment_token = data["payment_token"]
|
241
|
+
end
|
242
|
+
if data.include? "contact"
|
243
|
+
self.contact = data["contact"]
|
244
|
+
end
|
245
|
+
if data.include? "shipping"
|
246
|
+
self.shipping = data["shipping"]
|
247
|
+
end
|
248
|
+
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
# Prefills the object with the data passed as parameters
|
253
|
+
# Params:
|
254
|
+
# +data+:: +Hash+ of data
|
255
|
+
def prefill(data)
|
256
|
+
if data.nil?
|
257
|
+
return self
|
258
|
+
end
|
259
|
+
self.device = data.fetch(:device, self.device)
|
260
|
+
self.name = data.fetch(:name, self.name)
|
261
|
+
self.number = data.fetch(:number, self.number)
|
262
|
+
self.exp_day = data.fetch(:exp_day, self.exp_day)
|
263
|
+
self.exp_month = data.fetch(:exp_month, self.exp_month)
|
264
|
+
self.exp_year = data.fetch(:exp_year, self.exp_year)
|
265
|
+
self.cvc2 = data.fetch(:cvc2, self.cvc2)
|
266
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme)
|
267
|
+
self.metadata = data.fetch(:metadata, self.metadata)
|
268
|
+
self.token_type = data.fetch(:token_type, self.token_type)
|
269
|
+
self.eci = data.fetch(:eci, self.eci)
|
270
|
+
self.cryptogram = data.fetch(:cryptogram, self.cryptogram)
|
271
|
+
self.applepay_response = data.fetch(:applepay_response, self.applepay_response)
|
272
|
+
self.applepay_mid = data.fetch(:applepay_mid, self.applepay_mid)
|
273
|
+
self.payment_token = data.fetch(:payment_token, self.payment_token)
|
274
|
+
self.contact = data.fetch(:contact, self.contact)
|
275
|
+
self.shipping = data.fetch(:shipping, self.shipping)
|
276
|
+
|
277
|
+
self
|
278
|
+
end
|
279
|
+
|
280
|
+
# Create a new card.
|
281
|
+
# Params:
|
282
|
+
# +options+:: +Hash+ of options
|
283
|
+
def create(options = {})
|
284
|
+
self.prefill(options)
|
285
|
+
|
286
|
+
request = Request.new(@client)
|
287
|
+
path = "/cards"
|
288
|
+
data = {
|
289
|
+
|
290
|
+
}
|
291
|
+
|
292
|
+
response = Response.new(request.post(path, data, options))
|
293
|
+
return_values = Array.new
|
294
|
+
|
295
|
+
body = response.body
|
296
|
+
body = body["card"]
|
297
|
+
|
298
|
+
|
299
|
+
obj = CardCreateRequest.new(@client)
|
300
|
+
return_values.push(obj.fill_with_data(body))
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
return_values[0]
|
305
|
+
end
|
306
|
+
|
307
|
+
|
308
|
+
end
|
309
|
+
end
|
@@ -0,0 +1,148 @@
|
|
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 CardShipping
|
10
|
+
|
11
|
+
attr_reader :address1
|
12
|
+
attr_reader :address2
|
13
|
+
attr_reader :city
|
14
|
+
attr_reader :state
|
15
|
+
attr_reader :country_code
|
16
|
+
attr_reader :zip
|
17
|
+
attr_reader :phone
|
18
|
+
|
19
|
+
|
20
|
+
def address1=(val)
|
21
|
+
@address1 = val
|
22
|
+
end
|
23
|
+
|
24
|
+
def address2=(val)
|
25
|
+
@address2 = val
|
26
|
+
end
|
27
|
+
|
28
|
+
def city=(val)
|
29
|
+
@city = val
|
30
|
+
end
|
31
|
+
|
32
|
+
def state=(val)
|
33
|
+
@state = val
|
34
|
+
end
|
35
|
+
|
36
|
+
def country_code=(val)
|
37
|
+
@country_code = val
|
38
|
+
end
|
39
|
+
|
40
|
+
def zip=(val)
|
41
|
+
@zip = val
|
42
|
+
end
|
43
|
+
|
44
|
+
def phone=(val)
|
45
|
+
if val.nil?
|
46
|
+
@phone = val
|
47
|
+
return
|
48
|
+
end
|
49
|
+
|
50
|
+
if val.instance_of? Phone
|
51
|
+
@phone = val
|
52
|
+
else
|
53
|
+
obj = Phone.new(@client)
|
54
|
+
obj.fill_with_data(val)
|
55
|
+
@phone = obj
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Initializes the CardShipping object
|
62
|
+
# Params:
|
63
|
+
# +client+:: +ProcessOut+ client instance
|
64
|
+
# +data+:: data that can be used to fill the object
|
65
|
+
def initialize(client, data = {})
|
66
|
+
@client = client
|
67
|
+
|
68
|
+
self.address1 = data.fetch(:address1, nil)
|
69
|
+
self.address2 = data.fetch(:address2, nil)
|
70
|
+
self.city = data.fetch(:city, nil)
|
71
|
+
self.state = data.fetch(:state, nil)
|
72
|
+
self.country_code = data.fetch(:country_code, nil)
|
73
|
+
self.zip = data.fetch(:zip, nil)
|
74
|
+
self.phone = data.fetch(:phone, nil)
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# Create a new CardShipping using the current client
|
79
|
+
def new(data = {})
|
80
|
+
CardShipping.new(@client, data)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Overrides the JSON marshaller to only send the fields we want
|
84
|
+
def to_json(options)
|
85
|
+
{
|
86
|
+
"address1": self.address1,
|
87
|
+
"address2": self.address2,
|
88
|
+
"city": self.city,
|
89
|
+
"state": self.state,
|
90
|
+
"country_code": self.country_code,
|
91
|
+
"zip": self.zip,
|
92
|
+
"phone": self.phone,
|
93
|
+
}.to_json
|
94
|
+
end
|
95
|
+
|
96
|
+
# Fills the object with data coming from the API
|
97
|
+
# Params:
|
98
|
+
# +data+:: +Hash+ of data coming from the API
|
99
|
+
def fill_with_data(data)
|
100
|
+
if data.nil?
|
101
|
+
return self
|
102
|
+
end
|
103
|
+
if data.include? "address1"
|
104
|
+
self.address1 = data["address1"]
|
105
|
+
end
|
106
|
+
if data.include? "address2"
|
107
|
+
self.address2 = data["address2"]
|
108
|
+
end
|
109
|
+
if data.include? "city"
|
110
|
+
self.city = data["city"]
|
111
|
+
end
|
112
|
+
if data.include? "state"
|
113
|
+
self.state = data["state"]
|
114
|
+
end
|
115
|
+
if data.include? "country_code"
|
116
|
+
self.country_code = data["country_code"]
|
117
|
+
end
|
118
|
+
if data.include? "zip"
|
119
|
+
self.zip = data["zip"]
|
120
|
+
end
|
121
|
+
if data.include? "phone"
|
122
|
+
self.phone = data["phone"]
|
123
|
+
end
|
124
|
+
|
125
|
+
self
|
126
|
+
end
|
127
|
+
|
128
|
+
# Prefills the object with the data passed as parameters
|
129
|
+
# Params:
|
130
|
+
# +data+:: +Hash+ of data
|
131
|
+
def prefill(data)
|
132
|
+
if data.nil?
|
133
|
+
return self
|
134
|
+
end
|
135
|
+
self.address1 = data.fetch(:address1, self.address1)
|
136
|
+
self.address2 = data.fetch(:address2, self.address2)
|
137
|
+
self.city = data.fetch(:city, self.city)
|
138
|
+
self.state = data.fetch(:state, self.state)
|
139
|
+
self.country_code = data.fetch(:country_code, self.country_code)
|
140
|
+
self.zip = data.fetch(:zip, self.zip)
|
141
|
+
self.phone = data.fetch(:phone, self.phone)
|
142
|
+
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,120 @@
|
|
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 CardUpdateRequest
|
10
|
+
|
11
|
+
attr_reader :update_type
|
12
|
+
attr_reader :update_reason
|
13
|
+
attr_reader :preferred_scheme
|
14
|
+
|
15
|
+
|
16
|
+
def update_type=(val)
|
17
|
+
@update_type = val
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_reason=(val)
|
21
|
+
@update_reason = val
|
22
|
+
end
|
23
|
+
|
24
|
+
def preferred_scheme=(val)
|
25
|
+
@preferred_scheme = val
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# Initializes the CardUpdateRequest object
|
30
|
+
# Params:
|
31
|
+
# +client+:: +ProcessOut+ client instance
|
32
|
+
# +data+:: data that can be used to fill the object
|
33
|
+
def initialize(client, data = {})
|
34
|
+
@client = client
|
35
|
+
|
36
|
+
self.update_type = data.fetch(:update_type, nil)
|
37
|
+
self.update_reason = data.fetch(:update_reason, nil)
|
38
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, nil)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new CardUpdateRequest using the current client
|
43
|
+
def new(data = {})
|
44
|
+
CardUpdateRequest.new(@client, data)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Overrides the JSON marshaller to only send the fields we want
|
48
|
+
def to_json(options)
|
49
|
+
{
|
50
|
+
"update_type": self.update_type,
|
51
|
+
"update_reason": self.update_reason,
|
52
|
+
"preferred_scheme": self.preferred_scheme,
|
53
|
+
}.to_json
|
54
|
+
end
|
55
|
+
|
56
|
+
# Fills the object with data coming from the API
|
57
|
+
# Params:
|
58
|
+
# +data+:: +Hash+ of data coming from the API
|
59
|
+
def fill_with_data(data)
|
60
|
+
if data.nil?
|
61
|
+
return self
|
62
|
+
end
|
63
|
+
if data.include? "update_type"
|
64
|
+
self.update_type = data["update_type"]
|
65
|
+
end
|
66
|
+
if data.include? "update_reason"
|
67
|
+
self.update_reason = data["update_reason"]
|
68
|
+
end
|
69
|
+
if data.include? "preferred_scheme"
|
70
|
+
self.preferred_scheme = data["preferred_scheme"]
|
71
|
+
end
|
72
|
+
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
# Prefills the object with the data passed as parameters
|
77
|
+
# Params:
|
78
|
+
# +data+:: +Hash+ of data
|
79
|
+
def prefill(data)
|
80
|
+
if data.nil?
|
81
|
+
return self
|
82
|
+
end
|
83
|
+
self.update_type = data.fetch(:update_type, self.update_type)
|
84
|
+
self.update_reason = data.fetch(:update_reason, self.update_reason)
|
85
|
+
self.preferred_scheme = data.fetch(:preferred_scheme, self.preferred_scheme)
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
# Update a card by its ID.
|
91
|
+
# Params:
|
92
|
+
# +card_id+:: ID of the card
|
93
|
+
# +options+:: +Hash+ of options
|
94
|
+
def update(card_id, options = {})
|
95
|
+
self.prefill(options)
|
96
|
+
|
97
|
+
request = Request.new(@client)
|
98
|
+
path = "/cards/" + CGI.escape(card_id) + ""
|
99
|
+
data = {
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
response = Response.new(request.put(path, data, options))
|
104
|
+
return_values = Array.new
|
105
|
+
|
106
|
+
body = response.body
|
107
|
+
body = body["card"]
|
108
|
+
|
109
|
+
|
110
|
+
obj = CardUpdateRequest.new(@client)
|
111
|
+
return_values.push(obj.fill_with_data(body))
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
return_values[0]
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|