insights-approval-api-client 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +142 -0
  4. data/Rakefile +10 -0
  5. data/client-meta.json +9 -0
  6. data/docs/Action.md +27 -0
  7. data/docs/ActionApi.md +172 -0
  8. data/docs/ActionCollection.md +21 -0
  9. data/docs/CollectionLinks.md +23 -0
  10. data/docs/CollectionMetadata.md +21 -0
  11. data/docs/GraphqlApi.md +62 -0
  12. data/docs/GraphqlIn.md +21 -0
  13. data/docs/GraphqlOut.md +19 -0
  14. data/docs/GroupRef.md +19 -0
  15. data/docs/HttpApiError.md +19 -0
  16. data/docs/HttpApiErrorCollection.md +17 -0
  17. data/docs/Request.md +49 -0
  18. data/docs/RequestApi.md +292 -0
  19. data/docs/RequestCollection.md +21 -0
  20. data/docs/RequestIn.md +23 -0
  21. data/docs/ResourceObject.md +21 -0
  22. data/docs/Tag.md +17 -0
  23. data/docs/TagResource.md +21 -0
  24. data/docs/Template.md +23 -0
  25. data/docs/TemplateApi.md +124 -0
  26. data/docs/TemplateCollection.md +21 -0
  27. data/docs/Workflow.md +29 -0
  28. data/docs/WorkflowApi.md +469 -0
  29. data/docs/WorkflowCollection.md +21 -0
  30. data/generate.sh +9 -0
  31. data/git_push.sh +58 -0
  32. data/insights-approval-api-client.gemspec +39 -0
  33. data/lib/insights-approval-api-client.rb +63 -0
  34. data/lib/insights-approval-api-client/api/action_api.rb +231 -0
  35. data/lib/insights-approval-api-client/api/graphql_api.rb +86 -0
  36. data/lib/insights-approval-api-client/api/request_api.rb +381 -0
  37. data/lib/insights-approval-api-client/api/template_api.rb +169 -0
  38. data/lib/insights-approval-api-client/api/workflow_api.rb +630 -0
  39. data/lib/insights-approval-api-client/api_client.rb +386 -0
  40. data/lib/insights-approval-api-client/api_error.rb +57 -0
  41. data/lib/insights-approval-api-client/configuration.rb +268 -0
  42. data/lib/insights-approval-api-client/models/action.rb +293 -0
  43. data/lib/insights-approval-api-client/models/action_collection.rb +226 -0
  44. data/lib/insights-approval-api-client/models/collection_links.rb +237 -0
  45. data/lib/insights-approval-api-client/models/collection_metadata.rb +227 -0
  46. data/lib/insights-approval-api-client/models/graphql_in.rb +237 -0
  47. data/lib/insights-approval-api-client/models/graphql_out.rb +219 -0
  48. data/lib/insights-approval-api-client/models/group_ref.rb +223 -0
  49. data/lib/insights-approval-api-client/models/http_api_error.rb +218 -0
  50. data/lib/insights-approval-api-client/models/http_api_error_collection.rb +210 -0
  51. data/lib/insights-approval-api-client/models/request.rb +417 -0
  52. data/lib/insights-approval-api-client/models/request_collection.rb +226 -0
  53. data/lib/insights-approval-api-client/models/request_in.rb +255 -0
  54. data/lib/insights-approval-api-client/models/resource_object.rb +243 -0
  55. data/lib/insights-approval-api-client/models/tag.rb +207 -0
  56. data/lib/insights-approval-api-client/models/tag_resource.rb +242 -0
  57. data/lib/insights-approval-api-client/models/template.rb +235 -0
  58. data/lib/insights-approval-api-client/models/template_collection.rb +226 -0
  59. data/lib/insights-approval-api-client/models/workflow.rb +283 -0
  60. data/lib/insights-approval-api-client/models/workflow_collection.rb +226 -0
  61. data/lib/insights-approval-api-client/version.rb +15 -0
  62. data/openapi.json +1540 -0
  63. data/spec/api/action_api_spec.rb +72 -0
  64. data/spec/api/graphql_api_spec.rb +47 -0
  65. data/spec/api/request_api_spec.rb +100 -0
  66. data/spec/api/template_api_spec.rb +62 -0
  67. data/spec/api/workflow_api_spec.rb +145 -0
  68. data/spec/api_client_spec.rb +226 -0
  69. data/spec/configuration_spec.rb +42 -0
  70. data/spec/models/action_collection_spec.rb +53 -0
  71. data/spec/models/action_spec.rb +75 -0
  72. data/spec/models/collection_links_spec.rb +59 -0
  73. data/spec/models/collection_metadata_spec.rb +53 -0
  74. data/spec/models/graphql_in_spec.rb +53 -0
  75. data/spec/models/graphql_out_spec.rb +47 -0
  76. data/spec/models/group_ref_spec.rb +47 -0
  77. data/spec/models/http_api_error_collection_spec.rb +41 -0
  78. data/spec/models/http_api_error_spec.rb +47 -0
  79. data/spec/models/request_collection_spec.rb +53 -0
  80. data/spec/models/request_in_spec.rb +59 -0
  81. data/spec/models/request_spec.rb +145 -0
  82. data/spec/models/resource_object_spec.rb +53 -0
  83. data/spec/models/tag_resource_spec.rb +53 -0
  84. data/spec/models/tag_spec.rb +41 -0
  85. data/spec/models/template_collection_spec.rb +53 -0
  86. data/spec/models/template_spec.rb +59 -0
  87. data/spec/models/workflow_collection_spec.rb +53 -0
  88. data/spec/models/workflow_spec.rb +77 -0
  89. data/spec/spec_helper.rb +111 -0
  90. metadata +218 -0
@@ -0,0 +1,207 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ApprovalApiClient
16
+ # tag details
17
+ class Tag
18
+ attr_accessor :tag
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'tag' => :'tag'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'tag' => :'String'
31
+ }
32
+ end
33
+
34
+ # List of attributes with nullable: true
35
+ def self.openapi_nullable
36
+ Set.new([
37
+ ])
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ApprovalApiClient::Tag` initialize method"
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
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ApprovalApiClient::Tag`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'tag')
56
+ self.tag = attributes[:'tag']
57
+ end
58
+ end
59
+
60
+ # Show invalid properties with the reasons. Usually used together with valid?
61
+ # @return Array for valid properties with the reasons
62
+ def list_invalid_properties
63
+ invalid_properties = Array.new
64
+ invalid_properties
65
+ end
66
+
67
+ # Check to see if the all the properties in the model are valid
68
+ # @return true if the model is valid
69
+ def valid?
70
+ true
71
+ end
72
+
73
+ # Checks equality by comparing each attribute.
74
+ # @param [Object] Object to be compared
75
+ def ==(o)
76
+ return true if self.equal?(o)
77
+ self.class == o.class &&
78
+ tag == o.tag
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(o)
84
+ self == o
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Integer] Hash code
89
+ def hash
90
+ [tag].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def self.build_from_hash(attributes)
97
+ new.build_from_hash(attributes)
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.openapi_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :Boolean
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ ApprovalApiClient.const_get(type).build_from_hash(value)
158
+ end
159
+ end
160
+
161
+ # Returns the string representation of the object
162
+ # @return [String] String presentation of the object
163
+ def to_s
164
+ to_hash.to_s
165
+ end
166
+
167
+ # to_body is an alias to to_hash (backward compatibility)
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_body
170
+ to_hash
171
+ end
172
+
173
+ # Returns the object in the form of hash
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_hash
176
+ hash = {}
177
+ self.class.attribute_map.each_pair do |attr, param|
178
+ value = self.send(attr)
179
+ if value.nil?
180
+ is_nullable = self.class.openapi_nullable.include?(attr)
181
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
182
+ end
183
+
184
+ hash[param] = _to_hash(value)
185
+ end
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to? :to_hash
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,242 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ApprovalApiClient
16
+ # Resource with tags
17
+ class TagResource
18
+ attr_accessor :app_name
19
+
20
+ attr_accessor :object_type
21
+
22
+ attr_accessor :tags
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'app_name' => :'app_name',
28
+ :'object_type' => :'object_type',
29
+ :'tags' => :'tags'
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'app_name' => :'String',
37
+ :'object_type' => :'String',
38
+ :'tags' => :'Array<Tag>'
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.openapi_nullable
44
+ Set.new([
45
+ ])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ApprovalApiClient::TagResource` initialize method"
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
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ApprovalApiClient::TagResource`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:'app_name')
64
+ self.app_name = attributes[:'app_name']
65
+ end
66
+
67
+ if attributes.key?(:'object_type')
68
+ self.object_type = attributes[:'object_type']
69
+ end
70
+
71
+ if attributes.key?(:'tags')
72
+ if (value = attributes[:'tags']).is_a?(Array)
73
+ self.tags = value
74
+ end
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 @app_name.nil?
83
+ invalid_properties.push('invalid value for "app_name", app_name cannot be nil.')
84
+ end
85
+
86
+ if @object_type.nil?
87
+ invalid_properties.push('invalid value for "object_type", object_type cannot be nil.')
88
+ end
89
+
90
+ if @tags.nil?
91
+ invalid_properties.push('invalid value for "tags", tags cannot be nil.')
92
+ end
93
+
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ return false if @app_name.nil?
101
+ return false if @object_type.nil?
102
+ return false if @tags.nil?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ app_name == o.app_name &&
112
+ object_type == o.object_type &&
113
+ tags == o.tags
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [app_name, object_type, tags].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ new.build_from_hash(attributes)
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ self.class.openapi_types.each_pair do |key, type|
141
+ if type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
146
+ end
147
+ elsif !attributes[self.class.attribute_map[key]].nil?
148
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
150
+ end
151
+
152
+ self
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def _deserialize(type, value)
160
+ case type.to_sym
161
+ when :DateTime
162
+ DateTime.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ ApprovalApiClient.const_get(type).build_from_hash(value)
193
+ end
194
+ end
195
+
196
+ # Returns the string representation of the object
197
+ # @return [String] String presentation of the object
198
+ def to_s
199
+ to_hash.to_s
200
+ end
201
+
202
+ # to_body is an alias to to_hash (backward compatibility)
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_body
205
+ to_hash
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = self.send(attr)
214
+ if value.nil?
215
+ is_nullable = self.class.openapi_nullable.include?(attr)
216
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
+ end
218
+
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ApprovalApiClient
16
+ # The template to categorize workflows.
17
+ class Template
18
+ attr_accessor :id
19
+
20
+ attr_accessor :title
21
+
22
+ attr_accessor :description
23
+
24
+ # JSON Metadata about the template
25
+ attr_accessor :metadata
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'id' => :'id',
31
+ :'title' => :'title',
32
+ :'description' => :'description',
33
+ :'metadata' => :'metadata'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'id' => :'String',
41
+ :'title' => :'String',
42
+ :'description' => :'String',
43
+ :'metadata' => :'Object'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ApprovalApiClient::Template` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ApprovalApiClient::Template`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'id')
69
+ self.id = attributes[:'id']
70
+ end
71
+
72
+ if attributes.key?(:'title')
73
+ self.title = attributes[:'title']
74
+ end
75
+
76
+ if attributes.key?(:'description')
77
+ self.description = attributes[:'description']
78
+ end
79
+
80
+ if attributes.key?(:'metadata')
81
+ self.metadata = attributes[:'metadata']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ id == o.id &&
104
+ title == o.title &&
105
+ description == o.description &&
106
+ metadata == o.metadata
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 [Integer] Hash code
117
+ def hash
118
+ [id, title, description, metadata].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 self.build_from_hash(attributes)
125
+ new.build_from_hash(attributes)
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ self.class.openapi_types.each_pair do |key, type|
134
+ if type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :DateTime
155
+ DateTime.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ ApprovalApiClient.const_get(type).build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+ end
235
+ end