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