atrium-ruby 2.8.5 → 2.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/docs/Account.md +3 -0
- data/docs/AccountNumber.md +2 -0
- data/docs/ConnectWidgetRequestBody.md +4 -0
- data/docs/Member.md +1 -0
- data/docs/MemberCreateRequest.md +4 -1
- data/docs/MembersApi.md +44 -0
- data/docs/MerchantLocation.md +17 -0
- data/docs/MerchantLocationResponseBody.md +8 -0
- data/docs/MerchantLocationsResponseBody.md +9 -0
- data/docs/MerchantsApi.md +107 -2
- data/docs/MerchantsResponseBody.md +9 -0
- data/docs/Transaction.md +1 -0
- data/lib/atrium-ruby.rb +4 -0
- data/lib/atrium-ruby/api/members_api.rb +64 -0
- data/lib/atrium-ruby/api/merchants_api.rb +156 -0
- data/lib/atrium-ruby/models/account.rb +28 -1
- data/lib/atrium-ruby/models/account_number.rb +19 -1
- data/lib/atrium-ruby/models/connect_widget_request_body.rb +40 -4
- data/lib/atrium-ruby/models/member.rb +10 -1
- data/lib/atrium-ruby/models/member_create_request.rb +31 -9
- data/lib/atrium-ruby/models/merchant_location.rb +260 -0
- data/lib/atrium-ruby/models/merchant_location_response_body.rb +179 -0
- data/lib/atrium-ruby/models/merchant_locations_response_body.rb +190 -0
- data/lib/atrium-ruby/models/merchants_response_body.rb +190 -0
- data/lib/atrium-ruby/models/transaction.rb +10 -1
- data/lib/atrium-ruby/version.rb +1 -1
- data/spec/api/members_api_spec.rb +15 -0
- data/spec/api/merchants_api_spec.rb +36 -0
- data/spec/models/account_number_spec.rb +12 -0
- data/spec/models/account_spec.rb +18 -0
- data/spec/models/connect_widget_request_body_spec.rb +24 -0
- data/spec/models/member_create_request_spec.rb +18 -0
- data/spec/models/member_spec.rb +6 -0
- data/spec/models/merchant_location_response_body_spec.rb +36 -0
- data/spec/models/merchant_location_spec.rb +90 -0
- data/spec/models/merchant_locations_response_body_spec.rb +42 -0
- data/spec/models/merchants_response_body_spec.rb +42 -0
- data/spec/models/transaction_spec.rb +6 -0
- metadata +52 -37
@@ -26,6 +26,8 @@ module Atrium
|
|
26
26
|
|
27
27
|
attr_accessor :name
|
28
28
|
|
29
|
+
attr_accessor :oauth_window_uri
|
30
|
+
|
29
31
|
attr_accessor :status
|
30
32
|
|
31
33
|
attr_accessor :successfully_aggregated_at
|
@@ -43,6 +45,7 @@ module Atrium
|
|
43
45
|
:'is_being_aggregated' => :'is_being_aggregated',
|
44
46
|
:'metadata' => :'metadata',
|
45
47
|
:'name' => :'name',
|
48
|
+
:'oauth_window_uri' => :'oauth_window_uri',
|
46
49
|
:'status' => :'status',
|
47
50
|
:'successfully_aggregated_at' => :'successfully_aggregated_at',
|
48
51
|
:'user_guid' => :'user_guid'
|
@@ -60,6 +63,7 @@ module Atrium
|
|
60
63
|
:'is_being_aggregated' => :'BOOLEAN',
|
61
64
|
:'metadata' => :'String',
|
62
65
|
:'name' => :'String',
|
66
|
+
:'oauth_window_uri' => :'String',
|
63
67
|
:'status' => :'String',
|
64
68
|
:'successfully_aggregated_at' => :'String',
|
65
69
|
:'user_guid' => :'String'
|
@@ -106,6 +110,10 @@ module Atrium
|
|
106
110
|
self.name = attributes[:'name']
|
107
111
|
end
|
108
112
|
|
113
|
+
if attributes.has_key?(:'oauth_window_uri')
|
114
|
+
self.oauth_window_uri = attributes[:'oauth_window_uri']
|
115
|
+
end
|
116
|
+
|
109
117
|
if attributes.has_key?(:'status')
|
110
118
|
self.status = attributes[:'status']
|
111
119
|
end
|
@@ -145,6 +153,7 @@ module Atrium
|
|
145
153
|
is_being_aggregated == o.is_being_aggregated &&
|
146
154
|
metadata == o.metadata &&
|
147
155
|
name == o.name &&
|
156
|
+
oauth_window_uri == o.oauth_window_uri &&
|
148
157
|
status == o.status &&
|
149
158
|
successfully_aggregated_at == o.successfully_aggregated_at &&
|
150
159
|
user_guid == o.user_guid
|
@@ -159,7 +168,7 @@ module Atrium
|
|
159
168
|
# Calculates hash code according to all attributes.
|
160
169
|
# @return [Fixnum] Hash code
|
161
170
|
def hash
|
162
|
-
[aggregated_at, connection_status, guid, identifier, institution_code, is_being_aggregated, metadata, name, status, successfully_aggregated_at, user_guid].hash
|
171
|
+
[aggregated_at, connection_status, guid, identifier, institution_code, is_being_aggregated, metadata, name, oauth_window_uri, status, successfully_aggregated_at, user_guid].hash
|
163
172
|
end
|
164
173
|
|
165
174
|
# Builds the object from hash
|
@@ -14,20 +14,29 @@ module Atrium
|
|
14
14
|
|
15
15
|
attr_accessor :identifier
|
16
16
|
|
17
|
+
attr_accessor :is_oauth
|
18
|
+
|
17
19
|
attr_accessor :institution_code
|
18
20
|
|
19
21
|
attr_accessor :metadata
|
20
22
|
|
23
|
+
attr_accessor :referral_source
|
24
|
+
|
21
25
|
attr_accessor :skip_aggregation
|
22
26
|
|
27
|
+
attr_accessor :ui_message_webview_url_scheme
|
28
|
+
|
23
29
|
# Attribute mapping from ruby-style variable name to JSON key.
|
24
30
|
def self.attribute_map
|
25
31
|
{
|
26
32
|
:'credentials' => :'credentials',
|
27
33
|
:'identifier' => :'identifier',
|
34
|
+
:'is_oauth' => :'is_oauth',
|
28
35
|
:'institution_code' => :'institution_code',
|
29
36
|
:'metadata' => :'metadata',
|
30
|
-
:'
|
37
|
+
:'referral_source' => :'referral_source',
|
38
|
+
:'skip_aggregation' => :'skip_aggregation',
|
39
|
+
:'ui_message_webview_url_scheme' => :'ui_message_webview_url_scheme'
|
31
40
|
}
|
32
41
|
end
|
33
42
|
|
@@ -36,9 +45,12 @@ module Atrium
|
|
36
45
|
{
|
37
46
|
:'credentials' => :'Array<CredentialRequest>',
|
38
47
|
:'identifier' => :'String',
|
48
|
+
:'is_oauth' => :'BOOLEAN',
|
39
49
|
:'institution_code' => :'String',
|
40
50
|
:'metadata' => :'String',
|
41
|
-
:'
|
51
|
+
:'referral_source' => :'String',
|
52
|
+
:'skip_aggregation' => :'BOOLEAN',
|
53
|
+
:'ui_message_webview_url_scheme' => :'String'
|
42
54
|
}
|
43
55
|
end
|
44
56
|
|
@@ -60,6 +72,10 @@ module Atrium
|
|
60
72
|
self.identifier = attributes[:'identifier']
|
61
73
|
end
|
62
74
|
|
75
|
+
if attributes.has_key?(:'is_oauth')
|
76
|
+
self.is_oauth = attributes[:'is_oauth']
|
77
|
+
end
|
78
|
+
|
63
79
|
if attributes.has_key?(:'institution_code')
|
64
80
|
self.institution_code = attributes[:'institution_code']
|
65
81
|
end
|
@@ -68,19 +84,23 @@ module Atrium
|
|
68
84
|
self.metadata = attributes[:'metadata']
|
69
85
|
end
|
70
86
|
|
87
|
+
if attributes.has_key?(:'referral_source')
|
88
|
+
self.referral_source = attributes[:'referral_source']
|
89
|
+
end
|
90
|
+
|
71
91
|
if attributes.has_key?(:'skip_aggregation')
|
72
92
|
self.skip_aggregation = attributes[:'skip_aggregation']
|
73
93
|
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:'ui_message_webview_url_scheme')
|
96
|
+
self.ui_message_webview_url_scheme = attributes[:'ui_message_webview_url_scheme']
|
97
|
+
end
|
74
98
|
end
|
75
99
|
|
76
100
|
# Show invalid properties with the reasons. Usually used together with valid?
|
77
101
|
# @return Array for valid properties with the reasons
|
78
102
|
def list_invalid_properties
|
79
103
|
invalid_properties = Array.new
|
80
|
-
if @credentials.nil?
|
81
|
-
invalid_properties.push('invalid value for "credentials", credentials cannot be nil.')
|
82
|
-
end
|
83
|
-
|
84
104
|
if @institution_code.nil?
|
85
105
|
invalid_properties.push('invalid value for "institution_code", institution_code cannot be nil.')
|
86
106
|
end
|
@@ -91,7 +111,6 @@ module Atrium
|
|
91
111
|
# Check to see if the all the properties in the model are valid
|
92
112
|
# @return true if the model is valid
|
93
113
|
def valid?
|
94
|
-
return false if @credentials.nil?
|
95
114
|
return false if @institution_code.nil?
|
96
115
|
true
|
97
116
|
end
|
@@ -103,9 +122,12 @@ module Atrium
|
|
103
122
|
self.class == o.class &&
|
104
123
|
credentials == o.credentials &&
|
105
124
|
identifier == o.identifier &&
|
125
|
+
is_oauth == o.is_oauth &&
|
106
126
|
institution_code == o.institution_code &&
|
107
127
|
metadata == o.metadata &&
|
108
|
-
|
128
|
+
referral_source == o.referral_source &&
|
129
|
+
skip_aggregation == o.skip_aggregation &&
|
130
|
+
ui_message_webview_url_scheme == o.ui_message_webview_url_scheme
|
109
131
|
end
|
110
132
|
|
111
133
|
# @see the `==` method
|
@@ -117,7 +139,7 @@ module Atrium
|
|
117
139
|
# Calculates hash code according to all attributes.
|
118
140
|
# @return [Fixnum] Hash code
|
119
141
|
def hash
|
120
|
-
[credentials, identifier, institution_code, metadata, skip_aggregation].hash
|
142
|
+
[credentials, identifier, is_oauth, institution_code, metadata, referral_source, skip_aggregation, ui_message_webview_url_scheme].hash
|
121
143
|
end
|
122
144
|
|
123
145
|
# Builds the object from hash
|
@@ -0,0 +1,260 @@
|
|
1
|
+
=begin
|
2
|
+
#MX API
|
3
|
+
|
4
|
+
#The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
|
5
|
+
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'date'
|
10
|
+
|
11
|
+
module Atrium
|
12
|
+
class MerchantLocation
|
13
|
+
attr_accessor :city
|
14
|
+
|
15
|
+
attr_accessor :guid
|
16
|
+
|
17
|
+
attr_accessor :latitude
|
18
|
+
|
19
|
+
attr_accessor :longitude
|
20
|
+
|
21
|
+
attr_accessor :merchant_guid
|
22
|
+
|
23
|
+
attr_accessor :phone_number
|
24
|
+
|
25
|
+
attr_accessor :postal_code
|
26
|
+
|
27
|
+
attr_accessor :state
|
28
|
+
|
29
|
+
attr_accessor :store_number
|
30
|
+
|
31
|
+
attr_accessor :street_address
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:'city' => :'city',
|
37
|
+
:'guid' => :'guid',
|
38
|
+
:'latitude' => :'latitude',
|
39
|
+
:'longitude' => :'longitude',
|
40
|
+
:'merchant_guid' => :'merchant_guid',
|
41
|
+
:'phone_number' => :'phone_number',
|
42
|
+
:'postal_code' => :'postal_code',
|
43
|
+
:'state' => :'state',
|
44
|
+
:'store_number' => :'store_number',
|
45
|
+
:'street_address' => :'street_address'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.mx_types
|
51
|
+
{
|
52
|
+
:'city' => :'String',
|
53
|
+
:'guid' => :'String',
|
54
|
+
:'latitude' => :'Float',
|
55
|
+
:'longitude' => :'Float',
|
56
|
+
:'merchant_guid' => :'String',
|
57
|
+
:'phone_number' => :'String',
|
58
|
+
:'postal_code' => :'String',
|
59
|
+
:'state' => :'String',
|
60
|
+
:'store_number' => :'String',
|
61
|
+
:'street_address' => :'String'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# Initializes the object
|
66
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
67
|
+
def initialize(attributes = {})
|
68
|
+
return unless attributes.is_a?(Hash)
|
69
|
+
|
70
|
+
# convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
72
|
+
|
73
|
+
if attributes.has_key?(:'city')
|
74
|
+
self.city = attributes[:'city']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'guid')
|
78
|
+
self.guid = attributes[:'guid']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'latitude')
|
82
|
+
self.latitude = attributes[:'latitude']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.has_key?(:'longitude')
|
86
|
+
self.longitude = attributes[:'longitude']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'merchant_guid')
|
90
|
+
self.merchant_guid = attributes[:'merchant_guid']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.has_key?(:'phone_number')
|
94
|
+
self.phone_number = attributes[:'phone_number']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.has_key?(:'postal_code')
|
98
|
+
self.postal_code = attributes[:'postal_code']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.has_key?(:'state')
|
102
|
+
self.state = attributes[:'state']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'store_number')
|
106
|
+
self.store_number = attributes[:'store_number']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.has_key?(:'street_address')
|
110
|
+
self.street_address = attributes[:'street_address']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
115
|
+
# @return Array for valid properties with the reasons
|
116
|
+
def list_invalid_properties
|
117
|
+
invalid_properties = Array.new
|
118
|
+
invalid_properties
|
119
|
+
end
|
120
|
+
|
121
|
+
# Check to see if the all the properties in the model are valid
|
122
|
+
# @return true if the model is valid
|
123
|
+
def valid?
|
124
|
+
true
|
125
|
+
end
|
126
|
+
|
127
|
+
# Checks equality by comparing each attribute.
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def ==(o)
|
130
|
+
return true if self.equal?(o)
|
131
|
+
self.class == o.class &&
|
132
|
+
city == o.city &&
|
133
|
+
guid == o.guid &&
|
134
|
+
latitude == o.latitude &&
|
135
|
+
longitude == o.longitude &&
|
136
|
+
merchant_guid == o.merchant_guid &&
|
137
|
+
phone_number == o.phone_number &&
|
138
|
+
postal_code == o.postal_code &&
|
139
|
+
state == o.state &&
|
140
|
+
store_number == o.store_number &&
|
141
|
+
street_address == o.street_address
|
142
|
+
end
|
143
|
+
|
144
|
+
# @see the `==` method
|
145
|
+
# @param [Object] Object to be compared
|
146
|
+
def eql?(o)
|
147
|
+
self == o
|
148
|
+
end
|
149
|
+
|
150
|
+
# Calculates hash code according to all attributes.
|
151
|
+
# @return [Fixnum] Hash code
|
152
|
+
def hash
|
153
|
+
[city, guid, latitude, longitude, merchant_guid, phone_number, postal_code, state, store_number, street_address].hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# Builds the object from hash
|
157
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
158
|
+
# @return [Object] Returns the model itself
|
159
|
+
def build_from_hash(attributes)
|
160
|
+
return nil unless attributes.is_a?(Hash)
|
161
|
+
self.class.mx_types.each_pair do |key, type|
|
162
|
+
if type =~ /\AArray<(.*)>/i
|
163
|
+
# check to ensure the input is an array given that the the attribute
|
164
|
+
# is documented as an array but the input is not
|
165
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
166
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
167
|
+
end
|
168
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
169
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
170
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
171
|
+
end
|
172
|
+
|
173
|
+
self
|
174
|
+
end
|
175
|
+
|
176
|
+
# Deserializes the data based on type
|
177
|
+
# @param string type Data type
|
178
|
+
# @param string value Value to be deserialized
|
179
|
+
# @return [Object] Deserialized data
|
180
|
+
def _deserialize(type, value)
|
181
|
+
case type.to_sym
|
182
|
+
when :DateTime
|
183
|
+
DateTime.parse(value)
|
184
|
+
when :Date
|
185
|
+
Date.parse(value)
|
186
|
+
when :String
|
187
|
+
value.to_s
|
188
|
+
when :Integer
|
189
|
+
value.to_i
|
190
|
+
when :Float
|
191
|
+
value.to_f
|
192
|
+
when :BOOLEAN
|
193
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
194
|
+
true
|
195
|
+
else
|
196
|
+
false
|
197
|
+
end
|
198
|
+
when :Object
|
199
|
+
# generic object (usually a Hash), return directly
|
200
|
+
value
|
201
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
202
|
+
inner_type = Regexp.last_match[:inner_type]
|
203
|
+
value.map { |v| _deserialize(inner_type, v) }
|
204
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
205
|
+
k_type = Regexp.last_match[:k_type]
|
206
|
+
v_type = Regexp.last_match[:v_type]
|
207
|
+
{}.tap do |hash|
|
208
|
+
value.each do |k, v|
|
209
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
else # model
|
213
|
+
temp_model = Atrium.const_get(type).new
|
214
|
+
temp_model.build_from_hash(value)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Returns the string representation of the object
|
219
|
+
# @return [String] String presentation of the object
|
220
|
+
def to_s
|
221
|
+
to_hash.to_s
|
222
|
+
end
|
223
|
+
|
224
|
+
# to_body is an alias to to_hash (backward compatibility)
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
226
|
+
def to_body
|
227
|
+
to_hash
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the object in the form of hash
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
232
|
+
def to_hash
|
233
|
+
hash = {}
|
234
|
+
self.class.attribute_map.each_pair do |attr, param|
|
235
|
+
value = self.send(attr)
|
236
|
+
next if value.nil?
|
237
|
+
hash[param] = _to_hash(value)
|
238
|
+
end
|
239
|
+
hash
|
240
|
+
end
|
241
|
+
|
242
|
+
# Outputs non-array value in the form of hash
|
243
|
+
# For object, use to_hash. Otherwise, just return the value
|
244
|
+
# @param [Object] value Any valid value
|
245
|
+
# @return [Hash] Returns the value in the form of hash
|
246
|
+
def _to_hash(value)
|
247
|
+
if value.is_a?(Array)
|
248
|
+
value.compact.map { |v| _to_hash(v) }
|
249
|
+
elsif value.is_a?(Hash)
|
250
|
+
{}.tap do |hash|
|
251
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
252
|
+
end
|
253
|
+
elsif value.respond_to? :to_hash
|
254
|
+
value.to_hash
|
255
|
+
else
|
256
|
+
value
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
=begin
|
2
|
+
#MX API
|
3
|
+
|
4
|
+
#The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification. Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes. Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access.
|
5
|
+
|
6
|
+
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'date'
|
10
|
+
|
11
|
+
module Atrium
|
12
|
+
class MerchantLocationResponseBody
|
13
|
+
attr_accessor :merchant_location
|
14
|
+
|
15
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
+
def self.attribute_map
|
17
|
+
{
|
18
|
+
:'merchant_location' => :'merchant_location'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.mx_types
|
24
|
+
{
|
25
|
+
:'merchant_location' => :'MerchantLocation'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Initializes the object
|
30
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
31
|
+
def initialize(attributes = {})
|
32
|
+
return unless attributes.is_a?(Hash)
|
33
|
+
|
34
|
+
# convert string to symbol for hash key
|
35
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
36
|
+
|
37
|
+
if attributes.has_key?(:'merchant_location')
|
38
|
+
self.merchant_location = attributes[:'merchant_location']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
43
|
+
# @return Array for valid properties with the reasons
|
44
|
+
def list_invalid_properties
|
45
|
+
invalid_properties = Array.new
|
46
|
+
invalid_properties
|
47
|
+
end
|
48
|
+
|
49
|
+
# Check to see if the all the properties in the model are valid
|
50
|
+
# @return true if the model is valid
|
51
|
+
def valid?
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
# Checks equality by comparing each attribute.
|
56
|
+
# @param [Object] Object to be compared
|
57
|
+
def ==(o)
|
58
|
+
return true if self.equal?(o)
|
59
|
+
self.class == o.class &&
|
60
|
+
merchant_location == o.merchant_location
|
61
|
+
end
|
62
|
+
|
63
|
+
# @see the `==` method
|
64
|
+
# @param [Object] Object to be compared
|
65
|
+
def eql?(o)
|
66
|
+
self == o
|
67
|
+
end
|
68
|
+
|
69
|
+
# Calculates hash code according to all attributes.
|
70
|
+
# @return [Fixnum] Hash code
|
71
|
+
def hash
|
72
|
+
[merchant_location].hash
|
73
|
+
end
|
74
|
+
|
75
|
+
# Builds the object from hash
|
76
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
+
# @return [Object] Returns the model itself
|
78
|
+
def build_from_hash(attributes)
|
79
|
+
return nil unless attributes.is_a?(Hash)
|
80
|
+
self.class.mx_types.each_pair do |key, type|
|
81
|
+
if type =~ /\AArray<(.*)>/i
|
82
|
+
# check to ensure the input is an array given that the the attribute
|
83
|
+
# is documented as an array but the input is not
|
84
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
85
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
86
|
+
end
|
87
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
88
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
89
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
90
|
+
end
|
91
|
+
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# Deserializes the data based on type
|
96
|
+
# @param string type Data type
|
97
|
+
# @param string value Value to be deserialized
|
98
|
+
# @return [Object] Deserialized data
|
99
|
+
def _deserialize(type, value)
|
100
|
+
case type.to_sym
|
101
|
+
when :DateTime
|
102
|
+
DateTime.parse(value)
|
103
|
+
when :Date
|
104
|
+
Date.parse(value)
|
105
|
+
when :String
|
106
|
+
value.to_s
|
107
|
+
when :Integer
|
108
|
+
value.to_i
|
109
|
+
when :Float
|
110
|
+
value.to_f
|
111
|
+
when :BOOLEAN
|
112
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
113
|
+
true
|
114
|
+
else
|
115
|
+
false
|
116
|
+
end
|
117
|
+
when :Object
|
118
|
+
# generic object (usually a Hash), return directly
|
119
|
+
value
|
120
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
121
|
+
inner_type = Regexp.last_match[:inner_type]
|
122
|
+
value.map { |v| _deserialize(inner_type, v) }
|
123
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
124
|
+
k_type = Regexp.last_match[:k_type]
|
125
|
+
v_type = Regexp.last_match[:v_type]
|
126
|
+
{}.tap do |hash|
|
127
|
+
value.each do |k, v|
|
128
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
else # model
|
132
|
+
temp_model = Atrium.const_get(type).new
|
133
|
+
temp_model.build_from_hash(value)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns the string representation of the object
|
138
|
+
# @return [String] String presentation of the object
|
139
|
+
def to_s
|
140
|
+
to_hash.to_s
|
141
|
+
end
|
142
|
+
|
143
|
+
# to_body is an alias to to_hash (backward compatibility)
|
144
|
+
# @return [Hash] Returns the object in the form of hash
|
145
|
+
def to_body
|
146
|
+
to_hash
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns the object in the form of hash
|
150
|
+
# @return [Hash] Returns the object in the form of hash
|
151
|
+
def to_hash
|
152
|
+
hash = {}
|
153
|
+
self.class.attribute_map.each_pair do |attr, param|
|
154
|
+
value = self.send(attr)
|
155
|
+
next if value.nil?
|
156
|
+
hash[param] = _to_hash(value)
|
157
|
+
end
|
158
|
+
hash
|
159
|
+
end
|
160
|
+
|
161
|
+
# Outputs non-array value in the form of hash
|
162
|
+
# For object, use to_hash. Otherwise, just return the value
|
163
|
+
# @param [Object] value Any valid value
|
164
|
+
# @return [Hash] Returns the value in the form of hash
|
165
|
+
def _to_hash(value)
|
166
|
+
if value.is_a?(Array)
|
167
|
+
value.compact.map { |v| _to_hash(v) }
|
168
|
+
elsif value.is_a?(Hash)
|
169
|
+
{}.tap do |hash|
|
170
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
171
|
+
end
|
172
|
+
elsif value.respond_to? :to_hash
|
173
|
+
value.to_hash
|
174
|
+
else
|
175
|
+
value
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|