zip_money 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +128 -0
- data/Rakefile +8 -0
- data/docs/Address.md +15 -0
- data/docs/Authority.md +9 -0
- data/docs/CaptureChargeRequest.md +8 -0
- data/docs/Charge.md +17 -0
- data/docs/ChargeCollection.md +8 -0
- data/docs/ChargeOrder.md +11 -0
- data/docs/ChargesApi.md +307 -0
- data/docs/Checkout.md +18 -0
- data/docs/CheckoutConfiguration.md +8 -0
- data/docs/CheckoutFeatures.md +8 -0
- data/docs/CheckoutFeaturesTokenisation.md +8 -0
- data/docs/CheckoutOrder.md +13 -0
- data/docs/CheckoutsApi.md +119 -0
- data/docs/CreateChargeRequest.md +14 -0
- data/docs/CreateCheckoutRequest.md +13 -0
- data/docs/CreateCheckoutRequestFeatures.md +8 -0
- data/docs/CreateCheckoutRequestFeaturesTokenisation.md +8 -0
- data/docs/CreateRefundRequest.md +11 -0
- data/docs/CreateTokenRequest.md +8 -0
- data/docs/Customer.md +15 -0
- data/docs/CustomersApi.md +96 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/ErrorResponseError.md +10 -0
- data/docs/ErrorResponseErrorDetails.md +9 -0
- data/docs/InlineResponse200.md +8 -0
- data/docs/Metadata.md +7 -0
- data/docs/OrderItem.md +16 -0
- data/docs/OrderShipping.md +10 -0
- data/docs/OrderShippingTracking.md +10 -0
- data/docs/Refund.md +13 -0
- data/docs/RefundsApi.md +181 -0
- data/docs/SettlementsApi.md +96 -0
- data/docs/Shopper.md +17 -0
- data/docs/ShopperStatistics.md +16 -0
- data/docs/Token.md +11 -0
- data/docs/TokensApi.md +66 -0
- data/lib/zip_money.rb +68 -0
- data/lib/zip_money/api/charges_api.rb +301 -0
- data/lib/zip_money/api/checkouts_api.rb +120 -0
- data/lib/zip_money/api/customers_api.rb +116 -0
- data/lib/zip_money/api/refunds_api.rb +181 -0
- data/lib/zip_money/api/settlements_api.rb +116 -0
- data/lib/zip_money/api/tokens_api.rb +70 -0
- data/lib/zip_money/api_client.rb +386 -0
- data/lib/zip_money/api_error.rb +31 -0
- data/lib/zip_money/configuration.rb +238 -0
- data/lib/zip_money/models/address.rb +413 -0
- data/lib/zip_money/models/authority.rb +235 -0
- data/lib/zip_money/models/capture_charge_request.rb +206 -0
- data/lib/zip_money/models/charge.rb +369 -0
- data/lib/zip_money/models/charge_collection.rb +188 -0
- data/lib/zip_money/models/charge_order.rb +250 -0
- data/lib/zip_money/models/checkout.rb +344 -0
- data/lib/zip_money/models/checkout_configuration.rb +187 -0
- data/lib/zip_money/models/checkout_features.rb +181 -0
- data/lib/zip_money/models/checkout_features_tokenisation.rb +184 -0
- data/lib/zip_money/models/checkout_order.rb +299 -0
- data/lib/zip_money/models/create_charge_request.rb +289 -0
- data/lib/zip_money/models/create_checkout_request.rb +272 -0
- data/lib/zip_money/models/create_checkout_request_features.rb +181 -0
- data/lib/zip_money/models/create_checkout_request_features_tokenisation.rb +189 -0
- data/lib/zip_money/models/create_refund_request.rb +246 -0
- data/lib/zip_money/models/create_token_request.rb +186 -0
- data/lib/zip_money/models/customer.rb +310 -0
- data/lib/zip_money/models/error_response.rb +181 -0
- data/lib/zip_money/models/error_response_error.rb +211 -0
- data/lib/zip_money/models/error_response_error_details.rb +190 -0
- data/lib/zip_money/models/inline_response_200.rb +188 -0
- data/lib/zip_money/models/metadata.rb +172 -0
- data/lib/zip_money/models/order_item.rb +333 -0
- data/lib/zip_money/models/order_shipping.rb +200 -0
- data/lib/zip_money/models/order_shipping_tracking.rb +247 -0
- data/lib/zip_money/models/refund.rb +252 -0
- data/lib/zip_money/models/shopper.rb +339 -0
- data/lib/zip_money/models/shopper_statistics.rb +295 -0
- data/lib/zip_money/models/token.rb +228 -0
- data/lib/zip_money/version.rb +8 -0
- data/spec/api/charges_api_spec.rb +114 -0
- data/spec/api/checkouts_api_spec.rb +54 -0
- data/spec/api/customers_api_spec.rb +51 -0
- data/spec/api/refunds_api_spec.rb +67 -0
- data/spec/api/settlements_api_spec.rb +51 -0
- data/spec/api/tokens_api_spec.rb +41 -0
- data/spec/api_client_spec.rb +219 -0
- data/spec/configuration_spec.rb +50 -0
- data/spec/models/address_spec.rb +77 -0
- data/spec/models/authority_spec.rb +45 -0
- data/spec/models/capture_charge_request_spec.rb +35 -0
- data/spec/models/charge_collection_spec.rb +35 -0
- data/spec/models/charge_order_spec.rb +53 -0
- data/spec/models/charge_spec.rb +93 -0
- data/spec/models/checkout_configuration_spec.rb +35 -0
- data/spec/models/checkout_features_spec.rb +35 -0
- data/spec/models/checkout_features_tokenisation_spec.rb +35 -0
- data/spec/models/checkout_order_spec.rb +65 -0
- data/spec/models/checkout_spec.rb +103 -0
- data/spec/models/create_charge_request_spec.rb +75 -0
- data/spec/models/create_checkout_request_features_spec.rb +35 -0
- data/spec/models/create_checkout_request_features_tokenisation_spec.rb +35 -0
- data/spec/models/create_checkout_request_spec.rb +69 -0
- data/spec/models/create_refund_request_spec.rb +53 -0
- data/spec/models/create_token_request_spec.rb +35 -0
- data/spec/models/customer_spec.rb +81 -0
- data/spec/models/error_response_error_details_spec.rb +41 -0
- data/spec/models/error_response_error_spec.rb +47 -0
- data/spec/models/error_response_spec.rb +35 -0
- data/spec/models/inline_response_200_spec.rb +35 -0
- data/spec/models/metadata_spec.rb +29 -0
- data/spec/models/order_item_spec.rb +87 -0
- data/spec/models/order_shipping_spec.rb +47 -0
- data/spec/models/order_shipping_tracking_spec.rb +47 -0
- data/spec/models/refund_spec.rb +65 -0
- data/spec/models/shopper_spec.rb +92 -0
- data/spec/models/shopper_statistics_spec.rb +86 -0
- data/spec/models/token_spec.rb +52 -0
- data/spec/payload_helper.rb +96 -0
- data/spec/spec_helper.rb +104 -0
- data/zip_money.gemspec +38 -0
- metadata +380 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module ZipMoney
|
9
|
+
|
10
|
+
class ErrorResponseError
|
11
|
+
attr_accessor :code
|
12
|
+
|
13
|
+
attr_accessor :message
|
14
|
+
|
15
|
+
attr_accessor :details
|
16
|
+
|
17
|
+
|
18
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
19
|
+
def self.attribute_map
|
20
|
+
{
|
21
|
+
:'code' => :'code',
|
22
|
+
:'message' => :'message',
|
23
|
+
:'details' => :'details'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.zip_types
|
29
|
+
{
|
30
|
+
:'code' => :'String',
|
31
|
+
:'message' => :'String',
|
32
|
+
:'details' => :'Array<ErrorResponseErrorDetails>'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
return unless attributes.is_a?(Hash)
|
40
|
+
|
41
|
+
# convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
43
|
+
|
44
|
+
if attributes.has_key?(:'code')
|
45
|
+
self.code = attributes[:'code']
|
46
|
+
end
|
47
|
+
|
48
|
+
if attributes.has_key?(:'message')
|
49
|
+
self.message = attributes[:'message']
|
50
|
+
end
|
51
|
+
|
52
|
+
if attributes.has_key?(:'details')
|
53
|
+
if (value = attributes[:'details']).is_a?(Array)
|
54
|
+
self.details = value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
61
|
+
# @return Array for valid properies with the reasons
|
62
|
+
def list_invalid_properties
|
63
|
+
invalid_properties = Array.new
|
64
|
+
if @code.nil?
|
65
|
+
invalid_properties.push("invalid value for 'code', code cannot be nil.")
|
66
|
+
end
|
67
|
+
|
68
|
+
if @message.nil?
|
69
|
+
invalid_properties.push("invalid value for 'message', message cannot be nil.")
|
70
|
+
end
|
71
|
+
|
72
|
+
return invalid_properties
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check to see if the all the properties in the model are valid
|
76
|
+
# @return true if the model is valid
|
77
|
+
def valid?
|
78
|
+
return false if @code.nil?
|
79
|
+
return false if @message.nil?
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Checks equality by comparing each attribute.
|
84
|
+
# @param [Object] Object to be compared
|
85
|
+
def ==(o)
|
86
|
+
return true if self.equal?(o)
|
87
|
+
self.class == o.class &&
|
88
|
+
code == o.code &&
|
89
|
+
message == o.message &&
|
90
|
+
details == o.details
|
91
|
+
end
|
92
|
+
|
93
|
+
# @see the `==` method
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def eql?(o)
|
96
|
+
self == o
|
97
|
+
end
|
98
|
+
|
99
|
+
# Calculates hash code according to all attributes.
|
100
|
+
# @return [Fixnum] Hash code
|
101
|
+
def hash
|
102
|
+
[code, message, details].hash
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.zip_types.each_pair do |key, type|
|
111
|
+
if type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the the attribute
|
113
|
+
# is documented as an array but the input is not
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
116
|
+
end
|
117
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
118
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
119
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
120
|
+
end
|
121
|
+
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Deserializes the data based on type
|
126
|
+
# @param string type Data type
|
127
|
+
# @param string value Value to be deserialized
|
128
|
+
# @return [Object] Deserialized data
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :BOOLEAN
|
142
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
temp_model = ZipMoney.const_get(type).new
|
163
|
+
temp_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the string representation of the object
|
168
|
+
# @return [String] String presentation of the object
|
169
|
+
def to_s
|
170
|
+
to_hash.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
# to_body is an alias to to_hash (backward compatibility)
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_body
|
176
|
+
to_hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the object in the form of hash
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_hash
|
182
|
+
hash = {}
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
184
|
+
value = self.send(attr)
|
185
|
+
next if value.nil?
|
186
|
+
hash[param] = _to_hash(value)
|
187
|
+
end
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map{ |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to? :to_hash
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module ZipMoney
|
9
|
+
|
10
|
+
class ErrorResponseErrorDetails
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
attr_accessor :message
|
14
|
+
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:'name' => :'name',
|
20
|
+
:'message' => :'message'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.zip_types
|
26
|
+
{
|
27
|
+
:'name' => :'String',
|
28
|
+
:'message' => :'String'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Initializes the object
|
33
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
34
|
+
def initialize(attributes = {})
|
35
|
+
return unless attributes.is_a?(Hash)
|
36
|
+
|
37
|
+
# convert string to symbol for hash key
|
38
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
39
|
+
|
40
|
+
if attributes.has_key?(:'name')
|
41
|
+
self.name = attributes[:'name']
|
42
|
+
end
|
43
|
+
|
44
|
+
if attributes.has_key?(:'message')
|
45
|
+
self.message = attributes[:'message']
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
51
|
+
# @return Array for valid properies with the reasons
|
52
|
+
def list_invalid_properties
|
53
|
+
invalid_properties = Array.new
|
54
|
+
return invalid_properties
|
55
|
+
end
|
56
|
+
|
57
|
+
# Check to see if the all the properties in the model are valid
|
58
|
+
# @return true if the model is valid
|
59
|
+
def valid?
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
|
63
|
+
# Checks equality by comparing each attribute.
|
64
|
+
# @param [Object] Object to be compared
|
65
|
+
def ==(o)
|
66
|
+
return true if self.equal?(o)
|
67
|
+
self.class == o.class &&
|
68
|
+
name == o.name &&
|
69
|
+
message == o.message
|
70
|
+
end
|
71
|
+
|
72
|
+
# @see the `==` method
|
73
|
+
# @param [Object] Object to be compared
|
74
|
+
def eql?(o)
|
75
|
+
self == o
|
76
|
+
end
|
77
|
+
|
78
|
+
# Calculates hash code according to all attributes.
|
79
|
+
# @return [Fixnum] Hash code
|
80
|
+
def hash
|
81
|
+
[name, message].hash
|
82
|
+
end
|
83
|
+
|
84
|
+
# Builds the object from hash
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
# @return [Object] Returns the model itself
|
87
|
+
def build_from_hash(attributes)
|
88
|
+
return nil unless attributes.is_a?(Hash)
|
89
|
+
self.class.zip_types.each_pair do |key, type|
|
90
|
+
if type =~ /\AArray<(.*)>/i
|
91
|
+
# check to ensure the input is an array given that the the attribute
|
92
|
+
# is documented as an array but the input is not
|
93
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
94
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
95
|
+
end
|
96
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
97
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
98
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
99
|
+
end
|
100
|
+
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deserializes the data based on type
|
105
|
+
# @param string type Data type
|
106
|
+
# @param string value Value to be deserialized
|
107
|
+
# @return [Object] Deserialized data
|
108
|
+
def _deserialize(type, value)
|
109
|
+
case type.to_sym
|
110
|
+
when :DateTime
|
111
|
+
DateTime.parse(value)
|
112
|
+
when :Date
|
113
|
+
Date.parse(value)
|
114
|
+
when :String
|
115
|
+
value.to_s
|
116
|
+
when :Integer
|
117
|
+
value.to_i
|
118
|
+
when :Float
|
119
|
+
value.to_f
|
120
|
+
when :BOOLEAN
|
121
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
122
|
+
true
|
123
|
+
else
|
124
|
+
false
|
125
|
+
end
|
126
|
+
when :Object
|
127
|
+
# generic object (usually a Hash), return directly
|
128
|
+
value
|
129
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
130
|
+
inner_type = Regexp.last_match[:inner_type]
|
131
|
+
value.map { |v| _deserialize(inner_type, v) }
|
132
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
133
|
+
k_type = Regexp.last_match[:k_type]
|
134
|
+
v_type = Regexp.last_match[:v_type]
|
135
|
+
{}.tap do |hash|
|
136
|
+
value.each do |k, v|
|
137
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
else # model
|
141
|
+
temp_model = ZipMoney.const_get(type).new
|
142
|
+
temp_model.build_from_hash(value)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Returns the string representation of the object
|
147
|
+
# @return [String] String presentation of the object
|
148
|
+
def to_s
|
149
|
+
to_hash.to_s
|
150
|
+
end
|
151
|
+
|
152
|
+
# to_body is an alias to to_hash (backward compatibility)
|
153
|
+
# @return [Hash] Returns the object in the form of hash
|
154
|
+
def to_body
|
155
|
+
to_hash
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the object in the form of hash
|
159
|
+
# @return [Hash] Returns the object in the form of hash
|
160
|
+
def to_hash
|
161
|
+
hash = {}
|
162
|
+
self.class.attribute_map.each_pair do |attr, param|
|
163
|
+
value = self.send(attr)
|
164
|
+
next if value.nil?
|
165
|
+
hash[param] = _to_hash(value)
|
166
|
+
end
|
167
|
+
hash
|
168
|
+
end
|
169
|
+
|
170
|
+
# Outputs non-array value in the form of hash
|
171
|
+
# For object, use to_hash. Otherwise, just return the value
|
172
|
+
# @param [Object] value Any valid value
|
173
|
+
# @return [Hash] Returns the value in the form of hash
|
174
|
+
def _to_hash(value)
|
175
|
+
if value.is_a?(Array)
|
176
|
+
value.compact.map{ |v| _to_hash(v) }
|
177
|
+
elsif value.is_a?(Hash)
|
178
|
+
{}.tap do |hash|
|
179
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
180
|
+
end
|
181
|
+
elsif value.respond_to? :to_hash
|
182
|
+
value.to_hash
|
183
|
+
else
|
184
|
+
value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module ZipMoney
|
9
|
+
|
10
|
+
class InlineResponse200
|
11
|
+
attr_accessor :items
|
12
|
+
|
13
|
+
|
14
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
15
|
+
def self.attribute_map
|
16
|
+
{
|
17
|
+
:'items' => :'items'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Attribute type mapping.
|
22
|
+
def self.zip_types
|
23
|
+
{
|
24
|
+
:'items' => :'Array<Refund>'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Initializes the object
|
29
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
30
|
+
def initialize(attributes = {})
|
31
|
+
return unless attributes.is_a?(Hash)
|
32
|
+
|
33
|
+
# convert string to symbol for hash key
|
34
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
35
|
+
|
36
|
+
if attributes.has_key?(:'items')
|
37
|
+
if (value = attributes[:'items']).is_a?(Array)
|
38
|
+
self.items = value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
45
|
+
# @return Array for valid properies with the reasons
|
46
|
+
def list_invalid_properties
|
47
|
+
invalid_properties = Array.new
|
48
|
+
if @items.nil?
|
49
|
+
invalid_properties.push("invalid value for 'items', items cannot be nil.")
|
50
|
+
end
|
51
|
+
|
52
|
+
return invalid_properties
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check to see if the all the properties in the model are valid
|
56
|
+
# @return true if the model is valid
|
57
|
+
def valid?
|
58
|
+
return false if @items.nil?
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
# Checks equality by comparing each attribute.
|
63
|
+
# @param [Object] Object to be compared
|
64
|
+
def ==(o)
|
65
|
+
return true if self.equal?(o)
|
66
|
+
self.class == o.class &&
|
67
|
+
items == o.items
|
68
|
+
end
|
69
|
+
|
70
|
+
# @see the `==` method
|
71
|
+
# @param [Object] Object to be compared
|
72
|
+
def eql?(o)
|
73
|
+
self == o
|
74
|
+
end
|
75
|
+
|
76
|
+
# Calculates hash code according to all attributes.
|
77
|
+
# @return [Fixnum] Hash code
|
78
|
+
def hash
|
79
|
+
[items].hash
|
80
|
+
end
|
81
|
+
|
82
|
+
# Builds the object from hash
|
83
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
84
|
+
# @return [Object] Returns the model itself
|
85
|
+
def build_from_hash(attributes)
|
86
|
+
return nil unless attributes.is_a?(Hash)
|
87
|
+
self.class.zip_types.each_pair do |key, type|
|
88
|
+
if type =~ /\AArray<(.*)>/i
|
89
|
+
# check to ensure the input is an array given that the the attribute
|
90
|
+
# is documented as an array but the input is not
|
91
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
93
|
+
end
|
94
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
95
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
96
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
97
|
+
end
|
98
|
+
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# Deserializes the data based on type
|
103
|
+
# @param string type Data type
|
104
|
+
# @param string value Value to be deserialized
|
105
|
+
# @return [Object] Deserialized data
|
106
|
+
def _deserialize(type, value)
|
107
|
+
case type.to_sym
|
108
|
+
when :DateTime
|
109
|
+
DateTime.parse(value)
|
110
|
+
when :Date
|
111
|
+
Date.parse(value)
|
112
|
+
when :String
|
113
|
+
value.to_s
|
114
|
+
when :Integer
|
115
|
+
value.to_i
|
116
|
+
when :Float
|
117
|
+
value.to_f
|
118
|
+
when :BOOLEAN
|
119
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
120
|
+
true
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
when :Object
|
125
|
+
# generic object (usually a Hash), return directly
|
126
|
+
value
|
127
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
128
|
+
inner_type = Regexp.last_match[:inner_type]
|
129
|
+
value.map { |v| _deserialize(inner_type, v) }
|
130
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
131
|
+
k_type = Regexp.last_match[:k_type]
|
132
|
+
v_type = Regexp.last_match[:v_type]
|
133
|
+
{}.tap do |hash|
|
134
|
+
value.each do |k, v|
|
135
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
else # model
|
139
|
+
temp_model = ZipMoney.const_get(type).new
|
140
|
+
temp_model.build_from_hash(value)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the string representation of the object
|
145
|
+
# @return [String] String presentation of the object
|
146
|
+
def to_s
|
147
|
+
to_hash.to_s
|
148
|
+
end
|
149
|
+
|
150
|
+
# to_body is an alias to to_hash (backward compatibility)
|
151
|
+
# @return [Hash] Returns the object in the form of hash
|
152
|
+
def to_body
|
153
|
+
to_hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the object in the form of hash
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_hash
|
159
|
+
hash = {}
|
160
|
+
self.class.attribute_map.each_pair do |attr, param|
|
161
|
+
value = self.send(attr)
|
162
|
+
next if value.nil?
|
163
|
+
hash[param] = _to_hash(value)
|
164
|
+
end
|
165
|
+
hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Outputs non-array value in the form of hash
|
169
|
+
# For object, use to_hash. Otherwise, just return the value
|
170
|
+
# @param [Object] value Any valid value
|
171
|
+
# @return [Hash] Returns the value in the form of hash
|
172
|
+
def _to_hash(value)
|
173
|
+
if value.is_a?(Array)
|
174
|
+
value.compact.map{ |v| _to_hash(v) }
|
175
|
+
elsif value.is_a?(Hash)
|
176
|
+
{}.tap do |hash|
|
177
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
178
|
+
end
|
179
|
+
elsif value.respond_to? :to_hash
|
180
|
+
value.to_hash
|
181
|
+
else
|
182
|
+
value
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|