marketcheck_ruby_client 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +133 -0
  3. data/docs/Averages.md +13 -0
  4. data/docs/BaseListing.md +27 -0
  5. data/docs/Build.md +19 -0
  6. data/docs/Dealer.md +23 -0
  7. data/docs/DealerApi.md +230 -0
  8. data/docs/Error.md +9 -0
  9. data/docs/FacetItem.md +9 -0
  10. data/docs/FacetsApi.md +71 -0
  11. data/docs/GraphsApi.md +73 -0
  12. data/docs/HistoricalListing.md +19 -0
  13. data/docs/HistoryApi.md +65 -0
  14. data/docs/InventoryApi.md +113 -0
  15. data/docs/Listing.md +23 -0
  16. data/docs/ListingDebugAttributes.md +13 -0
  17. data/docs/ListingExtraAttributes.md +10 -0
  18. data/docs/ListingMedia.md +9 -0
  19. data/docs/ListingVDP.md +10 -0
  20. data/docs/ListingsApi.md +324 -0
  21. data/docs/Location.md +12 -0
  22. data/docs/MakeModel.md +9 -0
  23. data/docs/MarketAveragesApi.md +70 -0
  24. data/docs/MarketTrendsApi.md +72 -0
  25. data/docs/PlotPoint.md +14 -0
  26. data/docs/SearchResponse.md +9 -0
  27. data/docs/TrendPoint.md +12 -0
  28. data/docs/VINDecoderApi.md +59 -0
  29. data/git_push.sh +52 -0
  30. data/lib/marketcheck_ruby_client.rb +65 -0
  31. data/lib/swagger_client/api/dealer_api.rb +312 -0
  32. data/lib/swagger_client/api/facets_api.rb +105 -0
  33. data/lib/swagger_client/api/graphs_api.rb +108 -0
  34. data/lib/swagger_client/api/history_api.rb +95 -0
  35. data/lib/swagger_client/api/inventory_api.rb +155 -0
  36. data/lib/swagger_client/api/listings_api.rb +474 -0
  37. data/lib/swagger_client/api/market_averages_api.rb +102 -0
  38. data/lib/swagger_client/api/market_trends_api.rb +108 -0
  39. data/lib/swagger_client/api/vin_decoder_api.rb +89 -0
  40. data/lib/swagger_client/api_client.rb +332 -0
  41. data/lib/swagger_client/api_error.rb +36 -0
  42. data/lib/swagger_client/configuration.rb +163 -0
  43. data/lib/swagger_client/models/averages.rb +217 -0
  44. data/lib/swagger_client/models/base_listing.rb +370 -0
  45. data/lib/swagger_client/models/build.rb +284 -0
  46. data/lib/swagger_client/models/dealer.rb +329 -0
  47. data/lib/swagger_client/models/error.rb +173 -0
  48. data/lib/swagger_client/models/facet_item.rb +173 -0
  49. data/lib/swagger_client/models/historical_listing.rb +284 -0
  50. data/lib/swagger_client/models/listing.rb +327 -0
  51. data/lib/swagger_client/models/listing_debug_attributes.rb +217 -0
  52. data/lib/swagger_client/models/listing_extra_attributes.rb +188 -0
  53. data/lib/swagger_client/models/listing_media.rb +175 -0
  54. data/lib/swagger_client/models/listing_vdp.rb +185 -0
  55. data/lib/swagger_client/models/location.rb +207 -0
  56. data/lib/swagger_client/models/make_model.rb +171 -0
  57. data/lib/swagger_client/models/plot_point.rb +228 -0
  58. data/lib/swagger_client/models/search_response.rb +175 -0
  59. data/lib/swagger_client/models/trend_point.rb +206 -0
  60. data/lib/swagger_client/version.rb +15 -0
  61. data/marketcheck_ruby_client-1.0.6.gem +0 -0
  62. data/marketcheck_ruby_client.gemspec +32 -0
  63. data/spec/api/dealer_api_spec.rb +109 -0
  64. data/spec/api/facets_api_spec.rb +57 -0
  65. data/spec/api/graphs_api_spec.rb +58 -0
  66. data/spec/api/history_api_spec.rb +54 -0
  67. data/spec/api/inventory_api_spec.rb +70 -0
  68. data/spec/api/listings_api_spec.rb +148 -0
  69. data/spec/api/market_averages_api_spec.rb +57 -0
  70. data/spec/api/market_trends_api_spec.rb +57 -0
  71. data/spec/api/vin_decoder_api_spec.rb +52 -0
  72. data/spec/models/averages_spec.rb +96 -0
  73. data/spec/models/base_listing_spec.rb +236 -0
  74. data/spec/models/build_spec.rb +156 -0
  75. data/spec/models/dealer_spec.rb +196 -0
  76. data/spec/models/error_spec.rb +56 -0
  77. data/spec/models/facet_item_spec.rb +56 -0
  78. data/spec/models/historical_listing_spec.rb +156 -0
  79. data/spec/models/listing_debug_attributes_spec.rb +96 -0
  80. data/spec/models/listing_extra_attributes_spec.rb +66 -0
  81. data/spec/models/listing_media_spec.rb +56 -0
  82. data/spec/models/listing_spec.rb +196 -0
  83. data/spec/models/listing_vdp_spec.rb +66 -0
  84. data/spec/models/location_spec.rb +86 -0
  85. data/spec/models/make_model_spec.rb +56 -0
  86. data/spec/models/plot_point_spec.rb +106 -0
  87. data/spec/models/search_response_spec.rb +56 -0
  88. data/spec/models/trend_point_spec.rb +86 -0
  89. metadata +337 -0
@@ -0,0 +1,173 @@
1
+ =begin
2
+ Marketcheck Cars API
3
+
4
+ <b>Access the New, Used and Certified cars inventories for all Car Dealers in US.</b> <br/>The data is sourced from online listings by over 40,000 Car dealers in US. At any time, there are about 5.2M searchable listings (about 1.8M unique VINs) for Used & Certified cars and about 5M (about 2.3M unique VINs) New Car listings from all over US. We use this API at the back for our website <a href='http://www.marketcheck.com' target='_blank'>www.marketcheck.com</a> and our Android and iOS mobile apps too.<br/><h5> Few useful links : </h5><ul><li>A quick view of the API and the use cases is depicated <a href='https://portals.marketcheck.com/mcapi/' target='_blank'>here</a></li><li>The Postman collection with various usages of the API is shared here https://www.getpostman.com/collections/2752684ff636cdd7bac2</li><li> [Coming soon] API Key : Request your API Key <a href='https://portals.marketcheck.com/api' target='_blank'> here </a> </li><li> [Coming soon] Benchmarks : See the API benchmarks <a href='https://portals.marketcheck.com/mcapi/benchmarks'>here</a></li></ul>
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SwaggerClient
16
+ class Error
17
+ # Error code
18
+ attr_accessor :status
19
+
20
+ # Error message
21
+ attr_accessor :message
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+
27
+ :'status' => :'status',
28
+
29
+ :'message' => :'message'
30
+
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'status' => :'Float',
38
+ :'message' => :'String'
39
+
40
+ }
41
+ end
42
+
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
48
+
49
+
50
+ if attributes[:'status']
51
+ self.status = attributes[:'status']
52
+ end
53
+
54
+ if attributes[:'message']
55
+ self.message = attributes[:'message']
56
+ end
57
+
58
+ end
59
+
60
+ # Check equality by comparing each attribute.
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ status == o.status &&
65
+ message == o.message
66
+ end
67
+
68
+ # @see the `==` method
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculate hash code according to all attributes.
74
+ def hash
75
+ [status, message].hash
76
+ end
77
+
78
+ # build the object from hash
79
+ def build_from_hash(attributes)
80
+ return nil unless attributes.is_a?(Hash)
81
+ self.class.swagger_types.each_pair do |key, type|
82
+ if type =~ /^Array<(.*)>/i
83
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
84
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
85
+ else
86
+ #TODO show warning in debug mode
87
+ end
88
+ elsif !attributes[self.class.attribute_map[key]].nil?
89
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
90
+ else
91
+ # data not found in attributes(hash), not an issue as the data can be optional
92
+ end
93
+ end
94
+
95
+ self
96
+ end
97
+
98
+ def _deserialize(type, value)
99
+ case type.to_sym
100
+ when :DateTime
101
+ DateTime.parse(value)
102
+ when :Date
103
+ Date.parse(value)
104
+ when :String
105
+ value.to_s
106
+ when :Integer
107
+ value.to_i
108
+ when :Float
109
+ value.to_f
110
+ when :BOOLEAN
111
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
112
+ true
113
+ else
114
+ false
115
+ end
116
+ when :Object
117
+ # generic object (usually a Hash), return directly
118
+ value
119
+ when /\AArray<(?<inner_type>.+)>\z/
120
+ inner_type = Regexp.last_match[:inner_type]
121
+ value.map { |v| _deserialize(inner_type, v) }
122
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
123
+ k_type = Regexp.last_match[:k_type]
124
+ v_type = Regexp.last_match[:v_type]
125
+ {}.tap do |hash|
126
+ value.each do |k, v|
127
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
128
+ end
129
+ end
130
+ else # model
131
+ _model = SwaggerClient.const_get(type).new
132
+ _model.build_from_hash(value)
133
+ end
134
+ end
135
+
136
+ def to_s
137
+ to_hash.to_s
138
+ end
139
+
140
+ # to_body is an alias to to_body (backward compatibility))
141
+ def to_body
142
+ to_hash
143
+ end
144
+
145
+ # return the object in the form of hash
146
+ def to_hash
147
+ hash = {}
148
+ self.class.attribute_map.each_pair do |attr, param|
149
+ value = self.send(attr)
150
+ next if value.nil?
151
+ hash[param] = _to_hash(value)
152
+ end
153
+ hash
154
+ end
155
+
156
+ # Method to output non-array value in the form of hash
157
+ # For object, use to_hash. Otherwise, just return the value
158
+ def _to_hash(value)
159
+ if value.is_a?(Array)
160
+ value.compact.map{ |v| _to_hash(v) }
161
+ elsif value.is_a?(Hash)
162
+ {}.tap do |hash|
163
+ value.each { |k, v| hash[k] = _to_hash(v) }
164
+ end
165
+ elsif value.respond_to? :to_hash
166
+ value.to_hash
167
+ else
168
+ value
169
+ end
170
+ end
171
+
172
+ end
173
+ end
@@ -0,0 +1,173 @@
1
+ =begin
2
+ Marketcheck Cars API
3
+
4
+ <b>Access the New, Used and Certified cars inventories for all Car Dealers in US.</b> <br/>The data is sourced from online listings by over 40,000 Car dealers in US. At any time, there are about 5.2M searchable listings (about 1.8M unique VINs) for Used & Certified cars and about 5M (about 2.3M unique VINs) New Car listings from all over US. We use this API at the back for our website <a href='http://www.marketcheck.com' target='_blank'>www.marketcheck.com</a> and our Android and iOS mobile apps too.<br/><h5> Few useful links : </h5><ul><li>A quick view of the API and the use cases is depicated <a href='https://portals.marketcheck.com/mcapi/' target='_blank'>here</a></li><li>The Postman collection with various usages of the API is shared here https://www.getpostman.com/collections/2752684ff636cdd7bac2</li><li> [Coming soon] API Key : Request your API Key <a href='https://portals.marketcheck.com/api' target='_blank'> here </a> </li><li> [Coming soon] Benchmarks : See the API benchmarks <a href='https://portals.marketcheck.com/mcapi/benchmarks'>here</a></li></ul>
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SwaggerClient
16
+ class FacetItem
17
+ # Facet item
18
+ attr_accessor :item
19
+
20
+ # Facet item count
21
+ attr_accessor :count
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+
27
+ :'item' => :'item',
28
+
29
+ :'count' => :'count'
30
+
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'item' => :'String',
38
+ :'count' => :'Float'
39
+
40
+ }
41
+ end
42
+
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
48
+
49
+
50
+ if attributes[:'item']
51
+ self.item = attributes[:'item']
52
+ end
53
+
54
+ if attributes[:'count']
55
+ self.count = attributes[:'count']
56
+ end
57
+
58
+ end
59
+
60
+ # Check equality by comparing each attribute.
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ item == o.item &&
65
+ count == o.count
66
+ end
67
+
68
+ # @see the `==` method
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculate hash code according to all attributes.
74
+ def hash
75
+ [item, count].hash
76
+ end
77
+
78
+ # build the object from hash
79
+ def build_from_hash(attributes)
80
+ return nil unless attributes.is_a?(Hash)
81
+ self.class.swagger_types.each_pair do |key, type|
82
+ if type =~ /^Array<(.*)>/i
83
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
84
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
85
+ else
86
+ #TODO show warning in debug mode
87
+ end
88
+ elsif !attributes[self.class.attribute_map[key]].nil?
89
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
90
+ else
91
+ # data not found in attributes(hash), not an issue as the data can be optional
92
+ end
93
+ end
94
+
95
+ self
96
+ end
97
+
98
+ def _deserialize(type, value)
99
+ case type.to_sym
100
+ when :DateTime
101
+ DateTime.parse(value)
102
+ when :Date
103
+ Date.parse(value)
104
+ when :String
105
+ value.to_s
106
+ when :Integer
107
+ value.to_i
108
+ when :Float
109
+ value.to_f
110
+ when :BOOLEAN
111
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
112
+ true
113
+ else
114
+ false
115
+ end
116
+ when :Object
117
+ # generic object (usually a Hash), return directly
118
+ value
119
+ when /\AArray<(?<inner_type>.+)>\z/
120
+ inner_type = Regexp.last_match[:inner_type]
121
+ value.map { |v| _deserialize(inner_type, v) }
122
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
123
+ k_type = Regexp.last_match[:k_type]
124
+ v_type = Regexp.last_match[:v_type]
125
+ {}.tap do |hash|
126
+ value.each do |k, v|
127
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
128
+ end
129
+ end
130
+ else # model
131
+ _model = SwaggerClient.const_get(type).new
132
+ _model.build_from_hash(value)
133
+ end
134
+ end
135
+
136
+ def to_s
137
+ to_hash.to_s
138
+ end
139
+
140
+ # to_body is an alias to to_body (backward compatibility))
141
+ def to_body
142
+ to_hash
143
+ end
144
+
145
+ # return the object in the form of hash
146
+ def to_hash
147
+ hash = {}
148
+ self.class.attribute_map.each_pair do |attr, param|
149
+ value = self.send(attr)
150
+ next if value.nil?
151
+ hash[param] = _to_hash(value)
152
+ end
153
+ hash
154
+ end
155
+
156
+ # Method to output non-array value in the form of hash
157
+ # For object, use to_hash. Otherwise, just return the value
158
+ def _to_hash(value)
159
+ if value.is_a?(Array)
160
+ value.compact.map{ |v| _to_hash(v) }
161
+ elsif value.is_a?(Hash)
162
+ {}.tap do |hash|
163
+ value.each { |k, v| hash[k] = _to_hash(v) }
164
+ end
165
+ elsif value.respond_to? :to_hash
166
+ value.to_hash
167
+ else
168
+ value
169
+ end
170
+ end
171
+
172
+ end
173
+ end
@@ -0,0 +1,284 @@
1
+ =begin
2
+ Marketcheck Cars API
3
+
4
+ <b>Access the New, Used and Certified cars inventories for all Car Dealers in US.</b> <br/>The data is sourced from online listings by over 40,000 Car dealers in US. At any time, there are about 5.2M searchable listings (about 1.8M unique VINs) for Used & Certified cars and about 5M (about 2.3M unique VINs) New Car listings from all over US. We use this API at the back for our website <a href='http://www.marketcheck.com' target='_blank'>www.marketcheck.com</a> and our Android and iOS mobile apps too.<br/><h5> Few useful links : </h5><ul><li>A quick view of the API and the use cases is depicated <a href='https://portals.marketcheck.com/mcapi/' target='_blank'>here</a></li><li>The Postman collection with various usages of the API is shared here https://www.getpostman.com/collections/2752684ff636cdd7bac2</li><li> [Coming soon] API Key : Request your API Key <a href='https://portals.marketcheck.com/api' target='_blank'> here </a> </li><li> [Coming soon] Benchmarks : See the API benchmarks <a href='https://portals.marketcheck.com/mcapi/benchmarks'>here</a></li></ul>
5
+
6
+ OpenAPI spec version: 1.0.3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module SwaggerClient
16
+ # Represents a car history entry
17
+ class HistoricalListing
18
+ # Unique identifier representing a specific listing from the Marketcheck database
19
+ attr_accessor :id
20
+
21
+ # Asking price for the car
22
+ attr_accessor :price
23
+
24
+ # MSRP for the car
25
+ attr_accessor :msrp
26
+
27
+ # Odometer reading / reported miles usage for the car
28
+ attr_accessor :miles
29
+
30
+ # Vehicle Details Page url of the specific car
31
+ attr_accessor :vdp_url
32
+
33
+ # Seller name of the listing from the Marketcheck database
34
+ attr_accessor :seller_name
35
+
36
+ # Listing scraped at timestamp
37
+ attr_accessor :scraped_at
38
+
39
+ # Listing last seen at (most recent) timestamp
40
+ attr_accessor :last_seen_at
41
+
42
+ # Source website for the listing
43
+ attr_accessor :source
44
+
45
+ # City of the listing
46
+ attr_accessor :city
47
+
48
+ # State of the listing
49
+ attr_accessor :state
50
+
51
+ # Zip of the listing
52
+ attr_accessor :zip
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+
58
+ :'id' => :'id',
59
+
60
+ :'price' => :'price',
61
+
62
+ :'msrp' => :'msrp',
63
+
64
+ :'miles' => :'miles',
65
+
66
+ :'vdp_url' => :'vdp_url',
67
+
68
+ :'seller_name' => :'seller_name',
69
+
70
+ :'scraped_at' => :'scraped_at',
71
+
72
+ :'last_seen_at' => :'last_seen_at',
73
+
74
+ :'source' => :'source',
75
+
76
+ :'city' => :'city',
77
+
78
+ :'state' => :'state',
79
+
80
+ :'zip' => :'zip'
81
+
82
+ }
83
+ end
84
+
85
+ # Attribute type mapping.
86
+ def self.swagger_types
87
+ {
88
+ :'id' => :'String',
89
+ :'price' => :'String',
90
+ :'msrp' => :'String',
91
+ :'miles' => :'String',
92
+ :'vdp_url' => :'String',
93
+ :'seller_name' => :'String',
94
+ :'scraped_at' => :'Float',
95
+ :'last_seen_at' => :'Float',
96
+ :'source' => :'String',
97
+ :'city' => :'String',
98
+ :'state' => :'String',
99
+ :'zip' => :'String'
100
+
101
+ }
102
+ end
103
+
104
+ def initialize(attributes = {})
105
+ return unless attributes.is_a?(Hash)
106
+
107
+ # convert string to symbol for hash key
108
+ attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
109
+
110
+
111
+ if attributes[:'id']
112
+ self.id = attributes[:'id']
113
+ end
114
+
115
+ if attributes[:'price']
116
+ self.price = attributes[:'price']
117
+ end
118
+
119
+ if attributes[:'msrp']
120
+ self.msrp = attributes[:'msrp']
121
+ end
122
+
123
+ if attributes[:'miles']
124
+ self.miles = attributes[:'miles']
125
+ end
126
+
127
+ if attributes[:'vdp_url']
128
+ self.vdp_url = attributes[:'vdp_url']
129
+ end
130
+
131
+ if attributes[:'seller_name']
132
+ self.seller_name = attributes[:'seller_name']
133
+ end
134
+
135
+ if attributes[:'scraped_at']
136
+ self.scraped_at = attributes[:'scraped_at']
137
+ end
138
+
139
+ if attributes[:'last_seen_at']
140
+ self.last_seen_at = attributes[:'last_seen_at']
141
+ end
142
+
143
+ if attributes[:'source']
144
+ self.source = attributes[:'source']
145
+ end
146
+
147
+ if attributes[:'city']
148
+ self.city = attributes[:'city']
149
+ end
150
+
151
+ if attributes[:'state']
152
+ self.state = attributes[:'state']
153
+ end
154
+
155
+ if attributes[:'zip']
156
+ self.zip = attributes[:'zip']
157
+ end
158
+
159
+ end
160
+
161
+ # Check equality by comparing each attribute.
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ id == o.id &&
166
+ price == o.price &&
167
+ msrp == o.msrp &&
168
+ miles == o.miles &&
169
+ vdp_url == o.vdp_url &&
170
+ seller_name == o.seller_name &&
171
+ scraped_at == o.scraped_at &&
172
+ last_seen_at == o.last_seen_at &&
173
+ source == o.source &&
174
+ city == o.city &&
175
+ state == o.state &&
176
+ zip == o.zip
177
+ end
178
+
179
+ # @see the `==` method
180
+ def eql?(o)
181
+ self == o
182
+ end
183
+
184
+ # Calculate hash code according to all attributes.
185
+ def hash
186
+ [id, price, msrp, miles, vdp_url, seller_name, scraped_at, last_seen_at, source, city, state, zip].hash
187
+ end
188
+
189
+ # build the object from hash
190
+ def build_from_hash(attributes)
191
+ return nil unless attributes.is_a?(Hash)
192
+ self.class.swagger_types.each_pair do |key, type|
193
+ if type =~ /^Array<(.*)>/i
194
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
195
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
196
+ else
197
+ #TODO show warning in debug mode
198
+ end
199
+ elsif !attributes[self.class.attribute_map[key]].nil?
200
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
201
+ else
202
+ # data not found in attributes(hash), not an issue as the data can be optional
203
+ end
204
+ end
205
+
206
+ self
207
+ end
208
+
209
+ def _deserialize(type, value)
210
+ case type.to_sym
211
+ when :DateTime
212
+ DateTime.parse(value)
213
+ when :Date
214
+ Date.parse(value)
215
+ when :String
216
+ value.to_s
217
+ when :Integer
218
+ value.to_i
219
+ when :Float
220
+ value.to_f
221
+ when :BOOLEAN
222
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
223
+ true
224
+ else
225
+ false
226
+ end
227
+ when :Object
228
+ # generic object (usually a Hash), return directly
229
+ value
230
+ when /\AArray<(?<inner_type>.+)>\z/
231
+ inner_type = Regexp.last_match[:inner_type]
232
+ value.map { |v| _deserialize(inner_type, v) }
233
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
234
+ k_type = Regexp.last_match[:k_type]
235
+ v_type = Regexp.last_match[:v_type]
236
+ {}.tap do |hash|
237
+ value.each do |k, v|
238
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
239
+ end
240
+ end
241
+ else # model
242
+ _model = SwaggerClient.const_get(type).new
243
+ _model.build_from_hash(value)
244
+ end
245
+ end
246
+
247
+ def to_s
248
+ to_hash.to_s
249
+ end
250
+
251
+ # to_body is an alias to to_body (backward compatibility))
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # return the object in the form of hash
257
+ def to_hash
258
+ hash = {}
259
+ self.class.attribute_map.each_pair do |attr, param|
260
+ value = self.send(attr)
261
+ next if value.nil?
262
+ hash[param] = _to_hash(value)
263
+ end
264
+ hash
265
+ end
266
+
267
+ # Method to output non-array value in the form of hash
268
+ # For object, use to_hash. Otherwise, just return the value
269
+ def _to_hash(value)
270
+ if value.is_a?(Array)
271
+ value.compact.map{ |v| _to_hash(v) }
272
+ elsif value.is_a?(Hash)
273
+ {}.tap do |hash|
274
+ value.each { |k, v| hash[k] = _to_hash(v) }
275
+ end
276
+ elsif value.respond_to? :to_hash
277
+ value.to_hash
278
+ else
279
+ value
280
+ end
281
+ end
282
+
283
+ end
284
+ end