noths 0.1.0

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