rbflagr 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Makefile +9 -0
- data/README.md +143 -0
- data/Rakefile +8 -0
- data/docs/Constraint.md +11 -0
- data/docs/ConstraintApi.md +211 -0
- data/docs/CreateConstraintRequest.md +10 -0
- data/docs/CreateFlagRequest.md +8 -0
- data/docs/CreateSegmentRequest.md +9 -0
- data/docs/CreateVariantRequest.md +9 -0
- data/docs/Distribution.md +12 -0
- data/docs/DistributionApi.md +109 -0
- data/docs/Error.md +8 -0
- data/docs/EvalContext.md +12 -0
- data/docs/EvalDebugLog.md +9 -0
- data/docs/EvalResult.md +16 -0
- data/docs/EvaluationApi.md +98 -0
- data/docs/EvaluationBatchRequest.md +10 -0
- data/docs/EvaluationBatchResponse.md +8 -0
- data/docs/EvaluationEntity.md +10 -0
- data/docs/Flag.md +13 -0
- data/docs/FlagApi.md +337 -0
- data/docs/FlagSnapshot.md +11 -0
- data/docs/HealthApi.md +46 -0
- data/docs/PutDistributionsRequest.md +8 -0
- data/docs/PutFlagRequest.md +9 -0
- data/docs/PutSegmentReorderRequest.md +8 -0
- data/docs/PutSegmentRequest.md +9 -0
- data/docs/PutVariantRequest.md +9 -0
- data/docs/Segment.md +13 -0
- data/docs/SegmentApi.md +246 -0
- data/docs/SegmentDebugLog.md +9 -0
- data/docs/SetFlagEnabledRequest.md +8 -0
- data/docs/Variant.md +10 -0
- data/docs/VariantApi.md +199 -0
- data/git_push.sh +55 -0
- data/lib/rbflagr.rb +70 -0
- data/lib/rbflagr/api/constraint_api.rb +310 -0
- data/lib/rbflagr/api/distribution_api.rb +159 -0
- data/lib/rbflagr/api/evaluation_api.rb +123 -0
- data/lib/rbflagr/api/flag_api.rb +413 -0
- data/lib/rbflagr/api/health_api.rb +66 -0
- data/lib/rbflagr/api/segment_api.rb +329 -0
- data/lib/rbflagr/api/variant_api.rb +270 -0
- data/lib/rbflagr/api_client.rb +388 -0
- data/lib/rbflagr/api_error.rb +38 -0
- data/lib/rbflagr/configuration.rb +202 -0
- data/lib/rbflagr/models/constraint.rb +317 -0
- data/lib/rbflagr/models/create_constraint_request.rb +273 -0
- data/lib/rbflagr/models/create_flag_request.rb +207 -0
- data/lib/rbflagr/models/create_segment_request.rb +249 -0
- data/lib/rbflagr/models/create_variant_request.rb +216 -0
- data/lib/rbflagr/models/distribution.rb +330 -0
- data/lib/rbflagr/models/error.rb +207 -0
- data/lib/rbflagr/models/eval_context.rb +268 -0
- data/lib/rbflagr/models/eval_debug_log.rb +194 -0
- data/lib/rbflagr/models/eval_result.rb +385 -0
- data/lib/rbflagr/models/evaluation_batch_request.rb +215 -0
- data/lib/rbflagr/models/evaluation_batch_response.rb +190 -0
- data/lib/rbflagr/models/evaluation_entity.rb +225 -0
- data/lib/rbflagr/models/flag.rb +282 -0
- data/lib/rbflagr/models/flag_snapshot.rb +263 -0
- data/lib/rbflagr/models/put_distributions_request.rb +190 -0
- data/lib/rbflagr/models/put_flag_request.rb +217 -0
- data/lib/rbflagr/models/put_segment_reorder_request.rb +190 -0
- data/lib/rbflagr/models/put_segment_request.rb +249 -0
- data/lib/rbflagr/models/put_variant_request.rb +221 -0
- data/lib/rbflagr/models/segment.rb +328 -0
- data/lib/rbflagr/models/segment_debug_log.rb +207 -0
- data/lib/rbflagr/models/set_flag_enabled_request.rb +188 -0
- data/lib/rbflagr/models/variant.rb +240 -0
- data/lib/rbflagr/version.rb +15 -0
- data/rbflagr.gemspec +45 -0
- data/spec/api/constraint_api_spec.rb +91 -0
- data/spec/api/distribution_api_spec.rb +62 -0
- data/spec/api/evaluation_api_spec.rb +47 -0
- data/spec/api/flag_api_spec.rb +108 -0
- data/spec/api/health_api_spec.rb +44 -0
- data/spec/api/segment_api_spec.rb +87 -0
- data/spec/api/variant_api_spec.rb +87 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/constraint_spec.rb +64 -0
- data/spec/models/create_constraint_request_spec.rb +54 -0
- data/spec/models/create_flag_request_spec.rb +42 -0
- data/spec/models/create_segment_request_spec.rb +48 -0
- data/spec/models/create_variant_request_spec.rb +48 -0
- data/spec/models/distribution_spec.rb +66 -0
- data/spec/models/error_spec.rb +42 -0
- data/spec/models/eval_context_spec.rb +66 -0
- data/spec/models/eval_debug_log_spec.rb +48 -0
- data/spec/models/eval_result_spec.rb +78 -0
- data/spec/models/evaluation_batch_request_spec.rb +54 -0
- data/spec/models/evaluation_batch_response_spec.rb +42 -0
- data/spec/models/evaluation_entity_spec.rb +54 -0
- data/spec/models/flag_snapshot_spec.rb +60 -0
- data/spec/models/flag_spec.rb +66 -0
- data/spec/models/put_distributions_request_spec.rb +42 -0
- data/spec/models/put_flag_request_spec.rb +42 -0
- data/spec/models/put_segment_reorder_request_spec.rb +42 -0
- data/spec/models/put_segment_request_spec.rb +48 -0
- data/spec/models/put_variant_request_spec.rb +48 -0
- data/spec/models/segment_debug_log_spec.rb +48 -0
- data/spec/models/segment_spec.rb +72 -0
- data/spec/models/set_flag_enabled_request_spec.rb +42 -0
- data/spec/models/variant_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger.yaml +1135 -0
- data/swagger_ruby.json +6 -0
- data/tags +618 -0
- metadata +362 -0
@@ -0,0 +1,216 @@
|
|
1
|
+
=begin
|
2
|
+
#Flagr
|
3
|
+
|
4
|
+
#Flagr is a feature flagging, A/B testing and dynamic configuration microservice
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.8
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Flagr
|
16
|
+
class CreateVariantRequest
|
17
|
+
attr_accessor :key
|
18
|
+
|
19
|
+
attr_accessor :attachment
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'key' => :'key',
|
25
|
+
:'attachment' => :'attachment'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'key' => :'String',
|
33
|
+
:'attachment' => :'Object'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
44
|
+
|
45
|
+
if attributes.has_key?(:'key')
|
46
|
+
self.key = attributes[:'key']
|
47
|
+
end
|
48
|
+
|
49
|
+
if attributes.has_key?(:'attachment')
|
50
|
+
self.attachment = attributes[:'attachment']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def list_invalid_properties
|
57
|
+
invalid_properties = Array.new
|
58
|
+
if @key.nil?
|
59
|
+
invalid_properties.push('invalid value for "key", key cannot be nil.')
|
60
|
+
end
|
61
|
+
|
62
|
+
if @key.to_s.length < 1
|
63
|
+
invalid_properties.push('invalid value for "key", the character length must be great than or equal to 1.')
|
64
|
+
end
|
65
|
+
|
66
|
+
invalid_properties
|
67
|
+
end
|
68
|
+
|
69
|
+
# Check to see if the all the properties in the model are valid
|
70
|
+
# @return true if the model is valid
|
71
|
+
def valid?
|
72
|
+
return false if @key.nil?
|
73
|
+
return false if @key.to_s.length < 1
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# Custom attribute writer method with validation
|
78
|
+
# @param [Object] key Value to be assigned
|
79
|
+
def key=(key)
|
80
|
+
if key.nil?
|
81
|
+
fail ArgumentError, 'key cannot be nil'
|
82
|
+
end
|
83
|
+
|
84
|
+
if key.to_s.length < 1
|
85
|
+
fail ArgumentError, 'invalid value for "key", the character length must be great than or equal to 1.'
|
86
|
+
end
|
87
|
+
|
88
|
+
@key = key
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
key == o.key &&
|
97
|
+
attachment == o.attachment
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Fixnum] Hash code
|
108
|
+
def hash
|
109
|
+
[key, attachment].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def build_from_hash(attributes)
|
116
|
+
return nil unless attributes.is_a?(Hash)
|
117
|
+
self.class.swagger_types.each_pair do |key, type|
|
118
|
+
if type =~ /\AArray<(.*)>/i
|
119
|
+
# check to ensure the input is an array given that the the attribute
|
120
|
+
# is documented as an array but the input is not
|
121
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
122
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
123
|
+
end
|
124
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
125
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
126
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
127
|
+
end
|
128
|
+
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deserializes the data based on type
|
133
|
+
# @param string type Data type
|
134
|
+
# @param string value Value to be deserialized
|
135
|
+
# @return [Object] Deserialized data
|
136
|
+
def _deserialize(type, value)
|
137
|
+
case type.to_sym
|
138
|
+
when :DateTime
|
139
|
+
DateTime.parse(value)
|
140
|
+
when :Date
|
141
|
+
Date.parse(value)
|
142
|
+
when :String
|
143
|
+
value.to_s
|
144
|
+
when :Integer
|
145
|
+
value.to_i
|
146
|
+
when :Float
|
147
|
+
value.to_f
|
148
|
+
when :BOOLEAN
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
+
true
|
151
|
+
else
|
152
|
+
false
|
153
|
+
end
|
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
|
+
else # model
|
169
|
+
temp_model = Flagr.const_get(type).new
|
170
|
+
temp_model.build_from_hash(value)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the string representation of the object
|
175
|
+
# @return [String] String presentation of the object
|
176
|
+
def to_s
|
177
|
+
to_hash.to_s
|
178
|
+
end
|
179
|
+
|
180
|
+
# to_body is an alias to to_hash (backward compatibility)
|
181
|
+
# @return [Hash] Returns the object in the form of hash
|
182
|
+
def to_body
|
183
|
+
to_hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the object in the form of hash
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
188
|
+
def to_hash
|
189
|
+
hash = {}
|
190
|
+
self.class.attribute_map.each_pair do |attr, param|
|
191
|
+
value = self.send(attr)
|
192
|
+
next if value.nil?
|
193
|
+
hash[param] = _to_hash(value)
|
194
|
+
end
|
195
|
+
hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Outputs non-array value in the form of hash
|
199
|
+
# For object, use to_hash. Otherwise, just return the value
|
200
|
+
# @param [Object] value Any valid value
|
201
|
+
# @return [Hash] Returns the value in the form of hash
|
202
|
+
def _to_hash(value)
|
203
|
+
if value.is_a?(Array)
|
204
|
+
value.compact.map { |v| _to_hash(v) }
|
205
|
+
elsif value.is_a?(Hash)
|
206
|
+
{}.tap do |hash|
|
207
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
208
|
+
end
|
209
|
+
elsif value.respond_to? :to_hash
|
210
|
+
value.to_hash
|
211
|
+
else
|
212
|
+
value
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,330 @@
|
|
1
|
+
=begin
|
2
|
+
#Flagr
|
3
|
+
|
4
|
+
#Flagr is a feature flagging, A/B testing and dynamic configuration microservice
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.8
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Flagr
|
16
|
+
class Distribution
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
attr_accessor :percent
|
20
|
+
|
21
|
+
attr_accessor :bitmap
|
22
|
+
|
23
|
+
attr_accessor :variant_key
|
24
|
+
|
25
|
+
attr_accessor :variant_id
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'id' => :'id',
|
31
|
+
:'percent' => :'percent',
|
32
|
+
:'bitmap' => :'bitmap',
|
33
|
+
:'variant_key' => :'variantKey',
|
34
|
+
:'variant_id' => :'variantID'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.swagger_types
|
40
|
+
{
|
41
|
+
:'id' => :'Integer',
|
42
|
+
:'percent' => :'Integer',
|
43
|
+
:'bitmap' => :'String',
|
44
|
+
:'variant_key' => :'String',
|
45
|
+
:'variant_id' => :'Integer'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
return unless attributes.is_a?(Hash)
|
53
|
+
|
54
|
+
# convert string to symbol for hash key
|
55
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
56
|
+
|
57
|
+
if attributes.has_key?(:'id')
|
58
|
+
self.id = attributes[:'id']
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes.has_key?(:'percent')
|
62
|
+
self.percent = attributes[:'percent']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.has_key?(:'bitmap')
|
66
|
+
self.bitmap = attributes[:'bitmap']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.has_key?(:'variantKey')
|
70
|
+
self.variant_key = attributes[:'variantKey']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'variantID')
|
74
|
+
self.variant_id = attributes[:'variantID']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def list_invalid_properties
|
81
|
+
invalid_properties = Array.new
|
82
|
+
if !@id.nil? && @id < 1
|
83
|
+
invalid_properties.push('invalid value for "id", must be greater than or equal to 1.')
|
84
|
+
end
|
85
|
+
|
86
|
+
if @percent.nil?
|
87
|
+
invalid_properties.push('invalid value for "percent", percent cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if @percent > 100
|
91
|
+
invalid_properties.push('invalid value for "percent", must be smaller than or equal to 100.')
|
92
|
+
end
|
93
|
+
|
94
|
+
if @percent < 0
|
95
|
+
invalid_properties.push('invalid value for "percent", must be greater than or equal to 0.')
|
96
|
+
end
|
97
|
+
|
98
|
+
if !@bitmap.nil? && @bitmap.to_s.length < 1
|
99
|
+
invalid_properties.push('invalid value for "bitmap", the character length must be great than or equal to 1.')
|
100
|
+
end
|
101
|
+
|
102
|
+
if @variant_key.nil?
|
103
|
+
invalid_properties.push('invalid value for "variant_key", variant_key cannot be nil.')
|
104
|
+
end
|
105
|
+
|
106
|
+
if @variant_key.to_s.length < 1
|
107
|
+
invalid_properties.push('invalid value for "variant_key", the character length must be great than or equal to 1.')
|
108
|
+
end
|
109
|
+
|
110
|
+
if @variant_id.nil?
|
111
|
+
invalid_properties.push('invalid value for "variant_id", variant_id cannot be nil.')
|
112
|
+
end
|
113
|
+
|
114
|
+
if @variant_id < 1
|
115
|
+
invalid_properties.push('invalid value for "variant_id", must be greater than or equal to 1.')
|
116
|
+
end
|
117
|
+
|
118
|
+
invalid_properties
|
119
|
+
end
|
120
|
+
|
121
|
+
# Check to see if the all the properties in the model are valid
|
122
|
+
# @return true if the model is valid
|
123
|
+
def valid?
|
124
|
+
return false if !@id.nil? && @id < 1
|
125
|
+
return false if @percent.nil?
|
126
|
+
return false if @percent > 100
|
127
|
+
return false if @percent < 0
|
128
|
+
return false if !@bitmap.nil? && @bitmap.to_s.length < 1
|
129
|
+
return false if @variant_key.nil?
|
130
|
+
return false if @variant_key.to_s.length < 1
|
131
|
+
return false if @variant_id.nil?
|
132
|
+
return false if @variant_id < 1
|
133
|
+
true
|
134
|
+
end
|
135
|
+
|
136
|
+
# Custom attribute writer method with validation
|
137
|
+
# @param [Object] id Value to be assigned
|
138
|
+
def id=(id)
|
139
|
+
if !id.nil? && id < 1
|
140
|
+
fail ArgumentError, 'invalid value for "id", must be greater than or equal to 1.'
|
141
|
+
end
|
142
|
+
|
143
|
+
@id = id
|
144
|
+
end
|
145
|
+
|
146
|
+
# Custom attribute writer method with validation
|
147
|
+
# @param [Object] percent Value to be assigned
|
148
|
+
def percent=(percent)
|
149
|
+
if percent.nil?
|
150
|
+
fail ArgumentError, 'percent cannot be nil'
|
151
|
+
end
|
152
|
+
|
153
|
+
if percent > 100
|
154
|
+
fail ArgumentError, 'invalid value for "percent", must be smaller than or equal to 100.'
|
155
|
+
end
|
156
|
+
|
157
|
+
if percent < 0
|
158
|
+
fail ArgumentError, 'invalid value for "percent", must be greater than or equal to 0.'
|
159
|
+
end
|
160
|
+
|
161
|
+
@percent = percent
|
162
|
+
end
|
163
|
+
|
164
|
+
# Custom attribute writer method with validation
|
165
|
+
# @param [Object] bitmap Value to be assigned
|
166
|
+
def bitmap=(bitmap)
|
167
|
+
if !bitmap.nil? && bitmap.to_s.length < 1
|
168
|
+
fail ArgumentError, 'invalid value for "bitmap", the character length must be great than or equal to 1.'
|
169
|
+
end
|
170
|
+
|
171
|
+
@bitmap = bitmap
|
172
|
+
end
|
173
|
+
|
174
|
+
# Custom attribute writer method with validation
|
175
|
+
# @param [Object] variant_key Value to be assigned
|
176
|
+
def variant_key=(variant_key)
|
177
|
+
if variant_key.nil?
|
178
|
+
fail ArgumentError, 'variant_key cannot be nil'
|
179
|
+
end
|
180
|
+
|
181
|
+
if variant_key.to_s.length < 1
|
182
|
+
fail ArgumentError, 'invalid value for "variant_key", the character length must be great than or equal to 1.'
|
183
|
+
end
|
184
|
+
|
185
|
+
@variant_key = variant_key
|
186
|
+
end
|
187
|
+
|
188
|
+
# Custom attribute writer method with validation
|
189
|
+
# @param [Object] variant_id Value to be assigned
|
190
|
+
def variant_id=(variant_id)
|
191
|
+
if variant_id.nil?
|
192
|
+
fail ArgumentError, 'variant_id cannot be nil'
|
193
|
+
end
|
194
|
+
|
195
|
+
if variant_id < 1
|
196
|
+
fail ArgumentError, 'invalid value for "variant_id", must be greater than or equal to 1.'
|
197
|
+
end
|
198
|
+
|
199
|
+
@variant_id = variant_id
|
200
|
+
end
|
201
|
+
|
202
|
+
# Checks equality by comparing each attribute.
|
203
|
+
# @param [Object] Object to be compared
|
204
|
+
def ==(o)
|
205
|
+
return true if self.equal?(o)
|
206
|
+
self.class == o.class &&
|
207
|
+
id == o.id &&
|
208
|
+
percent == o.percent &&
|
209
|
+
bitmap == o.bitmap &&
|
210
|
+
variant_key == o.variant_key &&
|
211
|
+
variant_id == o.variant_id
|
212
|
+
end
|
213
|
+
|
214
|
+
# @see the `==` method
|
215
|
+
# @param [Object] Object to be compared
|
216
|
+
def eql?(o)
|
217
|
+
self == o
|
218
|
+
end
|
219
|
+
|
220
|
+
# Calculates hash code according to all attributes.
|
221
|
+
# @return [Fixnum] Hash code
|
222
|
+
def hash
|
223
|
+
[id, percent, bitmap, variant_key, variant_id].hash
|
224
|
+
end
|
225
|
+
|
226
|
+
# Builds the object from hash
|
227
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
228
|
+
# @return [Object] Returns the model itself
|
229
|
+
def build_from_hash(attributes)
|
230
|
+
return nil unless attributes.is_a?(Hash)
|
231
|
+
self.class.swagger_types.each_pair do |key, type|
|
232
|
+
if type =~ /\AArray<(.*)>/i
|
233
|
+
# check to ensure the input is an array given that the the attribute
|
234
|
+
# is documented as an array but the input is not
|
235
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
236
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
237
|
+
end
|
238
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
239
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
240
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
241
|
+
end
|
242
|
+
|
243
|
+
self
|
244
|
+
end
|
245
|
+
|
246
|
+
# Deserializes the data based on type
|
247
|
+
# @param string type Data type
|
248
|
+
# @param string value Value to be deserialized
|
249
|
+
# @return [Object] Deserialized data
|
250
|
+
def _deserialize(type, value)
|
251
|
+
case type.to_sym
|
252
|
+
when :DateTime
|
253
|
+
DateTime.parse(value)
|
254
|
+
when :Date
|
255
|
+
Date.parse(value)
|
256
|
+
when :String
|
257
|
+
value.to_s
|
258
|
+
when :Integer
|
259
|
+
value.to_i
|
260
|
+
when :Float
|
261
|
+
value.to_f
|
262
|
+
when :BOOLEAN
|
263
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
264
|
+
true
|
265
|
+
else
|
266
|
+
false
|
267
|
+
end
|
268
|
+
when :Object
|
269
|
+
# generic object (usually a Hash), return directly
|
270
|
+
value
|
271
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
272
|
+
inner_type = Regexp.last_match[:inner_type]
|
273
|
+
value.map { |v| _deserialize(inner_type, v) }
|
274
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
275
|
+
k_type = Regexp.last_match[:k_type]
|
276
|
+
v_type = Regexp.last_match[:v_type]
|
277
|
+
{}.tap do |hash|
|
278
|
+
value.each do |k, v|
|
279
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
else # model
|
283
|
+
temp_model = Flagr.const_get(type).new
|
284
|
+
temp_model.build_from_hash(value)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
# Returns the string representation of the object
|
289
|
+
# @return [String] String presentation of the object
|
290
|
+
def to_s
|
291
|
+
to_hash.to_s
|
292
|
+
end
|
293
|
+
|
294
|
+
# to_body is an alias to to_hash (backward compatibility)
|
295
|
+
# @return [Hash] Returns the object in the form of hash
|
296
|
+
def to_body
|
297
|
+
to_hash
|
298
|
+
end
|
299
|
+
|
300
|
+
# Returns the object in the form of hash
|
301
|
+
# @return [Hash] Returns the object in the form of hash
|
302
|
+
def to_hash
|
303
|
+
hash = {}
|
304
|
+
self.class.attribute_map.each_pair do |attr, param|
|
305
|
+
value = self.send(attr)
|
306
|
+
next if value.nil?
|
307
|
+
hash[param] = _to_hash(value)
|
308
|
+
end
|
309
|
+
hash
|
310
|
+
end
|
311
|
+
|
312
|
+
# Outputs non-array value in the form of hash
|
313
|
+
# For object, use to_hash. Otherwise, just return the value
|
314
|
+
# @param [Object] value Any valid value
|
315
|
+
# @return [Hash] Returns the value in the form of hash
|
316
|
+
def _to_hash(value)
|
317
|
+
if value.is_a?(Array)
|
318
|
+
value.compact.map { |v| _to_hash(v) }
|
319
|
+
elsif value.is_a?(Hash)
|
320
|
+
{}.tap do |hash|
|
321
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
322
|
+
end
|
323
|
+
elsif value.respond_to? :to_hash
|
324
|
+
value.to_hash
|
325
|
+
else
|
326
|
+
value
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|