aylien_news_api 0.4.0 → 4.1.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 (160) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +7 -1
  3. data/README.md +117 -4
  4. data/Rakefile +10 -0
  5. data/aylien_news_api.gemspec +20 -28
  6. data/docs/Author.md +12 -1
  7. data/docs/Autocomplete.md +10 -0
  8. data/docs/Autocompletes.md +9 -0
  9. data/docs/Category.md +19 -3
  10. data/docs/CategoryLinks.md +11 -1
  11. data/docs/CategoryTaxonomy.md +16 -0
  12. data/docs/Cluster.md +29 -0
  13. data/docs/Clusters.md +21 -0
  14. data/docs/Coverages.md +16 -4
  15. data/docs/DefaultApi.md +1299 -826
  16. data/docs/Entities.md +11 -1
  17. data/docs/Entity.md +16 -3
  18. data/docs/EntityLinks.md +9 -0
  19. data/docs/Error.md +16 -2
  20. data/docs/ErrorLinks.md +11 -0
  21. data/docs/Errors.md +9 -0
  22. data/docs/HistogramInterval.md +10 -0
  23. data/docs/Histograms.md +20 -3
  24. data/docs/Location.md +13 -2
  25. data/docs/Media.md +18 -4
  26. data/docs/MediaFormat.md +16 -0
  27. data/docs/MediaType.md +16 -0
  28. data/docs/Rank.md +12 -1
  29. data/docs/Rankings.md +9 -0
  30. data/docs/RelatedStories.md +18 -3
  31. data/docs/RepresentativeStory.md +23 -0
  32. data/docs/Scope.md +15 -3
  33. data/docs/ScopeLevel.md +16 -0
  34. data/docs/Sentiment.md +11 -1
  35. data/docs/SentimentPolarity.md +16 -0
  36. data/docs/Sentiments.md +12 -2
  37. data/docs/ShareCount.md +10 -0
  38. data/docs/ShareCounts.md +12 -0
  39. data/docs/Source.md +27 -8
  40. data/docs/Stories.md +17 -2
  41. data/docs/Story.md +48 -16
  42. data/docs/StoryCluster.md +14 -1
  43. data/docs/StoryLinks.md +14 -1
  44. data/docs/StoryTranslation.md +19 -0
  45. data/docs/StoryTranslations.md +17 -0
  46. data/docs/StoryTranslationsEn.md +21 -0
  47. data/docs/Summary.md +9 -0
  48. data/docs/TimeSeries.md +11 -1
  49. data/docs/TimeSeriesList.md +15 -3
  50. data/docs/Trend.md +11 -1
  51. data/docs/Trends.md +15 -1
  52. data/docs/Warning.md +21 -0
  53. data/git_push.sh +58 -0
  54. data/lib/aylien_news_api.rb +22 -14
  55. data/lib/aylien_news_api/api/default_api.rb +2407 -1520
  56. data/lib/aylien_news_api/api_client.rb +137 -111
  57. data/lib/aylien_news_api/api_error.rb +37 -18
  58. data/lib/aylien_news_api/configuration.rb +74 -36
  59. data/lib/aylien_news_api/models/author.rb +66 -50
  60. data/lib/aylien_news_api/models/autocomplete.rb +52 -36
  61. data/lib/aylien_news_api/models/autocompletes.rb +51 -35
  62. data/lib/aylien_news_api/models/category.rb +85 -94
  63. data/lib/aylien_news_api/models/category_links.rb +63 -47
  64. data/lib/aylien_news_api/models/category_taxonomy.rb +36 -0
  65. data/lib/aylien_news_api/models/cluster.rb +265 -0
  66. data/lib/aylien_news_api/models/clusters.rb +229 -0
  67. data/lib/aylien_news_api/models/coverages.rb +76 -72
  68. data/lib/aylien_news_api/models/entities.rb +64 -48
  69. data/lib/aylien_news_api/models/entity.rb +93 -79
  70. data/lib/aylien_news_api/models/entity_links.rb +51 -35
  71. data/lib/aylien_news_api/models/error.rb +76 -60
  72. data/lib/aylien_news_api/models/error_links.rb +62 -37
  73. data/lib/aylien_news_api/models/errors.rb +51 -35
  74. data/lib/aylien_news_api/models/histogram_interval.rb +52 -36
  75. data/lib/aylien_news_api/models/histograms.rb +96 -60
  76. data/lib/aylien_news_api/models/location.rb +67 -51
  77. data/lib/aylien_news_api/models/media.rb +83 -114
  78. data/lib/aylien_news_api/models/media_format.rb +44 -0
  79. data/lib/aylien_news_api/models/media_type.rb +36 -0
  80. data/lib/aylien_news_api/models/rank.rb +64 -48
  81. data/lib/aylien_news_api/models/rankings.rb +51 -35
  82. data/lib/aylien_news_api/models/related_stories.rb +84 -60
  83. data/lib/aylien_news_api/models/representative_story.rb +237 -0
  84. data/lib/aylien_news_api/models/scope.rb +73 -91
  85. data/lib/aylien_news_api/models/scope_level.rb +37 -0
  86. data/lib/aylien_news_api/models/sentiment.rb +63 -82
  87. data/lib/aylien_news_api/models/sentiment_polarity.rb +37 -0
  88. data/lib/aylien_news_api/models/sentiments.rb +62 -48
  89. data/lib/aylien_news_api/models/share_count.rb +52 -36
  90. data/lib/aylien_news_api/models/share_counts.rb +54 -38
  91. data/lib/aylien_news_api/models/source.rb +111 -96
  92. data/lib/aylien_news_api/models/stories.rb +86 -50
  93. data/lib/aylien_news_api/models/story.rb +188 -158
  94. data/lib/aylien_news_api/models/story_cluster.rb +68 -52
  95. data/lib/aylien_news_api/models/story_links.rb +70 -44
  96. data/lib/aylien_news_api/models/story_translation.rb +217 -0
  97. data/lib/aylien_news_api/models/story_translations.rb +207 -0
  98. data/lib/aylien_news_api/models/story_translations_en.rb +227 -0
  99. data/lib/aylien_news_api/models/summary.rb +51 -35
  100. data/lib/aylien_news_api/models/time_series.rb +63 -47
  101. data/lib/aylien_news_api/models/time_series_list.rb +72 -56
  102. data/lib/aylien_news_api/models/trend.rb +63 -47
  103. data/lib/aylien_news_api/models/trends.rb +77 -41
  104. data/lib/aylien_news_api/models/warning.rb +226 -0
  105. data/lib/aylien_news_api/version.rb +12 -14
  106. data/spec/api/default_api_spec.rb +620 -284
  107. data/spec/api_client_spec.rb +43 -161
  108. data/spec/configuration_spec.rb +22 -19
  109. data/spec/models/author_spec.rb +21 -34
  110. data/spec/models/autocomplete_spec.rb +17 -26
  111. data/spec/models/autocompletes_spec.rb +16 -21
  112. data/spec/models/category_links_spec.rb +19 -28
  113. data/spec/models/category_spec.rb +31 -50
  114. data/spec/models/category_taxonomy_spec.rb +35 -0
  115. data/spec/models/cluster_spec.rb +77 -0
  116. data/spec/models/clusters_spec.rb +53 -0
  117. data/spec/models/coverages_spec.rb +24 -45
  118. data/spec/models/entities_spec.rb +19 -28
  119. data/spec/models/entity_links_spec.rb +16 -21
  120. data/spec/models/entity_spec.rb +25 -46
  121. data/spec/models/error_links_spec.rb +22 -21
  122. data/spec/models/error_spec.rb +27 -52
  123. data/spec/models/errors_spec.rb +16 -21
  124. data/spec/models/histogram_interval_spec.rb +17 -26
  125. data/spec/models/histograms_spec.rb +36 -45
  126. data/spec/models/location_spec.rb +21 -34
  127. data/spec/models/media_format_spec.rb +35 -0
  128. data/spec/models/media_spec.rb +41 -26
  129. data/spec/models/media_type_spec.rb +35 -0
  130. data/spec/models/rank_spec.rb +20 -21
  131. data/spec/models/rankings_spec.rb +15 -16
  132. data/spec/models/related_stories_spec.rb +33 -38
  133. data/spec/models/representative_story_spec.rb +59 -0
  134. data/spec/models/scope_level_spec.rb +35 -0
  135. data/spec/models/scope_spec.rb +23 -40
  136. data/spec/models/sentiment_polarity_spec.rb +35 -0
  137. data/spec/models/sentiment_spec.rb +17 -26
  138. data/spec/models/sentiments_spec.rb +19 -28
  139. data/spec/models/share_count_spec.rb +17 -26
  140. data/spec/models/share_counts_spec.rb +19 -36
  141. data/spec/models/source_spec.rb +54 -49
  142. data/spec/models/stories_spec.rb +32 -33
  143. data/spec/models/story_cluster_spec.rb +23 -44
  144. data/spec/models/story_links_spec.rb +25 -32
  145. data/spec/models/story_spec.rb +65 -134
  146. data/spec/models/story_translation_spec.rb +47 -0
  147. data/spec/models/story_translations_en_spec.rb +53 -0
  148. data/spec/models/story_translations_spec.rb +41 -0
  149. data/spec/models/summary_spec.rb +16 -21
  150. data/spec/models/time_series_list_spec.rb +22 -39
  151. data/spec/models/time_series_spec.rb +19 -28
  152. data/spec/models/trend_spec.rb +19 -28
  153. data/spec/models/trends_spec.rb +30 -27
  154. data/spec/models/warning_spec.rb +53 -0
  155. data/spec/spec_helper.rb +11 -13
  156. metadata +91 -192
  157. data/Gemfile.lock +0 -65
  158. data/LICENSE +0 -13
  159. data/aylien_news_api-0.2.0.gem +0 -0
  160. data/aylien_news_api-0.3.0.gem +0 -0
@@ -1,125 +1,99 @@
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.
1
+ =begin
2
+ #AYLIEN News API
14
3
 
15
- require 'date'
4
+ #The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.
16
5
 
17
- module AylienNewsApi
6
+ The version of the OpenAPI document: 3.0
7
+ Contact: support@aylien.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
18
10
 
19
- class Scope
20
- # The source scope by country code. It supports [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes.
21
- attr_accessor :country
11
+ =end
22
12
 
23
- # The scope by state
24
- attr_accessor :state
13
+ require 'date'
25
14
 
15
+ module AylienNewsApi
16
+ class Scope
26
17
  # The scope by city
27
18
  attr_accessor :city
28
19
 
29
- # The scope by level
30
- attr_accessor :level
20
+ # The source scope by country code. It supports [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes.
21
+ attr_accessor :country
31
22
 
32
- class EnumAttributeValidator
33
- attr_reader :datatype
34
- attr_reader :allowable_values
35
-
36
- def initialize(datatype, allowable_values)
37
- @allowable_values = allowable_values.map do |value|
38
- case datatype.to_s
39
- when /Integer/i
40
- value.to_i
41
- when /Float/i
42
- value.to_f
43
- else
44
- value
45
- end
46
- end
47
- end
23
+ attr_accessor :level
48
24
 
49
- def valid?(value)
50
- !value || allowable_values.include?(value)
51
- end
52
- end
25
+ # The scope by state
26
+ attr_accessor :state
53
27
 
54
28
  # Attribute mapping from ruby-style variable name to JSON key.
55
29
  def self.attribute_map
56
30
  {
57
- :'country' => :'country',
58
- :'state' => :'state',
59
31
  :'city' => :'city',
60
- :'level' => :'level'
32
+ :'country' => :'country',
33
+ :'level' => :'level',
34
+ :'state' => :'state'
61
35
  }
62
36
  end
63
37
 
64
38
  # Attribute type mapping.
65
- def self.api_types
39
+ def self.openapi_types
66
40
  {
67
- :'country' => :'String',
68
- :'state' => :'String',
69
41
  :'city' => :'String',
70
- :'level' => :'String'
42
+ :'country' => :'String',
43
+ :'level' => :'ScopeLevel',
44
+ :'state' => :'String'
71
45
  }
72
46
  end
73
47
 
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
74
54
  # Initializes the object
75
55
  # @param [Hash] attributes Model attributes in the form of hash
76
56
  def initialize(attributes = {})
77
- return unless attributes.is_a?(Hash)
78
-
79
- # convert string to symbol for hash key
80
- attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
81
-
82
- if attributes.has_key?(:'country')
83
- self.country = attributes[:'country']
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::Scope` initialize method"
84
59
  end
85
60
 
86
- if attributes.has_key?(:'state')
87
- self.state = attributes[:'state']
88
- end
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::Scope`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
89
68
 
90
- if attributes.has_key?(:'city')
69
+ if attributes.key?(:'city')
91
70
  self.city = attributes[:'city']
92
71
  end
93
72
 
94
- if attributes.has_key?(:'level')
73
+ if attributes.key?(:'country')
74
+ self.country = attributes[:'country']
75
+ end
76
+
77
+ if attributes.key?(:'level')
95
78
  self.level = attributes[:'level']
96
79
  end
97
80
 
81
+ if attributes.key?(:'state')
82
+ self.state = attributes[:'state']
83
+ end
98
84
  end
99
85
 
100
86
  # Show invalid properties with the reasons. Usually used together with valid?
101
- # @return Array for valid properies with the reasons
87
+ # @return Array for valid properties with the reasons
102
88
  def list_invalid_properties
103
89
  invalid_properties = Array.new
104
- return invalid_properties
90
+ invalid_properties
105
91
  end
106
92
 
107
93
  # Check to see if the all the properties in the model are valid
108
94
  # @return true if the model is valid
109
95
  def valid?
110
- level_validator = EnumAttributeValidator.new('String', ["international", "national", "local"])
111
- return false unless level_validator.valid?(@level)
112
- return true
113
- end
114
-
115
- # Custom attribute writer method checking allowed values (enum).
116
- # @param [Object] level Object to be assigned
117
- def level=(level)
118
- validator = EnumAttributeValidator.new('String', ["international", "national", "local"])
119
- unless validator.valid?(level)
120
- fail ArgumentError, "invalid value for 'level', must be one of #{validator.allowable_values}."
121
- end
122
- @level = level
96
+ true
123
97
  end
124
98
 
125
99
  # Checks equality by comparing each attribute.
@@ -127,10 +101,10 @@ module AylienNewsApi
127
101
  def ==(o)
128
102
  return true if self.equal?(o)
129
103
  self.class == o.class &&
130
- country == o.country &&
131
- state == o.state &&
132
104
  city == o.city &&
133
- level == o.level
105
+ country == o.country &&
106
+ level == o.level &&
107
+ state == o.state
134
108
  end
135
109
 
136
110
  # @see the `==` method
@@ -140,9 +114,16 @@ module AylienNewsApi
140
114
  end
141
115
 
142
116
  # Calculates hash code according to all attributes.
143
- # @return [Fixnum] Hash code
117
+ # @return [Integer] Hash code
144
118
  def hash
145
- [country, state, city, level].hash
119
+ [city, country, level, state].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ new.build_from_hash(attributes)
146
127
  end
147
128
 
148
129
  # Builds the object from hash
@@ -150,12 +131,12 @@ module AylienNewsApi
150
131
  # @return [Object] Returns the model itself
151
132
  def build_from_hash(attributes)
152
133
  return nil unless attributes.is_a?(Hash)
153
- self.class.api_types.each_pair do |key, type|
134
+ self.class.openapi_types.each_pair do |key, type|
154
135
  if type =~ /\AArray<(.*)>/i
155
- # check to ensure the input is an array given that the the attribute
136
+ # check to ensure the input is an array given that the attribute
156
137
  # is documented as an array but the input is not
157
138
  if attributes[self.class.attribute_map[key]].is_a?(Array)
158
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
139
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
140
  end
160
141
  elsif !attributes[self.class.attribute_map[key]].nil?
161
142
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@@ -181,7 +162,7 @@ module AylienNewsApi
181
162
  value.to_i
182
163
  when :Float
183
164
  value.to_f
184
- when :BOOLEAN
165
+ when :Boolean
185
166
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
167
  true
187
168
  else
@@ -202,8 +183,7 @@ module AylienNewsApi
202
183
  end
203
184
  end
204
185
  else # model
205
- temp_model = AylienNewsApi.const_get(type).new
206
- temp_model.build_from_hash(value)
186
+ AylienNewsApi.const_get(type).build_from_hash(value)
207
187
  end
208
188
  end
209
189
 
@@ -225,7 +205,11 @@ module AylienNewsApi
225
205
  hash = {}
226
206
  self.class.attribute_map.each_pair do |attr, param|
227
207
  value = self.send(attr)
228
- next if value.nil?
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
229
213
  hash[param] = _to_hash(value)
230
214
  end
231
215
  hash
@@ -237,7 +221,7 @@ module AylienNewsApi
237
221
  # @return [Hash] Returns the value in the form of hash
238
222
  def _to_hash(value)
239
223
  if value.is_a?(Array)
240
- value.compact.map{ |v| _to_hash(v) }
224
+ value.compact.map { |v| _to_hash(v) }
241
225
  elsif value.is_a?(Hash)
242
226
  {}.tap do |hash|
243
227
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -248,7 +232,5 @@ module AylienNewsApi
248
232
  value
249
233
  end
250
234
  end
251
-
252
235
  end
253
-
254
236
  end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ #AYLIEN News API
3
+
4
+ #The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.
5
+
6
+ The version of the OpenAPI document: 3.0
7
+ Contact: support@aylien.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AylienNewsApi
16
+ class ScopeLevel
17
+ INTERNATIONAL = "international".freeze
18
+ NATIONAL = "national".freeze
19
+ LOCAL = "local".freeze
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ constantValues = ScopeLevel.constants.select { |c| ScopeLevel::const_get(c) == value }
33
+ raise "Invalid ENUM value #{value} for class #ScopeLevel" if constantValues.empty?
34
+ value
35
+ end
36
+ end
37
+ end
@@ -1,50 +1,24 @@
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.
1
+ =begin
2
+ #AYLIEN News API
3
+
4
+ #The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.
5
+
6
+ The version of the OpenAPI document: 3.0
7
+ Contact: support@aylien.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-SNAPSHOT
10
+
11
+ =end
14
12
 
15
13
  require 'date'
16
14
 
17
15
  module AylienNewsApi
18
-
19
16
  class Sentiment
20
- # Polarity of the sentiment
21
17
  attr_accessor :polarity
22
18
 
23
19
  # Polarity score of the sentiment
24
20
  attr_accessor :score
25
21
 
26
- class EnumAttributeValidator
27
- attr_reader :datatype
28
- attr_reader :allowable_values
29
-
30
- def initialize(datatype, allowable_values)
31
- @allowable_values = allowable_values.map do |value|
32
- case datatype.to_s
33
- when /Integer/i
34
- value.to_i
35
- when /Float/i
36
- value.to_f
37
- else
38
- value
39
- end
40
- end
41
- end
42
-
43
- def valid?(value)
44
- !value || allowable_values.include?(value)
45
- end
46
- end
47
-
48
22
  # Attribute mapping from ruby-style variable name to JSON key.
49
23
  def self.attribute_map
50
24
  {
@@ -54,76 +28,75 @@ module AylienNewsApi
54
28
  end
55
29
 
56
30
  # Attribute type mapping.
57
- def self.api_types
31
+ def self.openapi_types
58
32
  {
59
- :'polarity' => :'String',
33
+ :'polarity' => :'SentimentPolarity',
60
34
  :'score' => :'Float'
61
35
  }
62
36
  end
63
37
 
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
64
44
  # Initializes the object
65
45
  # @param [Hash] attributes Model attributes in the form of hash
66
46
  def initialize(attributes = {})
67
- return unless attributes.is_a?(Hash)
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AylienNewsApi::Sentiment` initialize method"
49
+ end
68
50
 
69
- # convert string to symbol for hash key
70
- attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AylienNewsApi::Sentiment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
71
58
 
72
- if attributes.has_key?(:'polarity')
59
+ if attributes.key?(:'polarity')
73
60
  self.polarity = attributes[:'polarity']
74
61
  end
75
62
 
76
- if attributes.has_key?(:'score')
63
+ if attributes.key?(:'score')
77
64
  self.score = attributes[:'score']
78
65
  end
79
-
80
66
  end
81
67
 
82
68
  # Show invalid properties with the reasons. Usually used together with valid?
83
- # @return Array for valid properies with the reasons
69
+ # @return Array for valid properties with the reasons
84
70
  def list_invalid_properties
85
71
  invalid_properties = Array.new
86
- if !@score.nil? && @score > 1.0
87
- invalid_properties.push("invalid value for 'score', must be smaller than or equal to 1.0.")
72
+ if !@score.nil? && @score > 1
73
+ invalid_properties.push('invalid value for "score", must be smaller than or equal to 1.')
88
74
  end
89
75
 
90
- if !@score.nil? && @score < 0.0
91
- invalid_properties.push("invalid value for 'score', must be greater than or equal to 0.0.")
76
+ if !@score.nil? && @score < 0
77
+ invalid_properties.push('invalid value for "score", must be greater than or equal to 0.')
92
78
  end
93
79
 
94
- return invalid_properties
80
+ invalid_properties
95
81
  end
96
82
 
97
83
  # Check to see if the all the properties in the model are valid
98
84
  # @return true if the model is valid
99
85
  def valid?
100
- polarity_validator = EnumAttributeValidator.new('String', ["positive", "neutral", "negative"])
101
- return false unless polarity_validator.valid?(@polarity)
102
- return false if !@score.nil? && @score > 1.0
103
- return false if !@score.nil? && @score < 0.0
104
- return true
105
- end
106
-
107
- # Custom attribute writer method checking allowed values (enum).
108
- # @param [Object] polarity Object to be assigned
109
- def polarity=(polarity)
110
- validator = EnumAttributeValidator.new('String', ["positive", "neutral", "negative"])
111
- unless validator.valid?(polarity)
112
- fail ArgumentError, "invalid value for 'polarity', must be one of #{validator.allowable_values}."
113
- end
114
- @polarity = polarity
86
+ return false if !@score.nil? && @score > 1
87
+ return false if !@score.nil? && @score < 0
88
+ true
115
89
  end
116
90
 
117
91
  # Custom attribute writer method with validation
118
92
  # @param [Object] score Value to be assigned
119
93
  def score=(score)
120
-
121
- if !score.nil? && score > 1.0
122
- fail ArgumentError, "invalid value for 'score', must be smaller than or equal to 1.0."
94
+ if !score.nil? && score > 1
95
+ fail ArgumentError, 'invalid value for "score", must be smaller than or equal to 1.'
123
96
  end
124
97
 
125
- if !score.nil? && score < 0.0
126
- fail ArgumentError, "invalid value for 'score', must be greater than or equal to 0.0."
98
+ if !score.nil? && score < 0
99
+ fail ArgumentError, 'invalid value for "score", must be greater than or equal to 0.'
127
100
  end
128
101
 
129
102
  @score = score
@@ -145,22 +118,29 @@ module AylienNewsApi
145
118
  end
146
119
 
147
120
  # Calculates hash code according to all attributes.
148
- # @return [Fixnum] Hash code
121
+ # @return [Integer] Hash code
149
122
  def hash
150
123
  [polarity, score].hash
151
124
  end
152
125
 
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ new.build_from_hash(attributes)
131
+ end
132
+
153
133
  # Builds the object from hash
154
134
  # @param [Hash] attributes Model attributes in the form of hash
155
135
  # @return [Object] Returns the model itself
156
136
  def build_from_hash(attributes)
157
137
  return nil unless attributes.is_a?(Hash)
158
- self.class.api_types.each_pair do |key, type|
138
+ self.class.openapi_types.each_pair do |key, type|
159
139
  if type =~ /\AArray<(.*)>/i
160
- # check to ensure the input is an array given that the the attribute
140
+ # check to ensure the input is an array given that the attribute
161
141
  # is documented as an array but the input is not
162
142
  if attributes[self.class.attribute_map[key]].is_a?(Array)
163
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
164
144
  end
165
145
  elsif !attributes[self.class.attribute_map[key]].nil?
166
146
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@@ -186,7 +166,7 @@ module AylienNewsApi
186
166
  value.to_i
187
167
  when :Float
188
168
  value.to_f
189
- when :BOOLEAN
169
+ when :Boolean
190
170
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
171
  true
192
172
  else
@@ -207,8 +187,7 @@ module AylienNewsApi
207
187
  end
208
188
  end
209
189
  else # model
210
- temp_model = AylienNewsApi.const_get(type).new
211
- temp_model.build_from_hash(value)
190
+ AylienNewsApi.const_get(type).build_from_hash(value)
212
191
  end
213
192
  end
214
193
 
@@ -230,7 +209,11 @@ module AylienNewsApi
230
209
  hash = {}
231
210
  self.class.attribute_map.each_pair do |attr, param|
232
211
  value = self.send(attr)
233
- next if value.nil?
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
234
217
  hash[param] = _to_hash(value)
235
218
  end
236
219
  hash
@@ -242,7 +225,7 @@ module AylienNewsApi
242
225
  # @return [Hash] Returns the value in the form of hash
243
226
  def _to_hash(value)
244
227
  if value.is_a?(Array)
245
- value.compact.map{ |v| _to_hash(v) }
228
+ value.compact.map { |v| _to_hash(v) }
246
229
  elsif value.is_a?(Hash)
247
230
  {}.tap do |hash|
248
231
  value.each { |k, v| hash[k] = _to_hash(v) }
@@ -253,7 +236,5 @@ module AylienNewsApi
253
236
  value
254
237
  end
255
238
  end
256
-
257
239
  end
258
-
259
240
  end