processout 2.28.0 → 2.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/processout/card_contact.rb +125 -0
- data/lib/processout/card_create_request.rb +324 -0
- data/lib/processout/card_shipping.rb +148 -0
- data/lib/processout/card_update_request.rb +121 -0
- data/lib/processout/device.rb +202 -0
- data/lib/processout/networking/request.rb +1 -1
- 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/project_sftp_settings_public.rb +120 -0
- data/lib/processout/version.rb +1 -1
- data/lib/processout.rb +48 -0
- metadata +10 -2
@@ -0,0 +1,121 @@
|
|
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
|
+
"update_type" => @update_type,
|
101
|
+
"update_reason" => @update_reason,
|
102
|
+
"preferred_scheme" => @preferred_scheme
|
103
|
+
}
|
104
|
+
|
105
|
+
response = Response.new(request.put(path, data, options))
|
106
|
+
return_values = Array.new
|
107
|
+
|
108
|
+
body = response.body
|
109
|
+
body = body["card"]
|
110
|
+
|
111
|
+
|
112
|
+
return_values.push(self.fill_with_data(body))
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
return_values[0]
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,202 @@
|
|
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 Device
|
10
|
+
|
11
|
+
attr_reader :request_origin
|
12
|
+
attr_reader :id
|
13
|
+
attr_reader :channel
|
14
|
+
attr_reader :ip_address
|
15
|
+
attr_reader :user_agent
|
16
|
+
attr_reader :header_accept
|
17
|
+
attr_reader :header_referer
|
18
|
+
attr_reader :app_color_depth
|
19
|
+
attr_reader :app_java_enabled
|
20
|
+
attr_reader :app_language
|
21
|
+
attr_reader :app_screen_height
|
22
|
+
attr_reader :app_screen_width
|
23
|
+
attr_reader :app_timezone_offset
|
24
|
+
|
25
|
+
|
26
|
+
def request_origin=(val)
|
27
|
+
@request_origin = val
|
28
|
+
end
|
29
|
+
|
30
|
+
def id=(val)
|
31
|
+
@id = val
|
32
|
+
end
|
33
|
+
|
34
|
+
def channel=(val)
|
35
|
+
@channel = val
|
36
|
+
end
|
37
|
+
|
38
|
+
def ip_address=(val)
|
39
|
+
@ip_address = val
|
40
|
+
end
|
41
|
+
|
42
|
+
def user_agent=(val)
|
43
|
+
@user_agent = val
|
44
|
+
end
|
45
|
+
|
46
|
+
def header_accept=(val)
|
47
|
+
@header_accept = val
|
48
|
+
end
|
49
|
+
|
50
|
+
def header_referer=(val)
|
51
|
+
@header_referer = val
|
52
|
+
end
|
53
|
+
|
54
|
+
def app_color_depth=(val)
|
55
|
+
@app_color_depth = val
|
56
|
+
end
|
57
|
+
|
58
|
+
def app_java_enabled=(val)
|
59
|
+
@app_java_enabled = val
|
60
|
+
end
|
61
|
+
|
62
|
+
def app_language=(val)
|
63
|
+
@app_language = val
|
64
|
+
end
|
65
|
+
|
66
|
+
def app_screen_height=(val)
|
67
|
+
@app_screen_height = val
|
68
|
+
end
|
69
|
+
|
70
|
+
def app_screen_width=(val)
|
71
|
+
@app_screen_width = val
|
72
|
+
end
|
73
|
+
|
74
|
+
def app_timezone_offset=(val)
|
75
|
+
@app_timezone_offset = val
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Initializes the Device object
|
80
|
+
# Params:
|
81
|
+
# +client+:: +ProcessOut+ client instance
|
82
|
+
# +data+:: data that can be used to fill the object
|
83
|
+
def initialize(client, data = {})
|
84
|
+
@client = client
|
85
|
+
|
86
|
+
self.request_origin = data.fetch(:request_origin, nil)
|
87
|
+
self.id = data.fetch(:id, nil)
|
88
|
+
self.channel = data.fetch(:channel, nil)
|
89
|
+
self.ip_address = data.fetch(:ip_address, nil)
|
90
|
+
self.user_agent = data.fetch(:user_agent, nil)
|
91
|
+
self.header_accept = data.fetch(:header_accept, nil)
|
92
|
+
self.header_referer = data.fetch(:header_referer, nil)
|
93
|
+
self.app_color_depth = data.fetch(:app_color_depth, nil)
|
94
|
+
self.app_java_enabled = data.fetch(:app_java_enabled, nil)
|
95
|
+
self.app_language = data.fetch(:app_language, nil)
|
96
|
+
self.app_screen_height = data.fetch(:app_screen_height, nil)
|
97
|
+
self.app_screen_width = data.fetch(:app_screen_width, nil)
|
98
|
+
self.app_timezone_offset = data.fetch(:app_timezone_offset, nil)
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# Create a new Device using the current client
|
103
|
+
def new(data = {})
|
104
|
+
Device.new(@client, data)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Overrides the JSON marshaller to only send the fields we want
|
108
|
+
def to_json(options)
|
109
|
+
{
|
110
|
+
"request_origin": self.request_origin,
|
111
|
+
"id": self.id,
|
112
|
+
"channel": self.channel,
|
113
|
+
"ip_address": self.ip_address,
|
114
|
+
"user_agent": self.user_agent,
|
115
|
+
"header_accept": self.header_accept,
|
116
|
+
"header_referer": self.header_referer,
|
117
|
+
"app_color_depth": self.app_color_depth,
|
118
|
+
"app_java_enabled": self.app_java_enabled,
|
119
|
+
"app_language": self.app_language,
|
120
|
+
"app_screen_height": self.app_screen_height,
|
121
|
+
"app_screen_width": self.app_screen_width,
|
122
|
+
"app_timezone_offset": self.app_timezone_offset,
|
123
|
+
}.to_json
|
124
|
+
end
|
125
|
+
|
126
|
+
# Fills the object with data coming from the API
|
127
|
+
# Params:
|
128
|
+
# +data+:: +Hash+ of data coming from the API
|
129
|
+
def fill_with_data(data)
|
130
|
+
if data.nil?
|
131
|
+
return self
|
132
|
+
end
|
133
|
+
if data.include? "request_origin"
|
134
|
+
self.request_origin = data["request_origin"]
|
135
|
+
end
|
136
|
+
if data.include? "id"
|
137
|
+
self.id = data["id"]
|
138
|
+
end
|
139
|
+
if data.include? "channel"
|
140
|
+
self.channel = data["channel"]
|
141
|
+
end
|
142
|
+
if data.include? "ip_address"
|
143
|
+
self.ip_address = data["ip_address"]
|
144
|
+
end
|
145
|
+
if data.include? "user_agent"
|
146
|
+
self.user_agent = data["user_agent"]
|
147
|
+
end
|
148
|
+
if data.include? "header_accept"
|
149
|
+
self.header_accept = data["header_accept"]
|
150
|
+
end
|
151
|
+
if data.include? "header_referer"
|
152
|
+
self.header_referer = data["header_referer"]
|
153
|
+
end
|
154
|
+
if data.include? "app_color_depth"
|
155
|
+
self.app_color_depth = data["app_color_depth"]
|
156
|
+
end
|
157
|
+
if data.include? "app_java_enabled"
|
158
|
+
self.app_java_enabled = data["app_java_enabled"]
|
159
|
+
end
|
160
|
+
if data.include? "app_language"
|
161
|
+
self.app_language = data["app_language"]
|
162
|
+
end
|
163
|
+
if data.include? "app_screen_height"
|
164
|
+
self.app_screen_height = data["app_screen_height"]
|
165
|
+
end
|
166
|
+
if data.include? "app_screen_width"
|
167
|
+
self.app_screen_width = data["app_screen_width"]
|
168
|
+
end
|
169
|
+
if data.include? "app_timezone_offset"
|
170
|
+
self.app_timezone_offset = data["app_timezone_offset"]
|
171
|
+
end
|
172
|
+
|
173
|
+
self
|
174
|
+
end
|
175
|
+
|
176
|
+
# Prefills the object with the data passed as parameters
|
177
|
+
# Params:
|
178
|
+
# +data+:: +Hash+ of data
|
179
|
+
def prefill(data)
|
180
|
+
if data.nil?
|
181
|
+
return self
|
182
|
+
end
|
183
|
+
self.request_origin = data.fetch(:request_origin, self.request_origin)
|
184
|
+
self.id = data.fetch(:id, self.id)
|
185
|
+
self.channel = data.fetch(:channel, self.channel)
|
186
|
+
self.ip_address = data.fetch(:ip_address, self.ip_address)
|
187
|
+
self.user_agent = data.fetch(:user_agent, self.user_agent)
|
188
|
+
self.header_accept = data.fetch(:header_accept, self.header_accept)
|
189
|
+
self.header_referer = data.fetch(:header_referer, self.header_referer)
|
190
|
+
self.app_color_depth = data.fetch(:app_color_depth, self.app_color_depth)
|
191
|
+
self.app_java_enabled = data.fetch(:app_java_enabled, self.app_java_enabled)
|
192
|
+
self.app_language = data.fetch(:app_language, self.app_language)
|
193
|
+
self.app_screen_height = data.fetch(:app_screen_height, self.app_screen_height)
|
194
|
+
self.app_screen_width = data.fetch(:app_screen_width, self.app_screen_width)
|
195
|
+
self.app_timezone_offset = data.fetch(:app_timezone_offset, self.app_timezone_offset)
|
196
|
+
|
197
|
+
self
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
@@ -13,7 +13,7 @@ module ProcessOut
|
|
13
13
|
req.basic_auth @client.project_id, @client.project_secret
|
14
14
|
req.content_type = "application/json"
|
15
15
|
req["API-Version"] = "1.4.0.0"
|
16
|
-
req["User-Agent"] = "ProcessOut Ruby-Bindings/2.
|
16
|
+
req["User-Agent"] = "ProcessOut Ruby-Bindings/2.30.0"
|
17
17
|
|
18
18
|
unless options.nil?
|
19
19
|
req["Idempotency-Key"] = options.fetch(:idempotency_key, "")
|
@@ -21,6 +21,7 @@ module ProcessOut
|
|
21
21
|
attr_reader :fees
|
22
22
|
attr_reader :metadata
|
23
23
|
attr_reader :created_at
|
24
|
+
attr_reader :breakdown
|
24
25
|
|
25
26
|
|
26
27
|
def id=(val)
|
@@ -111,6 +112,22 @@ module ProcessOut
|
|
111
112
|
@created_at = val
|
112
113
|
end
|
113
114
|
|
115
|
+
def breakdown=(val)
|
116
|
+
if val.nil?
|
117
|
+
@breakdown = val
|
118
|
+
return
|
119
|
+
end
|
120
|
+
|
121
|
+
if val.instance_of? PayoutItemAmountBreakdowns
|
122
|
+
@breakdown = val
|
123
|
+
else
|
124
|
+
obj = PayoutItemAmountBreakdowns.new(@client)
|
125
|
+
obj.fill_with_data(val)
|
126
|
+
@breakdown = obj
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
114
131
|
|
115
132
|
# Initializes the PayoutItem object
|
116
133
|
# Params:
|
@@ -132,6 +149,7 @@ module ProcessOut
|
|
132
149
|
self.fees = data.fetch(:fees, nil)
|
133
150
|
self.metadata = data.fetch(:metadata, nil)
|
134
151
|
self.created_at = data.fetch(:created_at, nil)
|
152
|
+
self.breakdown = data.fetch(:breakdown, nil)
|
135
153
|
|
136
154
|
end
|
137
155
|
|
@@ -156,6 +174,7 @@ module ProcessOut
|
|
156
174
|
"fees": self.fees,
|
157
175
|
"metadata": self.metadata,
|
158
176
|
"created_at": self.created_at,
|
177
|
+
"breakdown": self.breakdown,
|
159
178
|
}.to_json
|
160
179
|
end
|
161
180
|
|
@@ -205,6 +224,9 @@ module ProcessOut
|
|
205
224
|
if data.include? "created_at"
|
206
225
|
self.created_at = data["created_at"]
|
207
226
|
end
|
227
|
+
if data.include? "breakdown"
|
228
|
+
self.breakdown = data["breakdown"]
|
229
|
+
end
|
208
230
|
|
209
231
|
self
|
210
232
|
end
|
@@ -229,6 +251,7 @@ module ProcessOut
|
|
229
251
|
self.fees = data.fetch(:fees, self.fees)
|
230
252
|
self.metadata = data.fetch(:metadata, self.metadata)
|
231
253
|
self.created_at = data.fetch(:created_at, self.created_at)
|
254
|
+
self.breakdown = data.fetch(:breakdown, self.breakdown)
|
232
255
|
|
233
256
|
self
|
234
257
|
end
|
@@ -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 PayoutItemAmountBreakdowns
|
10
|
+
|
11
|
+
attr_reader :scheme_fee
|
12
|
+
attr_reader :interchange_fee
|
13
|
+
attr_reader :gateway_fee
|
14
|
+
attr_reader :markup_fee
|
15
|
+
attr_reader :acquirer_fee
|
16
|
+
attr_reader :other_fee
|
17
|
+
|
18
|
+
|
19
|
+
def scheme_fee=(val)
|
20
|
+
@scheme_fee = val
|
21
|
+
end
|
22
|
+
|
23
|
+
def interchange_fee=(val)
|
24
|
+
@interchange_fee = val
|
25
|
+
end
|
26
|
+
|
27
|
+
def gateway_fee=(val)
|
28
|
+
@gateway_fee = val
|
29
|
+
end
|
30
|
+
|
31
|
+
def markup_fee=(val)
|
32
|
+
@markup_fee = val
|
33
|
+
end
|
34
|
+
|
35
|
+
def acquirer_fee=(val)
|
36
|
+
@acquirer_fee = val
|
37
|
+
end
|
38
|
+
|
39
|
+
def other_fee=(val)
|
40
|
+
@other_fee = val
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# Initializes the PayoutItemAmountBreakdowns 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.scheme_fee = data.fetch(:scheme_fee, nil)
|
52
|
+
self.interchange_fee = data.fetch(:interchange_fee, nil)
|
53
|
+
self.gateway_fee = data.fetch(:gateway_fee, nil)
|
54
|
+
self.markup_fee = data.fetch(:markup_fee, nil)
|
55
|
+
self.acquirer_fee = data.fetch(:acquirer_fee, nil)
|
56
|
+
self.other_fee = data.fetch(:other_fee, nil)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# Create a new PayoutItemAmountBreakdowns using the current client
|
61
|
+
def new(data = {})
|
62
|
+
PayoutItemAmountBreakdowns.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
|
+
"scheme_fee": self.scheme_fee,
|
69
|
+
"interchange_fee": self.interchange_fee,
|
70
|
+
"gateway_fee": self.gateway_fee,
|
71
|
+
"markup_fee": self.markup_fee,
|
72
|
+
"acquirer_fee": self.acquirer_fee,
|
73
|
+
"other_fee": self.other_fee,
|
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? "scheme_fee"
|
85
|
+
self.scheme_fee = data["scheme_fee"]
|
86
|
+
end
|
87
|
+
if data.include? "interchange_fee"
|
88
|
+
self.interchange_fee = data["interchange_fee"]
|
89
|
+
end
|
90
|
+
if data.include? "gateway_fee"
|
91
|
+
self.gateway_fee = data["gateway_fee"]
|
92
|
+
end
|
93
|
+
if data.include? "markup_fee"
|
94
|
+
self.markup_fee = data["markup_fee"]
|
95
|
+
end
|
96
|
+
if data.include? "acquirer_fee"
|
97
|
+
self.acquirer_fee = data["acquirer_fee"]
|
98
|
+
end
|
99
|
+
if data.include? "other_fee"
|
100
|
+
self.other_fee = data["other_fee"]
|
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.scheme_fee = data.fetch(:scheme_fee, self.scheme_fee)
|
114
|
+
self.interchange_fee = data.fetch(:interchange_fee, self.interchange_fee)
|
115
|
+
self.gateway_fee = data.fetch(:gateway_fee, self.gateway_fee)
|
116
|
+
self.markup_fee = data.fetch(:markup_fee, self.markup_fee)
|
117
|
+
self.acquirer_fee = data.fetch(:acquirer_fee, self.acquirer_fee)
|
118
|
+
self.other_fee = data.fetch(:other_fee, self.other_fee)
|
119
|
+
|
120
|
+
self
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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 Phone
|
10
|
+
|
11
|
+
attr_reader :number
|
12
|
+
attr_reader :dialing_code
|
13
|
+
|
14
|
+
|
15
|
+
def number=(val)
|
16
|
+
@number = val
|
17
|
+
end
|
18
|
+
|
19
|
+
def dialing_code=(val)
|
20
|
+
@dialing_code = val
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Initializes the Phone object
|
25
|
+
# Params:
|
26
|
+
# +client+:: +ProcessOut+ client instance
|
27
|
+
# +data+:: data that can be used to fill the object
|
28
|
+
def initialize(client, data = {})
|
29
|
+
@client = client
|
30
|
+
|
31
|
+
self.number = data.fetch(:number, nil)
|
32
|
+
self.dialing_code = data.fetch(:dialing_code, nil)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create a new Phone using the current client
|
37
|
+
def new(data = {})
|
38
|
+
Phone.new(@client, data)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Overrides the JSON marshaller to only send the fields we want
|
42
|
+
def to_json(options)
|
43
|
+
{
|
44
|
+
"number": self.number,
|
45
|
+
"dialing_code": self.dialing_code,
|
46
|
+
}.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
# Fills the object with data coming from the API
|
50
|
+
# Params:
|
51
|
+
# +data+:: +Hash+ of data coming from the API
|
52
|
+
def fill_with_data(data)
|
53
|
+
if data.nil?
|
54
|
+
return self
|
55
|
+
end
|
56
|
+
if data.include? "number"
|
57
|
+
self.number = data["number"]
|
58
|
+
end
|
59
|
+
if data.include? "dialing_code"
|
60
|
+
self.dialing_code = data["dialing_code"]
|
61
|
+
end
|
62
|
+
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
# Prefills the object with the data passed as parameters
|
67
|
+
# Params:
|
68
|
+
# +data+:: +Hash+ of data
|
69
|
+
def prefill(data)
|
70
|
+
if data.nil?
|
71
|
+
return self
|
72
|
+
end
|
73
|
+
self.number = data.fetch(:number, self.number)
|
74
|
+
self.dialing_code = data.fetch(:dialing_code, self.dialing_code)
|
75
|
+
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|