algolia 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,240 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Usage
8
- class ErrorItem
9
- attr_accessor :code
10
-
11
- attr_accessor :message
12
-
13
- attr_accessor :line
14
-
15
- attr_accessor :position
16
-
17
- # Attribute mapping from ruby-style variable name to JSON key.
18
- def self.attribute_map
19
- {
20
- :code => :code,
21
- :message => :message,
22
- :line => :line,
23
- :position => :position
24
- }
25
- end
26
-
27
- # Returns all the JSON keys this model knows about
28
- def self.acceptable_attributes
29
- attribute_map.values
30
- end
31
-
32
- # Attribute type mapping.
33
- def self.types_mapping
34
- {
35
- :code => :"String",
36
- :message => :"String",
37
- :line => :"Integer",
38
- :position => :"Integer"
39
- }
40
- end
41
-
42
- # List of attributes with nullable: true
43
- def self.openapi_nullable
44
- Set.new(
45
- []
46
- )
47
- end
48
-
49
- # Initializes the object
50
- # @param [Hash] attributes Model attributes in the form of hash
51
- def initialize(attributes = {})
52
- if (!attributes.is_a?(Hash))
53
- raise(
54
- ArgumentError,
55
- "The input argument (attributes) must be a hash in `Algolia::ErrorItem` initialize method"
56
- )
57
- end
58
-
59
- # check to see if the attribute exists and convert string to symbol for hash key
60
- attributes = attributes.each_with_object({}) { |(k, v), h|
61
- if (!self.class.attribute_map.key?(k.to_sym))
62
- raise(
63
- ArgumentError,
64
- "`#{k}` is not a valid attribute in `Algolia::ErrorItem`. Please check the name to make sure it's valid. List of attributes: " +
65
- self.class.attribute_map.keys.inspect
66
- )
67
- end
68
-
69
- h[k.to_sym] = v
70
- }
71
-
72
- if attributes.key?(:code)
73
- self.code = attributes[:code]
74
- end
75
-
76
- if attributes.key?(:message)
77
- self.message = attributes[:message]
78
- else
79
- self.message = nil
80
- end
81
-
82
- if attributes.key?(:line)
83
- self.line = attributes[:line]
84
- end
85
-
86
- if attributes.key?(:position)
87
- self.position = attributes[:position]
88
- end
89
- end
90
-
91
- # Checks equality by comparing each attribute.
92
- # @param [Object] Object to be compared
93
- def ==(other)
94
- return true if self.equal?(other)
95
- self.class == other.class &&
96
- code == other.code &&
97
- message == other.message &&
98
- line == other.line &&
99
- position == other.position
100
- end
101
-
102
- # @see the `==` method
103
- # @param [Object] Object to be compared
104
- def eql?(other)
105
- self == other
106
- end
107
-
108
- # Calculates hash code according to all attributes.
109
- # @return [Integer] Hash code
110
- def hash
111
- [code, message, line, position].hash
112
- end
113
-
114
- # Builds the object from hash
115
- # @param [Hash] attributes Model attributes in the form of hash
116
- # @return [Object] Returns the model itself
117
- def self.build_from_hash(attributes)
118
- return nil unless attributes.is_a?(Hash)
119
- attributes = attributes.transform_keys(&:to_sym)
120
- transformed_hash = {}
121
- types_mapping.each_pair do |key, type|
122
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
123
- transformed_hash[key.to_sym] = nil
124
- elsif type =~ /\AArray<(.*)>/i
125
- # check to ensure the input is an array given that the attribute
126
- # is documented as an array but the input is not
127
- if attributes[attribute_map[key]].is_a?(Array)
128
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
129
- _deserialize(::Regexp.last_match(1), v)
130
- }
131
- end
132
- elsif !attributes[attribute_map[key]].nil?
133
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
134
- end
135
- end
136
-
137
- new(transformed_hash)
138
- end
139
-
140
- # Deserializes the data based on type
141
- # @param string type Data type
142
- # @param string value Value to be deserialized
143
- # @return [Object] Deserialized data
144
- def self._deserialize(type, value)
145
- case type.to_sym
146
- when :Time
147
- Time.parse(value)
148
- when :Date
149
- Date.parse(value)
150
- when :String
151
- value.to_s
152
- when :Integer
153
- value.to_i
154
- when :Float
155
- value.to_f
156
- when :Boolean
157
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
- true
159
- else
160
- false
161
- end
162
-
163
- when :Object
164
- # generic object (usually a Hash), return directly
165
- value
166
- when /\AArray<(?<inner_type>.+)>\z/
167
- inner_type = Regexp.last_match[:inner_type]
168
- value.map { |v| _deserialize(inner_type, v) }
169
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
- k_type = Regexp.last_match[:k_type]
171
- v_type = Regexp.last_match[:v_type]
172
- {}.tap do |hash|
173
- value.each do |k, v|
174
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
- end
176
- end
177
- # model
178
- else
179
- # models (e.g. Pet) or oneOf
180
- klass = Algolia::Usage.const_get(type)
181
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
182
- .build_from_hash(value)
183
- end
184
- end
185
-
186
- # Returns the string representation of the object
187
- # @return [String] String presentation of the object
188
- def to_s
189
- to_hash.to_s
190
- end
191
-
192
- # to_body is an alias to to_hash (backward compatibility)
193
- # @return [Hash] Returns the object in the form of hash
194
- def to_body
195
- to_hash
196
- end
197
-
198
- def to_json(*_args)
199
- to_hash.to_json
200
- end
201
-
202
- # Returns the object in the form of hash
203
- # @return [Hash] Returns the object in the form of hash
204
- def to_hash
205
- hash = {}
206
- self.class.attribute_map.each_pair do |attr, param|
207
- value = send(attr)
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
-
213
- hash[param] = _to_hash(value)
214
- end
215
-
216
- hash
217
- end
218
-
219
- # Outputs non-array value in the form of hash
220
- # For object, use to_hash. Otherwise, just return the value
221
- # @param [Object] value Any valid value
222
- # @return [Hash] Returns the value in the form of hash
223
- def _to_hash(value)
224
- if value.is_a?(Array)
225
- value.compact.map { |v| _to_hash(v) }
226
- elsif value.is_a?(Hash)
227
- {}.tap do |hash|
228
- value.each { |k, v| hash[k] = _to_hash(v) }
229
- end
230
- elsif value.respond_to?(:to_hash)
231
- value.to_hash
232
- else
233
- value
234
- end
235
- end
236
-
237
- end
238
-
239
- end
240
- end
@@ -1,231 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Usage
8
- class ForbiddenError
9
- attr_accessor :code
10
-
11
- attr_accessor :message
12
-
13
- attr_accessor :errors
14
-
15
- # Attribute mapping from ruby-style variable name to JSON key.
16
- def self.attribute_map
17
- {
18
- :code => :code,
19
- :message => :message,
20
- :errors => :errors
21
- }
22
- end
23
-
24
- # Returns all the JSON keys this model knows about
25
- def self.acceptable_attributes
26
- attribute_map.values
27
- end
28
-
29
- # Attribute type mapping.
30
- def self.types_mapping
31
- {
32
- :code => :"String",
33
- :message => :"String",
34
- :errors => :"Array<ErrorItem>"
35
- }
36
- end
37
-
38
- # List of attributes with nullable: true
39
- def self.openapi_nullable
40
- Set.new(
41
- []
42
- )
43
- end
44
-
45
- # Initializes the object
46
- # @param [Hash] attributes Model attributes in the form of hash
47
- def initialize(attributes = {})
48
- if (!attributes.is_a?(Hash))
49
- raise(
50
- ArgumentError,
51
- "The input argument (attributes) must be a hash in `Algolia::ForbiddenError` initialize method"
52
- )
53
- end
54
-
55
- # check to see if the attribute exists and convert string to symbol for hash key
56
- attributes = attributes.each_with_object({}) { |(k, v), h|
57
- if (!self.class.attribute_map.key?(k.to_sym))
58
- raise(
59
- ArgumentError,
60
- "`#{k}` is not a valid attribute in `Algolia::ForbiddenError`. Please check the name to make sure it's valid. List of attributes: " +
61
- self.class.attribute_map.keys.inspect
62
- )
63
- end
64
-
65
- h[k.to_sym] = v
66
- }
67
-
68
- if attributes.key?(:code)
69
- self.code = attributes[:code]
70
- end
71
-
72
- if attributes.key?(:message)
73
- self.message = attributes[:message]
74
- end
75
-
76
- if attributes.key?(:errors)
77
- if (value = attributes[:errors]).is_a?(Array)
78
- self.errors = value
79
- end
80
- end
81
- end
82
-
83
- # Checks equality by comparing each attribute.
84
- # @param [Object] Object to be compared
85
- def ==(other)
86
- return true if self.equal?(other)
87
- self.class == other.class &&
88
- code == other.code &&
89
- message == other.message &&
90
- errors == other.errors
91
- end
92
-
93
- # @see the `==` method
94
- # @param [Object] Object to be compared
95
- def eql?(other)
96
- self == other
97
- end
98
-
99
- # Calculates hash code according to all attributes.
100
- # @return [Integer] Hash code
101
- def hash
102
- [code, message, errors].hash
103
- end
104
-
105
- # Builds the object from hash
106
- # @param [Hash] attributes Model attributes in the form of hash
107
- # @return [Object] Returns the model itself
108
- def self.build_from_hash(attributes)
109
- return nil unless attributes.is_a?(Hash)
110
- attributes = attributes.transform_keys(&:to_sym)
111
- transformed_hash = {}
112
- types_mapping.each_pair do |key, type|
113
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
114
- transformed_hash[key.to_sym] = nil
115
- elsif type =~ /\AArray<(.*)>/i
116
- # check to ensure the input is an array given that the attribute
117
- # is documented as an array but the input is not
118
- if attributes[attribute_map[key]].is_a?(Array)
119
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
120
- _deserialize(::Regexp.last_match(1), v)
121
- }
122
- end
123
- elsif !attributes[attribute_map[key]].nil?
124
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
125
- end
126
- end
127
-
128
- new(transformed_hash)
129
- end
130
-
131
- # Deserializes the data based on type
132
- # @param string type Data type
133
- # @param string value Value to be deserialized
134
- # @return [Object] Deserialized data
135
- def self._deserialize(type, value)
136
- case type.to_sym
137
- when :Time
138
- Time.parse(value)
139
- when :Date
140
- Date.parse(value)
141
- when :String
142
- value.to_s
143
- when :Integer
144
- value.to_i
145
- when :Float
146
- value.to_f
147
- when :Boolean
148
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
- true
150
- else
151
- false
152
- end
153
-
154
- when :Object
155
- # generic object (usually a Hash), return directly
156
- value
157
- when /\AArray<(?<inner_type>.+)>\z/
158
- inner_type = Regexp.last_match[:inner_type]
159
- value.map { |v| _deserialize(inner_type, v) }
160
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
161
- k_type = Regexp.last_match[:k_type]
162
- v_type = Regexp.last_match[:v_type]
163
- {}.tap do |hash|
164
- value.each do |k, v|
165
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
166
- end
167
- end
168
- # model
169
- else
170
- # models (e.g. Pet) or oneOf
171
- klass = Algolia::Usage.const_get(type)
172
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
173
- .build_from_hash(value)
174
- end
175
- end
176
-
177
- # Returns the string representation of the object
178
- # @return [String] String presentation of the object
179
- def to_s
180
- to_hash.to_s
181
- end
182
-
183
- # to_body is an alias to to_hash (backward compatibility)
184
- # @return [Hash] Returns the object in the form of hash
185
- def to_body
186
- to_hash
187
- end
188
-
189
- def to_json(*_args)
190
- to_hash.to_json
191
- end
192
-
193
- # Returns the object in the form of hash
194
- # @return [Hash] Returns the object in the form of hash
195
- def to_hash
196
- hash = {}
197
- self.class.attribute_map.each_pair do |attr, param|
198
- value = send(attr)
199
- if value.nil?
200
- is_nullable = self.class.openapi_nullable.include?(attr)
201
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
- end
203
-
204
- hash[param] = _to_hash(value)
205
- end
206
-
207
- hash
208
- end
209
-
210
- # Outputs non-array value in the form of hash
211
- # For object, use to_hash. Otherwise, just return the value
212
- # @param [Object] value Any valid value
213
- # @return [Hash] Returns the value in the form of hash
214
- def _to_hash(value)
215
- if value.is_a?(Array)
216
- value.compact.map { |v| _to_hash(v) }
217
- elsif value.is_a?(Hash)
218
- {}.tap do |hash|
219
- value.each { |k, v| hash[k] = _to_hash(v) }
220
- end
221
- elsif value.respond_to?(:to_hash)
222
- value.to_hash
223
- else
224
- value
225
- end
226
- end
227
-
228
- end
229
-
230
- end
231
- end
@@ -1,32 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Usage
8
- class Granularity
9
- HOURLY = "hourly".freeze
10
- DAILY = "daily".freeze
11
-
12
- def self.all_vars
13
- @all_vars ||= [HOURLY, DAILY].freeze
14
- end
15
-
16
- # Builds the enum from string
17
- # @param [String] The enum value in the form of the string
18
- # @return [String] The enum value
19
- def self.build_from_hash(value)
20
- new.build_from_hash(value)
21
- end
22
-
23
- # Builds the enum from string
24
- # @param [String] The enum value in the form of the string
25
- # @return [String] The enum value
26
- def build_from_hash(value)
27
- return value if Granularity.all_vars.include?(value)
28
- raise "Invalid ENUM value #{value} for class #Granularity"
29
- end
30
- end
31
- end
32
- end
@@ -1,213 +0,0 @@
1
- # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
-
3
- require "date"
4
- require "time"
5
-
6
- module Algolia
7
- module Usage
8
- class IndexUsage
9
- attr_accessor :statistics
10
-
11
- # Attribute mapping from ruby-style variable name to JSON key.
12
- def self.attribute_map
13
- {
14
- :statistics => :statistics
15
- }
16
- end
17
-
18
- # Returns all the JSON keys this model knows about
19
- def self.acceptable_attributes
20
- attribute_map.values
21
- end
22
-
23
- # Attribute type mapping.
24
- def self.types_mapping
25
- {
26
- :statistics => :"Array<StatisticEntry>"
27
- }
28
- end
29
-
30
- # List of attributes with nullable: true
31
- def self.openapi_nullable
32
- Set.new(
33
- []
34
- )
35
- end
36
-
37
- # Initializes the object
38
- # @param [Hash] attributes Model attributes in the form of hash
39
- def initialize(attributes = {})
40
- if (!attributes.is_a?(Hash))
41
- raise(
42
- ArgumentError,
43
- "The input argument (attributes) must be a hash in `Algolia::IndexUsage` initialize method"
44
- )
45
- end
46
-
47
- # check to see if the attribute exists and convert string to symbol for hash key
48
- attributes = attributes.each_with_object({}) { |(k, v), h|
49
- if (!self.class.attribute_map.key?(k.to_sym))
50
- raise(
51
- ArgumentError,
52
- "`#{k}` is not a valid attribute in `Algolia::IndexUsage`. Please check the name to make sure it's valid. List of attributes: " +
53
- self.class.attribute_map.keys.inspect
54
- )
55
- end
56
-
57
- h[k.to_sym] = v
58
- }
59
-
60
- if attributes.key?(:statistics)
61
- if (value = attributes[:statistics]).is_a?(Array)
62
- self.statistics = value
63
- end
64
- end
65
- end
66
-
67
- # Checks equality by comparing each attribute.
68
- # @param [Object] Object to be compared
69
- def ==(other)
70
- return true if self.equal?(other)
71
- self.class == other.class &&
72
- statistics == other.statistics
73
- end
74
-
75
- # @see the `==` method
76
- # @param [Object] Object to be compared
77
- def eql?(other)
78
- self == other
79
- end
80
-
81
- # Calculates hash code according to all attributes.
82
- # @return [Integer] Hash code
83
- def hash
84
- [statistics].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 self.build_from_hash(attributes)
91
- return nil unless attributes.is_a?(Hash)
92
- attributes = attributes.transform_keys(&:to_sym)
93
- transformed_hash = {}
94
- types_mapping.each_pair do |key, type|
95
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
96
- transformed_hash[key.to_sym] = nil
97
- elsif type =~ /\AArray<(.*)>/i
98
- # check to ensure the input is an array given that the attribute
99
- # is documented as an array but the input is not
100
- if attributes[attribute_map[key]].is_a?(Array)
101
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
102
- _deserialize(::Regexp.last_match(1), v)
103
- }
104
- end
105
- elsif !attributes[attribute_map[key]].nil?
106
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
107
- end
108
- end
109
-
110
- new(transformed_hash)
111
- end
112
-
113
- # Deserializes the data based on type
114
- # @param string type Data type
115
- # @param string value Value to be deserialized
116
- # @return [Object] Deserialized data
117
- def self._deserialize(type, value)
118
- case type.to_sym
119
- when :Time
120
- Time.parse(value)
121
- when :Date
122
- Date.parse(value)
123
- when :String
124
- value.to_s
125
- when :Integer
126
- value.to_i
127
- when :Float
128
- value.to_f
129
- when :Boolean
130
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
- true
132
- else
133
- false
134
- end
135
-
136
- when :Object
137
- # generic object (usually a Hash), return directly
138
- value
139
- when /\AArray<(?<inner_type>.+)>\z/
140
- inner_type = Regexp.last_match[:inner_type]
141
- value.map { |v| _deserialize(inner_type, v) }
142
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
143
- k_type = Regexp.last_match[:k_type]
144
- v_type = Regexp.last_match[:v_type]
145
- {}.tap do |hash|
146
- value.each do |k, v|
147
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
- end
149
- end
150
- # model
151
- else
152
- # models (e.g. Pet) or oneOf
153
- klass = Algolia::Usage.const_get(type)
154
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
155
- .build_from_hash(value)
156
- end
157
- end
158
-
159
- # Returns the string representation of the object
160
- # @return [String] String presentation of the object
161
- def to_s
162
- to_hash.to_s
163
- end
164
-
165
- # to_body is an alias to to_hash (backward compatibility)
166
- # @return [Hash] Returns the object in the form of hash
167
- def to_body
168
- to_hash
169
- end
170
-
171
- def to_json(*_args)
172
- to_hash.to_json
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 = send(attr)
181
- if value.nil?
182
- is_nullable = self.class.openapi_nullable.include?(attr)
183
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
184
- end
185
-
186
- hash[param] = _to_hash(value)
187
- end
188
-
189
- hash
190
- end
191
-
192
- # Outputs non-array value in the form of hash
193
- # For object, use to_hash. Otherwise, just return the value
194
- # @param [Object] value Any valid value
195
- # @return [Hash] Returns the value in the form of hash
196
- def _to_hash(value)
197
- if value.is_a?(Array)
198
- value.compact.map { |v| _to_hash(v) }
199
- elsif value.is_a?(Hash)
200
- {}.tap do |hash|
201
- value.each { |k, v| hash[k] = _to_hash(v) }
202
- end
203
- elsif value.respond_to?(:to_hash)
204
- value.to_hash
205
- else
206
- value
207
- end
208
- end
209
-
210
- end
211
-
212
- end
213
- end