rbflagr 0.1.2

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