aylien_news_api 0.0.1

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 (112) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +67 -0
  4. data/LICENSE +13 -0
  5. data/README.md +133 -0
  6. data/Rakefile +8 -0
  7. data/aylien_news_api.gemspec +33 -0
  8. data/docs/Author.md +10 -0
  9. data/docs/Autocomplete.md +9 -0
  10. data/docs/Autocompletes.md +8 -0
  11. data/docs/Category.md +13 -0
  12. data/docs/CategoryLinks.md +9 -0
  13. data/docs/Coverages.md +12 -0
  14. data/docs/DefaultApi.md +829 -0
  15. data/docs/Entities.md +9 -0
  16. data/docs/Entity.md +12 -0
  17. data/docs/EntityLinks.md +8 -0
  18. data/docs/Error.md +13 -0
  19. data/docs/ErrorLinks.md +8 -0
  20. data/docs/Errors.md +8 -0
  21. data/docs/HistogramInterval.md +9 -0
  22. data/docs/Histograms.md +12 -0
  23. data/docs/Location.md +10 -0
  24. data/docs/Media.md +9 -0
  25. data/docs/RelatedStories.md +11 -0
  26. data/docs/Scope.md +11 -0
  27. data/docs/Sentiment.md +9 -0
  28. data/docs/Sentiments.md +9 -0
  29. data/docs/ShareCount.md +9 -0
  30. data/docs/ShareCounts.md +11 -0
  31. data/docs/Source.md +13 -0
  32. data/docs/Stories.md +10 -0
  33. data/docs/Story.md +27 -0
  34. data/docs/StoryCluster.md +12 -0
  35. data/docs/StoryLinks.md +10 -0
  36. data/docs/Summary.md +8 -0
  37. data/docs/TimeSeries.md +9 -0
  38. data/docs/TimeSeriesList.md +11 -0
  39. data/docs/Trend.md +9 -0
  40. data/docs/Trends.md +9 -0
  41. data/lib/aylien_news_api.rb +74 -0
  42. data/lib/aylien_news_api/api/default_api.rb +1171 -0
  43. data/lib/aylien_news_api/api_client.rb +365 -0
  44. data/lib/aylien_news_api/api_error.rb +38 -0
  45. data/lib/aylien_news_api/configuration.rb +191 -0
  46. data/lib/aylien_news_api/models/author.rb +192 -0
  47. data/lib/aylien_news_api/models/autocomplete.rb +183 -0
  48. data/lib/aylien_news_api/models/autocompletes.rb +176 -0
  49. data/lib/aylien_news_api/models/category.rb +229 -0
  50. data/lib/aylien_news_api/models/category_links.rb +183 -0
  51. data/lib/aylien_news_api/models/coverages.rb +212 -0
  52. data/lib/aylien_news_api/models/entities.rb +187 -0
  53. data/lib/aylien_news_api/models/entity.rb +214 -0
  54. data/lib/aylien_news_api/models/entity_links.rb +174 -0
  55. data/lib/aylien_news_api/models/error.rb +213 -0
  56. data/lib/aylien_news_api/models/error_links.rb +173 -0
  57. data/lib/aylien_news_api/models/errors.rb +175 -0
  58. data/lib/aylien_news_api/models/histogram_interval.rb +183 -0
  59. data/lib/aylien_news_api/models/histograms.rb +211 -0
  60. data/lib/aylien_news_api/models/location.rb +192 -0
  61. data/lib/aylien_news_api/models/media.rb +193 -0
  62. data/lib/aylien_news_api/models/related_stories.rb +203 -0
  63. data/lib/aylien_news_api/models/scope.rb +211 -0
  64. data/lib/aylien_news_api/models/sentiment.rb +193 -0
  65. data/lib/aylien_news_api/models/sentiments.rb +183 -0
  66. data/lib/aylien_news_api/models/share_count.rb +183 -0
  67. data/lib/aylien_news_api/models/share_counts.rb +209 -0
  68. data/lib/aylien_news_api/models/source.rb +223 -0
  69. data/lib/aylien_news_api/models/stories.rb +196 -0
  70. data/lib/aylien_news_api/models/story.rb +353 -0
  71. data/lib/aylien_news_api/models/story_cluster.rb +214 -0
  72. data/lib/aylien_news_api/models/story_links.rb +192 -0
  73. data/lib/aylien_news_api/models/summary.rb +176 -0
  74. data/lib/aylien_news_api/models/time_series.rb +183 -0
  75. data/lib/aylien_news_api/models/time_series_list.rb +203 -0
  76. data/lib/aylien_news_api/models/trend.rb +183 -0
  77. data/lib/aylien_news_api/models/trends.rb +185 -0
  78. data/lib/aylien_news_api/version.rb +17 -0
  79. data/spec/api/default_api_spec.rb +357 -0
  80. data/spec/models/author_spec.rb +66 -0
  81. data/spec/models/autocomplete_spec.rb +56 -0
  82. data/spec/models/autocompletes_spec.rb +46 -0
  83. data/spec/models/category_links_spec.rb +56 -0
  84. data/spec/models/category_spec.rb +96 -0
  85. data/spec/models/coverages_spec.rb +86 -0
  86. data/spec/models/entities_spec.rb +56 -0
  87. data/spec/models/entity_links_spec.rb +46 -0
  88. data/spec/models/entity_spec.rb +86 -0
  89. data/spec/models/error_links_spec.rb +46 -0
  90. data/spec/models/error_spec.rb +96 -0
  91. data/spec/models/errors_spec.rb +46 -0
  92. data/spec/models/histogram_interval_spec.rb +56 -0
  93. data/spec/models/histograms_spec.rb +86 -0
  94. data/spec/models/location_spec.rb +66 -0
  95. data/spec/models/media_spec.rb +56 -0
  96. data/spec/models/related_stories_spec.rb +76 -0
  97. data/spec/models/scope_spec.rb +76 -0
  98. data/spec/models/sentiment_spec.rb +56 -0
  99. data/spec/models/sentiments_spec.rb +56 -0
  100. data/spec/models/share_count_spec.rb +56 -0
  101. data/spec/models/share_counts_spec.rb +76 -0
  102. data/spec/models/source_spec.rb +96 -0
  103. data/spec/models/stories_spec.rb +66 -0
  104. data/spec/models/story_cluster_spec.rb +86 -0
  105. data/spec/models/story_links_spec.rb +66 -0
  106. data/spec/models/story_spec.rb +236 -0
  107. data/spec/models/summary_spec.rb +46 -0
  108. data/spec/models/time_series_list_spec.rb +76 -0
  109. data/spec/models/time_series_spec.rb +56 -0
  110. data/spec/models/trend_spec.rb +56 -0
  111. data/spec/models/trends_spec.rb +56 -0
  112. metadata +391 -0
@@ -0,0 +1,192 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class Author
19
+ # A unique identification for the author
20
+ attr_accessor :id
21
+
22
+ # The extracted author full name
23
+ attr_accessor :name
24
+
25
+ # A URL which points to the author avatar
26
+ attr_accessor :avatar_url
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'id' => :'id',
32
+ :'name' => :'name',
33
+ :'avatar_url' => :'avatar_url'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.api_types
39
+ {
40
+ :'id' => :'Integer',
41
+ :'name' => :'String',
42
+ :'avatar_url' => :'String'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes[:'id']
55
+ self.id = attributes[:'id']
56
+ end
57
+ if attributes[:'name']
58
+ self.name = attributes[:'name']
59
+ end
60
+ if attributes[:'avatar_url']
61
+ self.avatar_url = attributes[:'avatar_url']
62
+ end
63
+ end
64
+
65
+ # Checks equality by comparing each attribute.
66
+ # @param [Object] Object to be compared
67
+ def ==(o)
68
+ return true if self.equal?(o)
69
+ self.class == o.class &&
70
+ id == o.id &&
71
+ name == o.name &&
72
+ avatar_url == o.avatar_url
73
+ end
74
+
75
+ # @see the `==` method
76
+ # @param [Object] Object to be compared
77
+ def eql?(o)
78
+ self == o
79
+ end
80
+
81
+ # Calculates hash code according to all attributes.
82
+ # @return [Fixnum] Hash code
83
+ def hash
84
+ [id, name, avatar_url].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.api_types.each_pair do |key, type|
93
+ if type =~ /^Array<(.*)>/i
94
+ # check to ensure the input is an array given that the the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
97
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+
104
+ self
105
+ end
106
+
107
+ # Deserializes the data based on type
108
+ # @param string type Data type
109
+ # @param string value Value to be deserialized
110
+ # @return [Object] Deserialized data
111
+ def _deserialize(type, value)
112
+ case type.to_sym
113
+ when :DateTime
114
+ DateTime.parse(value)
115
+ when :Date
116
+ Date.parse(value)
117
+ when :String
118
+ value.to_s
119
+ when :Integer
120
+ value.to_i
121
+ when :Float
122
+ value.to_f
123
+ when :BOOLEAN
124
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
125
+ true
126
+ else
127
+ false
128
+ end
129
+ when :Object
130
+ # generic object (usually a Hash), return directly
131
+ value
132
+ when /\AArray<(?<inner_type>.+)>\z/
133
+ inner_type = Regexp.last_match[:inner_type]
134
+ value.map { |v| _deserialize(inner_type, v) }
135
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
136
+ k_type = Regexp.last_match[:k_type]
137
+ v_type = Regexp.last_match[:v_type]
138
+ {}.tap do |hash|
139
+ value.each do |k, v|
140
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
141
+ end
142
+ end
143
+ else # model
144
+ temp_model = AylienNewsApi.const_get(type).new
145
+ temp_model.build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ next if value.nil?
168
+ hash[param] = _to_hash(value)
169
+ end
170
+ hash
171
+ end
172
+
173
+ # Outputs non-array value in the form of hash
174
+ # For object, use to_hash. Otherwise, just return the value
175
+ # @param [Object] value Any valid value
176
+ # @return [Hash] Returns the value in the form of hash
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map{ |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+ end
192
+ end
@@ -0,0 +1,183 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class Autocomplete
19
+ # ID of the autocomplete
20
+ attr_accessor :id
21
+
22
+ # Text of the autocomplete
23
+ attr_accessor :text
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'id' => :'id',
29
+ :'text' => :'text'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.api_types
35
+ {
36
+ :'id' => :'String',
37
+ :'text' => :'String'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
48
+
49
+ if attributes[:'id']
50
+ self.id = attributes[:'id']
51
+ end
52
+ if attributes[:'text']
53
+ self.text = attributes[:'text']
54
+ end
55
+ end
56
+
57
+ # Checks equality by comparing each attribute.
58
+ # @param [Object] Object to be compared
59
+ def ==(o)
60
+ return true if self.equal?(o)
61
+ self.class == o.class &&
62
+ id == o.id &&
63
+ text == o.text
64
+ end
65
+
66
+ # @see the `==` method
67
+ # @param [Object] Object to be compared
68
+ def eql?(o)
69
+ self == o
70
+ end
71
+
72
+ # Calculates hash code according to all attributes.
73
+ # @return [Fixnum] Hash code
74
+ def hash
75
+ [id, text].hash
76
+ end
77
+
78
+ # Builds the object from hash
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ # @return [Object] Returns the model itself
81
+ def build_from_hash(attributes)
82
+ return nil unless attributes.is_a?(Hash)
83
+ self.class.api_types.each_pair do |key, type|
84
+ if type =~ /^Array<(.*)>/i
85
+ # check to ensure the input is an array given that the the attribute
86
+ # is documented as an array but the input is not
87
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
88
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
89
+ end
90
+ elsif !attributes[self.class.attribute_map[key]].nil?
91
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
92
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
93
+ end
94
+
95
+ self
96
+ end
97
+
98
+ # Deserializes the data based on type
99
+ # @param string type Data type
100
+ # @param string value Value to be deserialized
101
+ # @return [Object] Deserialized data
102
+ def _deserialize(type, value)
103
+ case type.to_sym
104
+ when :DateTime
105
+ DateTime.parse(value)
106
+ when :Date
107
+ Date.parse(value)
108
+ when :String
109
+ value.to_s
110
+ when :Integer
111
+ value.to_i
112
+ when :Float
113
+ value.to_f
114
+ when :BOOLEAN
115
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
116
+ true
117
+ else
118
+ false
119
+ end
120
+ when :Object
121
+ # generic object (usually a Hash), return directly
122
+ value
123
+ when /\AArray<(?<inner_type>.+)>\z/
124
+ inner_type = Regexp.last_match[:inner_type]
125
+ value.map { |v| _deserialize(inner_type, v) }
126
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
127
+ k_type = Regexp.last_match[:k_type]
128
+ v_type = Regexp.last_match[:v_type]
129
+ {}.tap do |hash|
130
+ value.each do |k, v|
131
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
132
+ end
133
+ end
134
+ else # model
135
+ temp_model = AylienNewsApi.const_get(type).new
136
+ temp_model.build_from_hash(value)
137
+ end
138
+ end
139
+
140
+ # Returns the string representation of the object
141
+ # @return [String] String presentation of the object
142
+ def to_s
143
+ to_hash.to_s
144
+ end
145
+
146
+ # to_body is an alias to to_hash (backward compatibility)
147
+ # @return [Hash] Returns the object in the form of hash
148
+ def to_body
149
+ to_hash
150
+ end
151
+
152
+ # Returns the object in the form of hash
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_hash
155
+ hash = {}
156
+ self.class.attribute_map.each_pair do |attr, param|
157
+ value = self.send(attr)
158
+ next if value.nil?
159
+ hash[param] = _to_hash(value)
160
+ end
161
+ hash
162
+ end
163
+
164
+ # Outputs non-array value in the form of hash
165
+ # For object, use to_hash. Otherwise, just return the value
166
+ # @param [Object] value Any valid value
167
+ # @return [Hash] Returns the value in the form of hash
168
+ def _to_hash(value)
169
+ if value.is_a?(Array)
170
+ value.compact.map{ |v| _to_hash(v) }
171
+ elsif value.is_a?(Hash)
172
+ {}.tap do |hash|
173
+ value.each { |k, v| hash[k] = _to_hash(v) }
174
+ end
175
+ elsif value.respond_to? :to_hash
176
+ value.to_hash
177
+ else
178
+ value
179
+ end
180
+ end
181
+
182
+ end
183
+ end
@@ -0,0 +1,176 @@
1
+ # Copyright 2016 Aylien, Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'date'
16
+
17
+ module AylienNewsApi
18
+ class Autocompletes
19
+ # An array of autocompletes
20
+ attr_accessor :autocompletes
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'autocompletes' => :'autocompletes'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.api_types
31
+ {
32
+ :'autocompletes' => :'Array<Autocomplete>'
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[:'autocompletes']
45
+ if (value = attributes[:'autocompletes']).is_a?(Array)
46
+ self.autocompletes = value
47
+ end
48
+ end
49
+ end
50
+
51
+ # Checks equality by comparing each attribute.
52
+ # @param [Object] Object to be compared
53
+ def ==(o)
54
+ return true if self.equal?(o)
55
+ self.class == o.class &&
56
+ autocompletes == o.autocompletes
57
+ end
58
+
59
+ # @see the `==` method
60
+ # @param [Object] Object to be compared
61
+ def eql?(o)
62
+ self == o
63
+ end
64
+
65
+ # Calculates hash code according to all attributes.
66
+ # @return [Fixnum] Hash code
67
+ def hash
68
+ [autocompletes].hash
69
+ end
70
+
71
+ # Builds the object from hash
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ # @return [Object] Returns the model itself
74
+ def build_from_hash(attributes)
75
+ return nil unless attributes.is_a?(Hash)
76
+ self.class.api_types.each_pair do |key, type|
77
+ if type =~ /^Array<(.*)>/i
78
+ # check to ensure the input is an array given that the the attribute
79
+ # is documented as an array but the input is not
80
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
81
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
82
+ end
83
+ elsif !attributes[self.class.attribute_map[key]].nil?
84
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
85
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
86
+ end
87
+
88
+ self
89
+ end
90
+
91
+ # Deserializes the data based on type
92
+ # @param string type Data type
93
+ # @param string value Value to be deserialized
94
+ # @return [Object] Deserialized data
95
+ def _deserialize(type, value)
96
+ case type.to_sym
97
+ when :DateTime
98
+ DateTime.parse(value)
99
+ when :Date
100
+ Date.parse(value)
101
+ when :String
102
+ value.to_s
103
+ when :Integer
104
+ value.to_i
105
+ when :Float
106
+ value.to_f
107
+ when :BOOLEAN
108
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
109
+ true
110
+ else
111
+ false
112
+ end
113
+ when :Object
114
+ # generic object (usually a Hash), return directly
115
+ value
116
+ when /\AArray<(?<inner_type>.+)>\z/
117
+ inner_type = Regexp.last_match[:inner_type]
118
+ value.map { |v| _deserialize(inner_type, v) }
119
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
120
+ k_type = Regexp.last_match[:k_type]
121
+ v_type = Regexp.last_match[:v_type]
122
+ {}.tap do |hash|
123
+ value.each do |k, v|
124
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
125
+ end
126
+ end
127
+ else # model
128
+ temp_model = AylienNewsApi.const_get(type).new
129
+ temp_model.build_from_hash(value)
130
+ end
131
+ end
132
+
133
+ # Returns the string representation of the object
134
+ # @return [String] String presentation of the object
135
+ def to_s
136
+ to_hash.to_s
137
+ end
138
+
139
+ # to_body is an alias to to_hash (backward compatibility)
140
+ # @return [Hash] Returns the object in the form of hash
141
+ def to_body
142
+ to_hash
143
+ end
144
+
145
+ # Returns the object in the form of hash
146
+ # @return [Hash] Returns the object in the form of hash
147
+ def to_hash
148
+ hash = {}
149
+ self.class.attribute_map.each_pair do |attr, param|
150
+ value = self.send(attr)
151
+ next if value.nil?
152
+ hash[param] = _to_hash(value)
153
+ end
154
+ hash
155
+ end
156
+
157
+ # Outputs non-array value in the form of hash
158
+ # For object, use to_hash. Otherwise, just return the value
159
+ # @param [Object] value Any valid value
160
+ # @return [Hash] Returns the value in the form of hash
161
+ def _to_hash(value)
162
+ if value.is_a?(Array)
163
+ value.compact.map{ |v| _to_hash(v) }
164
+ elsif value.is_a?(Hash)
165
+ {}.tap do |hash|
166
+ value.each { |k, v| hash[k] = _to_hash(v) }
167
+ end
168
+ elsif value.respond_to? :to_hash
169
+ value.to_hash
170
+ else
171
+ value
172
+ end
173
+ end
174
+
175
+ end
176
+ end