noths 0.1.0
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 +149 -0
- data/Rakefile +8 -0
- data/bin/generate_gem +18 -0
- data/bin/refresh_schemas +94 -0
- data/docs/AcceptanceBulkModel.md +11 -0
- data/docs/Currency.md +11 -0
- data/docs/DeclineBulkModel.md +9 -0
- data/docs/DeliveryAddress.md +13 -0
- data/docs/DeliveryService.md +9 -0
- data/docs/DeliveryZone.md +9 -0
- data/docs/DispatchBulkModel.md +12 -0
- data/docs/DispatchNotesBulkModel.md +8 -0
- data/docs/Enquiry.md +10 -0
- data/docs/EnquiryMessage.md +8 -0
- data/docs/Error.md +9 -0
- data/docs/Financials.md +25 -0
- data/docs/FinancialsDetails.md +10 -0
- data/docs/ImageUrl.md +13 -0
- data/docs/Item.md +15 -0
- data/docs/ItemFinancials.md +13 -0
- data/docs/Link.md +10 -0
- data/docs/ManualPayment.md +11 -0
- data/docs/Money.md +9 -0
- data/docs/Order.md +53 -0
- data/docs/OrderDetail.md +9 -0
- data/docs/OrderDetailsBulkModel.md +8 -0
- data/docs/OrderIndex.md +10 -0
- data/docs/OrderRefund.md +8 -0
- data/docs/OrdersApi.md +796 -0
- data/docs/Product.md +12 -0
- data/docs/ProductOption.md +9 -0
- data/docs/RefundResponse.md +10 -0
- data/docs/RefundsApi.md +69 -0
- data/docs/SearchResultMeta.md +9 -0
- data/docs/User.md +10 -0
- data/lib/noths.rb +70 -0
- data/lib/noths/api/orders_api.rb +819 -0
- data/lib/noths/api/refunds_api.rb +88 -0
- data/lib/noths/api_client.rb +389 -0
- data/lib/noths/api_error.rb +38 -0
- data/lib/noths/configuration.rb +209 -0
- data/lib/noths/models/acceptance_bulk_model.rb +233 -0
- data/lib/noths/models/currency.rb +235 -0
- data/lib/noths/models/decline_bulk_model.rb +208 -0
- data/lib/noths/models/delivery_address.rb +263 -0
- data/lib/noths/models/delivery_service.rb +207 -0
- data/lib/noths/models/delivery_zone.rb +207 -0
- data/lib/noths/models/dispatch_bulk_model.rb +236 -0
- data/lib/noths/models/dispatch_notes_bulk_model.rb +194 -0
- data/lib/noths/models/enquiry.rb +223 -0
- data/lib/noths/models/enquiry_message.rb +193 -0
- data/lib/noths/models/error.rb +207 -0
- data/lib/noths/models/financials.rb +433 -0
- data/lib/noths/models/financials_details.rb +221 -0
- data/lib/noths/models/image_url.rb +263 -0
- data/lib/noths/models/item.rb +293 -0
- data/lib/noths/models/item_financials.rb +263 -0
- data/lib/noths/models/link.rb +222 -0
- data/lib/noths/models/manual_payment.rb +235 -0
- data/lib/noths/models/money.rb +207 -0
- data/lib/noths/models/order.rb +812 -0
- data/lib/noths/models/order_detail.rb +207 -0
- data/lib/noths/models/order_details_bulk_model.rb +194 -0
- data/lib/noths/models/order_index.rb +225 -0
- data/lib/noths/models/order_refund.rb +193 -0
- data/lib/noths/models/product.rb +249 -0
- data/lib/noths/models/product_option.rb +207 -0
- data/lib/noths/models/refund_response.rb +223 -0
- data/lib/noths/models/search_result_meta.rb +207 -0
- data/lib/noths/models/user.rb +221 -0
- data/lib/noths/version.rb +15 -0
- data/noths.gemspec +45 -0
- data/schemas/api-docs.json +26 -0
- data/schemas/orders.json +2013 -0
- data/schemas/refunds.json +128 -0
- data/spec/api/orders_api_spec.rb +239 -0
- data/spec/api/refunds_api_spec.rb +50 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/acceptance_bulk_model_spec.rb +60 -0
- data/spec/models/currency_spec.rb +60 -0
- data/spec/models/decline_bulk_model_spec.rb +48 -0
- data/spec/models/delivery_address_spec.rb +72 -0
- data/spec/models/delivery_service_spec.rb +48 -0
- data/spec/models/delivery_zone_spec.rb +48 -0
- data/spec/models/dispatch_bulk_model_spec.rb +66 -0
- data/spec/models/dispatch_notes_bulk_model_spec.rb +42 -0
- data/spec/models/enquiry_message_spec.rb +42 -0
- data/spec/models/enquiry_spec.rb +54 -0
- data/spec/models/error_spec.rb +48 -0
- data/spec/models/financials_details_spec.rb +54 -0
- data/spec/models/financials_spec.rb +144 -0
- data/spec/models/image_url_spec.rb +72 -0
- data/spec/models/item_financials_spec.rb +72 -0
- data/spec/models/item_spec.rb +84 -0
- data/spec/models/link_spec.rb +54 -0
- data/spec/models/manual_payment_spec.rb +60 -0
- data/spec/models/money_spec.rb +48 -0
- data/spec/models/order_detail_spec.rb +48 -0
- data/spec/models/order_details_bulk_model_spec.rb +42 -0
- data/spec/models/order_index_spec.rb +54 -0
- data/spec/models/order_refund_spec.rb +42 -0
- data/spec/models/order_spec.rb +312 -0
- data/spec/models/product_option_spec.rb +48 -0
- data/spec/models/product_spec.rb +66 -0
- data/spec/models/refund_response_spec.rb +54 -0
- data/spec/models/search_result_meta_spec.rb +48 -0
- data/spec/models/user_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger_config.json +16 -0
- metadata +370 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class RefundResponse
|
18
|
+
attr_accessor :status
|
19
|
+
|
20
|
+
attr_accessor :errors
|
21
|
+
|
22
|
+
attr_accessor :order_refund
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'status' => :'status',
|
29
|
+
:'errors' => :'errors',
|
30
|
+
:'order_refund' => :'order_refund'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.swagger_types
|
36
|
+
{
|
37
|
+
:'status' => :'Integer',
|
38
|
+
:'errors' => :'Array<Error>',
|
39
|
+
:'order_refund' => :'OrderRefund'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
return unless attributes.is_a?(Hash)
|
47
|
+
|
48
|
+
# convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
50
|
+
|
51
|
+
if attributes.has_key?(:'status')
|
52
|
+
self.status = attributes[:'status']
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes.has_key?(:'errors')
|
56
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
57
|
+
self.errors = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.has_key?(:'order_refund')
|
62
|
+
self.order_refund = attributes[:'order_refund']
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
68
|
+
# @return Array for valid properties with the reasons
|
69
|
+
def list_invalid_properties
|
70
|
+
invalid_properties = Array.new
|
71
|
+
if @status.nil?
|
72
|
+
invalid_properties.push("invalid value for 'status', status cannot be nil.")
|
73
|
+
end
|
74
|
+
|
75
|
+
if @errors.nil?
|
76
|
+
invalid_properties.push("invalid value for 'errors', errors cannot be nil.")
|
77
|
+
end
|
78
|
+
|
79
|
+
if @order_refund.nil?
|
80
|
+
invalid_properties.push("invalid value for 'order_refund', order_refund cannot be nil.")
|
81
|
+
end
|
82
|
+
|
83
|
+
return invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
return false if @status.nil?
|
90
|
+
return false if @errors.nil?
|
91
|
+
return false if @order_refund.nil?
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Checks equality by comparing each attribute.
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def ==(o)
|
98
|
+
return true if self.equal?(o)
|
99
|
+
self.class == o.class &&
|
100
|
+
status == o.status &&
|
101
|
+
errors == o.errors &&
|
102
|
+
order_refund == o.order_refund
|
103
|
+
end
|
104
|
+
|
105
|
+
# @see the `==` method
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def eql?(o)
|
108
|
+
self == o
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculates hash code according to all attributes.
|
112
|
+
# @return [Fixnum] Hash code
|
113
|
+
def hash
|
114
|
+
[status, errors, order_refund].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def build_from_hash(attributes)
|
121
|
+
return nil unless attributes.is_a?(Hash)
|
122
|
+
self.class.swagger_types.each_pair do |key, type|
|
123
|
+
if type =~ /\AArray<(.*)>/i
|
124
|
+
# check to ensure the input is an array given that the the attribute
|
125
|
+
# is documented as an array but the input is not
|
126
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
127
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
128
|
+
end
|
129
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
130
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
131
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
132
|
+
end
|
133
|
+
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
# Deserializes the data based on type
|
138
|
+
# @param string type Data type
|
139
|
+
# @param string value Value to be deserialized
|
140
|
+
# @return [Object] Deserialized data
|
141
|
+
def _deserialize(type, value)
|
142
|
+
case type.to_sym
|
143
|
+
when :DateTime
|
144
|
+
DateTime.parse(value)
|
145
|
+
when :Date
|
146
|
+
Date.parse(value)
|
147
|
+
when :String
|
148
|
+
value.to_s
|
149
|
+
when :Integer
|
150
|
+
value.to_i
|
151
|
+
when :Float
|
152
|
+
value.to_f
|
153
|
+
when :BOOLEAN
|
154
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
155
|
+
true
|
156
|
+
else
|
157
|
+
false
|
158
|
+
end
|
159
|
+
when :Object
|
160
|
+
# generic object (usually a Hash), return directly
|
161
|
+
value
|
162
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
163
|
+
inner_type = Regexp.last_match[:inner_type]
|
164
|
+
value.map { |v| _deserialize(inner_type, v) }
|
165
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
166
|
+
k_type = Regexp.last_match[:k_type]
|
167
|
+
v_type = Regexp.last_match[:v_type]
|
168
|
+
{}.tap do |hash|
|
169
|
+
value.each do |k, v|
|
170
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
else # model
|
174
|
+
temp_model = Noths.const_get(type).new
|
175
|
+
temp_model.build_from_hash(value)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the string representation of the object
|
180
|
+
# @return [String] String presentation of the object
|
181
|
+
def to_s
|
182
|
+
to_hash.to_s
|
183
|
+
end
|
184
|
+
|
185
|
+
# to_body is an alias to to_hash (backward compatibility)
|
186
|
+
# @return [Hash] Returns the object in the form of hash
|
187
|
+
def to_body
|
188
|
+
to_hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the object in the form of hash
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_hash
|
194
|
+
hash = {}
|
195
|
+
self.class.attribute_map.each_pair do |attr, param|
|
196
|
+
value = self.send(attr)
|
197
|
+
next if value.nil?
|
198
|
+
hash[param] = _to_hash(value)
|
199
|
+
end
|
200
|
+
hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Outputs non-array value in the form of hash
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
205
|
+
# @param [Object] value Any valid value
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
207
|
+
def _to_hash(value)
|
208
|
+
if value.is_a?(Array)
|
209
|
+
value.compact.map{ |v| _to_hash(v) }
|
210
|
+
elsif value.is_a?(Hash)
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
213
|
+
end
|
214
|
+
elsif value.respond_to? :to_hash
|
215
|
+
value.to_hash
|
216
|
+
else
|
217
|
+
value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class SearchResultMeta
|
18
|
+
attr_accessor :results
|
19
|
+
|
20
|
+
attr_accessor :total
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'results' => :'results',
|
27
|
+
:'total' => :'total'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.swagger_types
|
33
|
+
{
|
34
|
+
:'results' => :'Integer',
|
35
|
+
:'total' => :'Integer'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
46
|
+
|
47
|
+
if attributes.has_key?(:'results')
|
48
|
+
self.results = attributes[:'results']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'total')
|
52
|
+
self.total = attributes[:'total']
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
58
|
+
# @return Array for valid properties with the reasons
|
59
|
+
def list_invalid_properties
|
60
|
+
invalid_properties = Array.new
|
61
|
+
if @results.nil?
|
62
|
+
invalid_properties.push("invalid value for 'results', results cannot be nil.")
|
63
|
+
end
|
64
|
+
|
65
|
+
if @total.nil?
|
66
|
+
invalid_properties.push("invalid value for 'total', total cannot be nil.")
|
67
|
+
end
|
68
|
+
|
69
|
+
return invalid_properties
|
70
|
+
end
|
71
|
+
|
72
|
+
# Check to see if the all the properties in the model are valid
|
73
|
+
# @return true if the model is valid
|
74
|
+
def valid?
|
75
|
+
return false if @results.nil?
|
76
|
+
return false if @total.nil?
|
77
|
+
return true
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks equality by comparing each attribute.
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def ==(o)
|
83
|
+
return true if self.equal?(o)
|
84
|
+
self.class == o.class &&
|
85
|
+
results == o.results &&
|
86
|
+
total == o.total
|
87
|
+
end
|
88
|
+
|
89
|
+
# @see the `==` method
|
90
|
+
# @param [Object] Object to be compared
|
91
|
+
def eql?(o)
|
92
|
+
self == o
|
93
|
+
end
|
94
|
+
|
95
|
+
# Calculates hash code according to all attributes.
|
96
|
+
# @return [Fixnum] Hash code
|
97
|
+
def hash
|
98
|
+
[results, total].hash
|
99
|
+
end
|
100
|
+
|
101
|
+
# Builds the object from hash
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
# @return [Object] Returns the model itself
|
104
|
+
def build_from_hash(attributes)
|
105
|
+
return nil unless attributes.is_a?(Hash)
|
106
|
+
self.class.swagger_types.each_pair do |key, type|
|
107
|
+
if type =~ /\AArray<(.*)>/i
|
108
|
+
# check to ensure the input is an array given that the the attribute
|
109
|
+
# is documented as an array but the input is not
|
110
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
111
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
112
|
+
end
|
113
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
114
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
115
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
116
|
+
end
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
# Deserializes the data based on type
|
122
|
+
# @param string type Data type
|
123
|
+
# @param string value Value to be deserialized
|
124
|
+
# @return [Object] Deserialized data
|
125
|
+
def _deserialize(type, value)
|
126
|
+
case type.to_sym
|
127
|
+
when :DateTime
|
128
|
+
DateTime.parse(value)
|
129
|
+
when :Date
|
130
|
+
Date.parse(value)
|
131
|
+
when :String
|
132
|
+
value.to_s
|
133
|
+
when :Integer
|
134
|
+
value.to_i
|
135
|
+
when :Float
|
136
|
+
value.to_f
|
137
|
+
when :BOOLEAN
|
138
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
139
|
+
true
|
140
|
+
else
|
141
|
+
false
|
142
|
+
end
|
143
|
+
when :Object
|
144
|
+
# generic object (usually a Hash), return directly
|
145
|
+
value
|
146
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
147
|
+
inner_type = Regexp.last_match[:inner_type]
|
148
|
+
value.map { |v| _deserialize(inner_type, v) }
|
149
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
150
|
+
k_type = Regexp.last_match[:k_type]
|
151
|
+
v_type = Regexp.last_match[:v_type]
|
152
|
+
{}.tap do |hash|
|
153
|
+
value.each do |k, v|
|
154
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
else # model
|
158
|
+
temp_model = Noths.const_get(type).new
|
159
|
+
temp_model.build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the string representation of the object
|
164
|
+
# @return [String] String presentation of the object
|
165
|
+
def to_s
|
166
|
+
to_hash.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
# to_body is an alias to to_hash (backward compatibility)
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_body
|
172
|
+
to_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the object in the form of hash
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Outputs non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
# @param [Object] value Any valid value
|
190
|
+
# @return [Hash] Returns the value in the form of hash
|
191
|
+
def _to_hash(value)
|
192
|
+
if value.is_a?(Array)
|
193
|
+
value.compact.map{ |v| _to_hash(v) }
|
194
|
+
elsif value.is_a?(Hash)
|
195
|
+
{}.tap do |hash|
|
196
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
197
|
+
end
|
198
|
+
elsif value.respond_to? :to_hash
|
199
|
+
value.to_hash
|
200
|
+
else
|
201
|
+
value
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class User
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
attr_accessor :telephone
|
21
|
+
|
22
|
+
attr_accessor :telephone_country_code
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'name' => :'name',
|
29
|
+
:'telephone' => :'telephone',
|
30
|
+
:'telephone_country_code' => :'telephone_country_code'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.swagger_types
|
36
|
+
{
|
37
|
+
:'name' => :'String',
|
38
|
+
:'telephone' => :'String',
|
39
|
+
:'telephone_country_code' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
return unless attributes.is_a?(Hash)
|
47
|
+
|
48
|
+
# convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
50
|
+
|
51
|
+
if attributes.has_key?(:'name')
|
52
|
+
self.name = attributes[:'name']
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes.has_key?(:'telephone')
|
56
|
+
self.telephone = attributes[:'telephone']
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.has_key?(:'telephone_country_code')
|
60
|
+
self.telephone_country_code = attributes[:'telephone_country_code']
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properties with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
invalid_properties = Array.new
|
69
|
+
if @name.nil?
|
70
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
71
|
+
end
|
72
|
+
|
73
|
+
if @telephone.nil?
|
74
|
+
invalid_properties.push("invalid value for 'telephone', telephone cannot be nil.")
|
75
|
+
end
|
76
|
+
|
77
|
+
if @telephone_country_code.nil?
|
78
|
+
invalid_properties.push("invalid value for 'telephone_country_code', telephone_country_code cannot be nil.")
|
79
|
+
end
|
80
|
+
|
81
|
+
return invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
return false if @name.nil?
|
88
|
+
return false if @telephone.nil?
|
89
|
+
return false if @telephone_country_code.nil?
|
90
|
+
return true
|
91
|
+
end
|
92
|
+
|
93
|
+
# Checks equality by comparing each attribute.
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def ==(o)
|
96
|
+
return true if self.equal?(o)
|
97
|
+
self.class == o.class &&
|
98
|
+
name == o.name &&
|
99
|
+
telephone == o.telephone &&
|
100
|
+
telephone_country_code == o.telephone_country_code
|
101
|
+
end
|
102
|
+
|
103
|
+
# @see the `==` method
|
104
|
+
# @param [Object] Object to be compared
|
105
|
+
def eql?(o)
|
106
|
+
self == o
|
107
|
+
end
|
108
|
+
|
109
|
+
# Calculates hash code according to all attributes.
|
110
|
+
# @return [Fixnum] Hash code
|
111
|
+
def hash
|
112
|
+
[name, telephone, telephone_country_code].hash
|
113
|
+
end
|
114
|
+
|
115
|
+
# Builds the object from hash
|
116
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
117
|
+
# @return [Object] Returns the model itself
|
118
|
+
def build_from_hash(attributes)
|
119
|
+
return nil unless attributes.is_a?(Hash)
|
120
|
+
self.class.swagger_types.each_pair do |key, type|
|
121
|
+
if type =~ /\AArray<(.*)>/i
|
122
|
+
# check to ensure the input is an array given that the the attribute
|
123
|
+
# is documented as an array but the input is not
|
124
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
125
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
126
|
+
end
|
127
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
128
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
129
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
130
|
+
end
|
131
|
+
|
132
|
+
self
|
133
|
+
end
|
134
|
+
|
135
|
+
# Deserializes the data based on type
|
136
|
+
# @param string type Data type
|
137
|
+
# @param string value Value to be deserialized
|
138
|
+
# @return [Object] Deserialized data
|
139
|
+
def _deserialize(type, value)
|
140
|
+
case type.to_sym
|
141
|
+
when :DateTime
|
142
|
+
DateTime.parse(value)
|
143
|
+
when :Date
|
144
|
+
Date.parse(value)
|
145
|
+
when :String
|
146
|
+
value.to_s
|
147
|
+
when :Integer
|
148
|
+
value.to_i
|
149
|
+
when :Float
|
150
|
+
value.to_f
|
151
|
+
when :BOOLEAN
|
152
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
153
|
+
true
|
154
|
+
else
|
155
|
+
false
|
156
|
+
end
|
157
|
+
when :Object
|
158
|
+
# generic object (usually a Hash), return directly
|
159
|
+
value
|
160
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
161
|
+
inner_type = Regexp.last_match[:inner_type]
|
162
|
+
value.map { |v| _deserialize(inner_type, v) }
|
163
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
164
|
+
k_type = Regexp.last_match[:k_type]
|
165
|
+
v_type = Regexp.last_match[:v_type]
|
166
|
+
{}.tap do |hash|
|
167
|
+
value.each do |k, v|
|
168
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
else # model
|
172
|
+
temp_model = Noths.const_get(type).new
|
173
|
+
temp_model.build_from_hash(value)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Returns the string representation of the object
|
178
|
+
# @return [String] String presentation of the object
|
179
|
+
def to_s
|
180
|
+
to_hash.to_s
|
181
|
+
end
|
182
|
+
|
183
|
+
# to_body is an alias to to_hash (backward compatibility)
|
184
|
+
# @return [Hash] Returns the object in the form of hash
|
185
|
+
def to_body
|
186
|
+
to_hash
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the object in the form of hash
|
190
|
+
# @return [Hash] Returns the object in the form of hash
|
191
|
+
def to_hash
|
192
|
+
hash = {}
|
193
|
+
self.class.attribute_map.each_pair do |attr, param|
|
194
|
+
value = self.send(attr)
|
195
|
+
next if value.nil?
|
196
|
+
hash[param] = _to_hash(value)
|
197
|
+
end
|
198
|
+
hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Outputs non-array value in the form of hash
|
202
|
+
# For object, use to_hash. Otherwise, just return the value
|
203
|
+
# @param [Object] value Any valid value
|
204
|
+
# @return [Hash] Returns the value in the form of hash
|
205
|
+
def _to_hash(value)
|
206
|
+
if value.is_a?(Array)
|
207
|
+
value.compact.map{ |v| _to_hash(v) }
|
208
|
+
elsif value.is_a?(Hash)
|
209
|
+
{}.tap do |hash|
|
210
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
211
|
+
end
|
212
|
+
elsif value.respond_to? :to_hash
|
213
|
+
value.to_hash
|
214
|
+
else
|
215
|
+
value
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|