quake_timesheets_client 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +74 -0
- data/README.md +27 -21
- data/build.sh +1 -1
- data/docs/ApprovalTypesApi.md +36 -38
- data/docs/ApprovalsApi.md +36 -40
- data/docs/CreateApprovalTypesInput.md +22 -0
- data/docs/CreateApprovalsInput.md +24 -0
- data/docs/CreateDatasetsInput.md +18 -0
- data/docs/CreateEntriesInput.md +30 -0
- data/docs/CreatePeopleInput.md +20 -0
- data/docs/DatasetsApi.md +51 -49
- data/docs/EntriesApi.md +52 -72
- data/docs/Entry.md +2 -0
- data/docs/PeopleApi.md +36 -36
- data/docs/UpdateEntriesInput.md +30 -0
- data/lib/quake_timesheets_client.rb +7 -1
- data/lib/quake_timesheets_client/api/approval_types_api.rb +33 -52
- data/lib/quake_timesheets_client/api/approvals_api.rb +34 -65
- data/lib/quake_timesheets_client/api/datasets_api.rb +45 -50
- data/lib/quake_timesheets_client/api/entries_api.rb +54 -94
- data/lib/quake_timesheets_client/api/people_api.rb +33 -45
- data/lib/quake_timesheets_client/api_client.rb +1 -1
- data/lib/quake_timesheets_client/api_error.rb +1 -1
- data/lib/quake_timesheets_client/configuration.rb +1 -1
- data/lib/quake_timesheets_client/models/approval.rb +1 -1
- data/lib/quake_timesheets_client/models/approval_type.rb +1 -1
- data/lib/quake_timesheets_client/models/create_approval_types_input.rb +254 -0
- data/lib/quake_timesheets_client/models/create_approvals_input.rb +304 -0
- data/lib/quake_timesheets_client/models/create_datasets_input.rb +224 -0
- data/lib/quake_timesheets_client/models/create_entries_input.rb +313 -0
- data/lib/quake_timesheets_client/models/create_people_input.rb +239 -0
- data/lib/quake_timesheets_client/models/dataset.rb +1 -1
- data/lib/quake_timesheets_client/models/entry.rb +19 -2
- data/lib/quake_timesheets_client/models/person.rb +1 -1
- data/lib/quake_timesheets_client/models/update_entries_input.rb +313 -0
- data/lib/quake_timesheets_client/version.rb +2 -2
- data/quake_timesheets_client.gemspec +1 -1
- data/ruby-templates/api.mustache +206 -0
- data/ruby.config.yaml +1 -1
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/create_approval_types_input_spec.rb +46 -0
- data/spec/models/create_approvals_input_spec.rb +56 -0
- data/spec/models/create_datasets_input_spec.rb +34 -0
- data/spec/models/create_entries_input_spec.rb +68 -0
- data/spec/models/create_people_input_spec.rb +40 -0
- data/spec/models/update_entries_input_spec.rb +68 -0
- data/spec/spec_helper.rb +1 -1
- metadata +34 -9
- data/commands +0 -13
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
#TimesheetsApi (params in:
|
2
|
+
#TimesheetsApi (params in:body)
|
3
3
|
|
4
4
|
# <p>Another API description</p>
|
5
5
|
|
@@ -37,6 +37,9 @@ module Quake::Timesheets
|
|
37
37
|
# Unique identifier of the activity this Entry relates to
|
38
38
|
attr_accessor :external_reference
|
39
39
|
|
40
|
+
# The Tags attached to this entry.
|
41
|
+
attr_accessor :tags
|
42
|
+
|
40
43
|
# Time at which the record was created
|
41
44
|
attr_accessor :created_at
|
42
45
|
|
@@ -76,6 +79,7 @@ module Quake::Timesheets
|
|
76
79
|
:'quantity' => :'quantity',
|
77
80
|
:'unit' => :'unit',
|
78
81
|
:'external_reference' => :'external_reference',
|
82
|
+
:'tags' => :'tags',
|
79
83
|
:'created_at' => :'created_at',
|
80
84
|
:'updated_at' => :'updated_at'
|
81
85
|
}
|
@@ -97,6 +101,7 @@ module Quake::Timesheets
|
|
97
101
|
:'quantity' => :'Float',
|
98
102
|
:'unit' => :'String',
|
99
103
|
:'external_reference' => :'String',
|
104
|
+
:'tags' => :'Array<String>',
|
100
105
|
:'created_at' => :'String',
|
101
106
|
:'updated_at' => :'String'
|
102
107
|
}
|
@@ -155,6 +160,12 @@ module Quake::Timesheets
|
|
155
160
|
self.external_reference = attributes[:'external_reference']
|
156
161
|
end
|
157
162
|
|
163
|
+
if attributes.key?(:'tags')
|
164
|
+
if (value = attributes[:'tags']).is_a?(Array)
|
165
|
+
self.tags = value
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
158
169
|
if attributes.key?(:'created_at')
|
159
170
|
self.created_at = attributes[:'created_at']
|
160
171
|
end
|
@@ -176,6 +187,10 @@ module Quake::Timesheets
|
|
176
187
|
invalid_properties.push('invalid value for "dataset_id", dataset_id cannot be nil.')
|
177
188
|
end
|
178
189
|
|
190
|
+
if @tags.nil?
|
191
|
+
invalid_properties.push('invalid value for "tags", tags cannot be nil.')
|
192
|
+
end
|
193
|
+
|
179
194
|
if @created_at.nil?
|
180
195
|
invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
|
181
196
|
end
|
@@ -194,6 +209,7 @@ module Quake::Timesheets
|
|
194
209
|
return false if @dataset_id.nil?
|
195
210
|
unit_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "other"])
|
196
211
|
return false unless unit_validator.valid?(@unit)
|
212
|
+
return false if @tags.nil?
|
197
213
|
return false if @created_at.nil?
|
198
214
|
return false if @updated_at.nil?
|
199
215
|
true
|
@@ -222,6 +238,7 @@ module Quake::Timesheets
|
|
222
238
|
quantity == o.quantity &&
|
223
239
|
unit == o.unit &&
|
224
240
|
external_reference == o.external_reference &&
|
241
|
+
tags == o.tags &&
|
225
242
|
created_at == o.created_at &&
|
226
243
|
updated_at == o.updated_at
|
227
244
|
end
|
@@ -235,7 +252,7 @@ module Quake::Timesheets
|
|
235
252
|
# Calculates hash code according to all attributes.
|
236
253
|
# @return [Integer] Hash code
|
237
254
|
def hash
|
238
|
-
[id, dataset_id, person_id, start_at, end_at, quantity, unit, external_reference, created_at, updated_at].hash
|
255
|
+
[id, dataset_id, person_id, start_at, end_at, quantity, unit, external_reference, tags, created_at, updated_at].hash
|
239
256
|
end
|
240
257
|
|
241
258
|
# Builds the object from hash
|
@@ -0,0 +1,313 @@
|
|
1
|
+
=begin
|
2
|
+
#TimesheetsApi (params in:body)
|
3
|
+
|
4
|
+
# <p>Another API description</p>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.1.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Quake::Timesheets
|
17
|
+
class UpdateEntriesInput
|
18
|
+
# ID of the person to which this entry pertains
|
19
|
+
attr_accessor :person_id
|
20
|
+
|
21
|
+
# Time period at which this entry starts
|
22
|
+
attr_accessor :start_at
|
23
|
+
|
24
|
+
# Time period at which this entry ends
|
25
|
+
attr_accessor :end_at
|
26
|
+
|
27
|
+
attr_accessor :quantity
|
28
|
+
|
29
|
+
attr_accessor :unit
|
30
|
+
|
31
|
+
# Unique identifier of the activity this Entry relates to
|
32
|
+
attr_accessor :external_reference
|
33
|
+
|
34
|
+
# The Tags attached to this entries. Can take an Array of UUIDs of existing Tags, or any String which will find or create a Tag with that value
|
35
|
+
attr_accessor :tags
|
36
|
+
|
37
|
+
class EnumAttributeValidator
|
38
|
+
attr_reader :datatype
|
39
|
+
attr_reader :allowable_values
|
40
|
+
|
41
|
+
def initialize(datatype, allowable_values)
|
42
|
+
@allowable_values = allowable_values.map do |value|
|
43
|
+
case datatype.to_s
|
44
|
+
when /Integer/i
|
45
|
+
value.to_i
|
46
|
+
when /Float/i
|
47
|
+
value.to_f
|
48
|
+
else
|
49
|
+
value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def valid?(value)
|
55
|
+
!value || allowable_values.include?(value)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
60
|
+
def self.attribute_map
|
61
|
+
{
|
62
|
+
:'person_id' => :'person_id',
|
63
|
+
:'start_at' => :'start_at',
|
64
|
+
:'end_at' => :'end_at',
|
65
|
+
:'quantity' => :'quantity',
|
66
|
+
:'unit' => :'unit',
|
67
|
+
:'external_reference' => :'external_reference',
|
68
|
+
:'tags' => :'tags'
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns all the JSON keys this model knows about
|
73
|
+
def self.acceptable_attributes
|
74
|
+
attribute_map.values
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute type mapping.
|
78
|
+
def self.openapi_types
|
79
|
+
{
|
80
|
+
:'person_id' => :'String',
|
81
|
+
:'start_at' => :'String',
|
82
|
+
:'end_at' => :'String',
|
83
|
+
:'quantity' => :'Float',
|
84
|
+
:'unit' => :'String',
|
85
|
+
:'external_reference' => :'String',
|
86
|
+
:'tags' => :'Array<String>'
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
# List of attributes with nullable: true
|
91
|
+
def self.openapi_nullable
|
92
|
+
Set.new([
|
93
|
+
])
|
94
|
+
end
|
95
|
+
|
96
|
+
# Initializes the object
|
97
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
98
|
+
def initialize(attributes = {})
|
99
|
+
if (!attributes.is_a?(Hash))
|
100
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Quake::Timesheets::UpdateEntriesInput` initialize method"
|
101
|
+
end
|
102
|
+
|
103
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
104
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
105
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
106
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Quake::Timesheets::UpdateEntriesInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
107
|
+
end
|
108
|
+
h[k.to_sym] = v
|
109
|
+
}
|
110
|
+
|
111
|
+
if attributes.key?(:'person_id')
|
112
|
+
self.person_id = attributes[:'person_id']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.key?(:'start_at')
|
116
|
+
self.start_at = attributes[:'start_at']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'end_at')
|
120
|
+
self.end_at = attributes[:'end_at']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'quantity')
|
124
|
+
self.quantity = attributes[:'quantity']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'unit')
|
128
|
+
self.unit = attributes[:'unit']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'external_reference')
|
132
|
+
self.external_reference = attributes[:'external_reference']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'tags')
|
136
|
+
if (value = attributes[:'tags']).is_a?(Array)
|
137
|
+
self.tags = value
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
143
|
+
# @return Array for valid properties with the reasons
|
144
|
+
def list_invalid_properties
|
145
|
+
invalid_properties = Array.new
|
146
|
+
invalid_properties
|
147
|
+
end
|
148
|
+
|
149
|
+
# Check to see if the all the properties in the model are valid
|
150
|
+
# @return true if the model is valid
|
151
|
+
def valid?
|
152
|
+
unit_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "other"])
|
153
|
+
return false unless unit_validator.valid?(@unit)
|
154
|
+
true
|
155
|
+
end
|
156
|
+
|
157
|
+
# Custom attribute writer method checking allowed values (enum).
|
158
|
+
# @param [Object] unit Object to be assigned
|
159
|
+
def unit=(unit)
|
160
|
+
validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "other"])
|
161
|
+
unless validator.valid?(unit)
|
162
|
+
fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
|
163
|
+
end
|
164
|
+
@unit = unit
|
165
|
+
end
|
166
|
+
|
167
|
+
# Checks equality by comparing each attribute.
|
168
|
+
# @param [Object] Object to be compared
|
169
|
+
def ==(o)
|
170
|
+
return true if self.equal?(o)
|
171
|
+
self.class == o.class &&
|
172
|
+
person_id == o.person_id &&
|
173
|
+
start_at == o.start_at &&
|
174
|
+
end_at == o.end_at &&
|
175
|
+
quantity == o.quantity &&
|
176
|
+
unit == o.unit &&
|
177
|
+
external_reference == o.external_reference &&
|
178
|
+
tags == o.tags
|
179
|
+
end
|
180
|
+
|
181
|
+
# @see the `==` method
|
182
|
+
# @param [Object] Object to be compared
|
183
|
+
def eql?(o)
|
184
|
+
self == o
|
185
|
+
end
|
186
|
+
|
187
|
+
# Calculates hash code according to all attributes.
|
188
|
+
# @return [Integer] Hash code
|
189
|
+
def hash
|
190
|
+
[person_id, start_at, end_at, quantity, unit, external_reference, tags].hash
|
191
|
+
end
|
192
|
+
|
193
|
+
# Builds the object from hash
|
194
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
195
|
+
# @return [Object] Returns the model itself
|
196
|
+
def self.build_from_hash(attributes)
|
197
|
+
new.build_from_hash(attributes)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Builds the object from hash
|
201
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
202
|
+
# @return [Object] Returns the model itself
|
203
|
+
def build_from_hash(attributes)
|
204
|
+
return nil unless attributes.is_a?(Hash)
|
205
|
+
self.class.openapi_types.each_pair do |key, type|
|
206
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
207
|
+
self.send("#{key}=", nil)
|
208
|
+
elsif type =~ /\AArray<(.*)>/i
|
209
|
+
# check to ensure the input is an array given that the attribute
|
210
|
+
# is documented as an array but the input is not
|
211
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
212
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
213
|
+
end
|
214
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
215
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
self
|
220
|
+
end
|
221
|
+
|
222
|
+
# Deserializes the data based on type
|
223
|
+
# @param string type Data type
|
224
|
+
# @param string value Value to be deserialized
|
225
|
+
# @return [Object] Deserialized data
|
226
|
+
def _deserialize(type, value)
|
227
|
+
case type.to_sym
|
228
|
+
when :Time
|
229
|
+
Time.parse(value)
|
230
|
+
when :Date
|
231
|
+
Date.parse(value)
|
232
|
+
when :String
|
233
|
+
value.to_s
|
234
|
+
when :Integer
|
235
|
+
value.to_i
|
236
|
+
when :Float
|
237
|
+
value.to_f
|
238
|
+
when :Boolean
|
239
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
240
|
+
true
|
241
|
+
else
|
242
|
+
false
|
243
|
+
end
|
244
|
+
when :Object
|
245
|
+
# generic object (usually a Hash), return directly
|
246
|
+
value
|
247
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
248
|
+
inner_type = Regexp.last_match[:inner_type]
|
249
|
+
value.map { |v| _deserialize(inner_type, v) }
|
250
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
251
|
+
k_type = Regexp.last_match[:k_type]
|
252
|
+
v_type = Regexp.last_match[:v_type]
|
253
|
+
{}.tap do |hash|
|
254
|
+
value.each do |k, v|
|
255
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
else # model
|
259
|
+
# models (e.g. Pet) or oneOf
|
260
|
+
klass = Quake::Timesheets.const_get(type)
|
261
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# Returns the string representation of the object
|
266
|
+
# @return [String] String presentation of the object
|
267
|
+
def to_s
|
268
|
+
to_hash.to_s
|
269
|
+
end
|
270
|
+
|
271
|
+
# to_body is an alias to to_hash (backward compatibility)
|
272
|
+
# @return [Hash] Returns the object in the form of hash
|
273
|
+
def to_body
|
274
|
+
to_hash
|
275
|
+
end
|
276
|
+
|
277
|
+
# Returns the object in the form of hash
|
278
|
+
# @return [Hash] Returns the object in the form of hash
|
279
|
+
def to_hash
|
280
|
+
hash = {}
|
281
|
+
self.class.attribute_map.each_pair do |attr, param|
|
282
|
+
value = self.send(attr)
|
283
|
+
if value.nil?
|
284
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
285
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
286
|
+
end
|
287
|
+
|
288
|
+
hash[param] = _to_hash(value)
|
289
|
+
end
|
290
|
+
hash
|
291
|
+
end
|
292
|
+
|
293
|
+
# Outputs non-array value in the form of hash
|
294
|
+
# For object, use to_hash. Otherwise, just return the value
|
295
|
+
# @param [Object] value Any valid value
|
296
|
+
# @return [Hash] Returns the value in the form of hash
|
297
|
+
def _to_hash(value)
|
298
|
+
if value.is_a?(Array)
|
299
|
+
value.compact.map { |v| _to_hash(v) }
|
300
|
+
elsif value.is_a?(Hash)
|
301
|
+
{}.tap do |hash|
|
302
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
303
|
+
end
|
304
|
+
elsif value.respond_to? :to_hash
|
305
|
+
value.to_hash
|
306
|
+
else
|
307
|
+
value
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
=begin
|
2
|
-
#TimesheetsApi (params in:
|
2
|
+
#TimesheetsApi (params in:body)
|
3
3
|
|
4
4
|
# <p>Another API description</p>
|
5
5
|
|
@@ -20,5 +20,5 @@ OpenAPI Generator version: 5.1.0
|
|
20
20
|
end
|
21
21
|
|
22
22
|
module Quake::Timesheets
|
23
|
-
VERSION = '0.1.
|
23
|
+
VERSION = '0.1.5'
|
24
24
|
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
=begin
|
2
|
+
{{> api_info}}
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
module {{moduleName}}
|
8
|
+
{{#operations}}
|
9
|
+
class {{classname}}
|
10
|
+
attr_accessor :api_client
|
11
|
+
|
12
|
+
def initialize(api_client = ApiClient.default)
|
13
|
+
@api_client = api_client
|
14
|
+
end
|
15
|
+
{{#operation}}
|
16
|
+
{{#summary}}
|
17
|
+
# {{{summary}}}
|
18
|
+
{{/summary}}
|
19
|
+
{{#notes}}
|
20
|
+
# {{{notes}}}
|
21
|
+
{{/notes}}
|
22
|
+
{{#allParams}}{{#required}} # @param {{paramName}} [{{{dataType}}}] {{description}}
|
23
|
+
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
24
|
+
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
25
|
+
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
26
|
+
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
27
|
+
{{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
|
28
|
+
{{#returnType}}data{{/returnType}}{{^returnType}}nil{{/returnType}}
|
29
|
+
end
|
30
|
+
|
31
|
+
{{#summary}}
|
32
|
+
# {{summary}}
|
33
|
+
{{/summary}}
|
34
|
+
{{#notes}}
|
35
|
+
# {{notes}}
|
36
|
+
{{/notes}}
|
37
|
+
{{#allParams}}{{#required}} # @param {{paramName}} [{{{dataType}}}] {{description}}
|
38
|
+
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
39
|
+
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
|
40
|
+
{{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Integer, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
|
41
|
+
def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
42
|
+
if @api_client.config.debugging
|
43
|
+
@api_client.config.logger.debug 'Calling API: {{classname}}.{{operationId}} ...'
|
44
|
+
end
|
45
|
+
{{#allParams}}
|
46
|
+
{{^isNullable}}
|
47
|
+
{{#required}}
|
48
|
+
# verify the required parameter '{{paramName}}' is set
|
49
|
+
if @api_client.config.client_side_validation && {{{paramName}}}.nil?
|
50
|
+
fail ArgumentError, "Missing the required parameter '{{paramName}}' when calling {{classname}}.{{operationId}}"
|
51
|
+
end
|
52
|
+
{{#isEnum}}
|
53
|
+
{{^isContainer}}
|
54
|
+
# verify enum value
|
55
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
56
|
+
if @api_client.config.client_side_validation && !allowable_values.include?({{{paramName}}})
|
57
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}"
|
58
|
+
end
|
59
|
+
{{/isContainer}}
|
60
|
+
{{/isEnum}}
|
61
|
+
{{/required}}
|
62
|
+
{{/isNullable}}
|
63
|
+
{{^required}}
|
64
|
+
{{#isEnum}}
|
65
|
+
{{#collectionFormat}}
|
66
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
67
|
+
if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !opts[:'{{{paramName}}}'].all? { |item| allowable_values.include?(item) }
|
68
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must include one of #{allowable_values}"
|
69
|
+
end
|
70
|
+
{{/collectionFormat}}
|
71
|
+
{{^collectionFormat}}
|
72
|
+
allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]
|
73
|
+
if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !allowable_values.include?(opts[:'{{{paramName}}}'])
|
74
|
+
fail ArgumentError, "invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}"
|
75
|
+
end
|
76
|
+
{{/collectionFormat}}
|
77
|
+
{{/isEnum}}
|
78
|
+
{{/required}}
|
79
|
+
{{#hasValidation}}
|
80
|
+
{{#maxLength}}
|
81
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length > {{{maxLength}}}
|
82
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be smaller than or equal to {{{maxLength}}}.'
|
83
|
+
end
|
84
|
+
|
85
|
+
{{/maxLength}}
|
86
|
+
{{#minLength}}
|
87
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.to_s.length < {{{minLength}}}
|
88
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, the character length must be great than or equal to {{{minLength}}}.'
|
89
|
+
end
|
90
|
+
|
91
|
+
{{/minLength}}
|
92
|
+
{{#maximum}}
|
93
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
|
94
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.'
|
95
|
+
end
|
96
|
+
|
97
|
+
{{/maximum}}
|
98
|
+
{{#minimum}}
|
99
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
|
100
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.'
|
101
|
+
end
|
102
|
+
|
103
|
+
{{/minimum}}
|
104
|
+
{{#pattern}}
|
105
|
+
pattern = Regexp.new({{{pattern}}})
|
106
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}} !~ pattern
|
107
|
+
fail ArgumentError, "invalid value for '{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:\"{{{paramName}}}\"]{{/required}}' when calling {{classname}}.{{operationId}}, must conform to the pattern #{pattern}."
|
108
|
+
end
|
109
|
+
|
110
|
+
{{/pattern}}
|
111
|
+
{{#maxItems}}
|
112
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.length > {{{maxItems}}}
|
113
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{{maxItems}}}.'
|
114
|
+
end
|
115
|
+
|
116
|
+
{{/maxItems}}
|
117
|
+
{{#minItems}}
|
118
|
+
if @api_client.config.client_side_validation && {{^required}}!opts[:'{{{paramName}}}'].nil? && {{/required}}{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}']{{/required}}.length < {{{minItems}}}
|
119
|
+
fail ArgumentError, 'invalid value for "{{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:"{{{paramName}}}"]{{/required}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{{minItems}}}.'
|
120
|
+
end
|
121
|
+
|
122
|
+
{{/minItems}}
|
123
|
+
{{/hasValidation}}
|
124
|
+
{{/allParams}}
|
125
|
+
# resource path
|
126
|
+
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s){{^strictSpecBehavior}}.gsub('%2F', '/'){{/strictSpecBehavior}}){{/pathParams}}
|
127
|
+
|
128
|
+
# query parameters
|
129
|
+
query_params = opts[:query_params] || {}
|
130
|
+
{{#queryParams}}
|
131
|
+
{{#required}}
|
132
|
+
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
133
|
+
{{/required}}
|
134
|
+
{{/queryParams}}
|
135
|
+
{{#queryParams}}
|
136
|
+
{{^required}}
|
137
|
+
query_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
138
|
+
{{/required}}
|
139
|
+
{{/queryParams}}
|
140
|
+
|
141
|
+
# header parameters
|
142
|
+
header_params = opts[:header_params] || {}
|
143
|
+
{{#hasProduces}}
|
144
|
+
# HTTP header 'Accept' (if needed)
|
145
|
+
header_params['Accept'] = @api_client.select_header_accept([{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}])
|
146
|
+
{{/hasProduces}}
|
147
|
+
{{#hasConsumes}}
|
148
|
+
# HTTP header 'Content-Type'
|
149
|
+
header_params['Content-Type'] = @api_client.select_header_content_type([{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}])
|
150
|
+
{{/hasConsumes}}
|
151
|
+
{{#headerParams}}
|
152
|
+
{{#required}}
|
153
|
+
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
154
|
+
{{/required}}
|
155
|
+
{{/headerParams}}
|
156
|
+
{{#headerParams}}
|
157
|
+
{{^required}}
|
158
|
+
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{{paramName}}}'].nil?
|
159
|
+
{{/required}}
|
160
|
+
{{/headerParams}}
|
161
|
+
|
162
|
+
# form parameters
|
163
|
+
form_params = opts[:form_params] || {}
|
164
|
+
{{#formParams}}
|
165
|
+
{{#required}}
|
166
|
+
form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
|
167
|
+
{{/required}}
|
168
|
+
{{/formParams}}
|
169
|
+
{{#formParams}}
|
170
|
+
{{^required}}
|
171
|
+
form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{paramName}}'].nil?
|
172
|
+
{{/required}}
|
173
|
+
{{/formParams}}
|
174
|
+
|
175
|
+
# http body (model)
|
176
|
+
post_body = opts[:debug_body]{{#bodyParam}} || @api_client.object_to_http_body({{#required}}{{{paramName}}}{{/required}}{{^required}}opts[:'{{{paramName}}}'] || opts[:body]{{/required}}){{/bodyParam}}
|
177
|
+
|
178
|
+
# return_type
|
179
|
+
return_type = opts[:debug_return_type]{{#returnType}} || '{{{returnType}}}'{{/returnType}}
|
180
|
+
|
181
|
+
# auth_names
|
182
|
+
auth_names = opts[:debug_auth_names] || [{{#authMethods}}'{{name}}'{{^-last}}, {{/-last}}{{/authMethods}}]
|
183
|
+
|
184
|
+
new_options = opts.merge(
|
185
|
+
:operation => :"{{classname}}.{{operationId}}",
|
186
|
+
:header_params => header_params,
|
187
|
+
:query_params => query_params,
|
188
|
+
:form_params => form_params,
|
189
|
+
:body => post_body,
|
190
|
+
:auth_names => auth_names,
|
191
|
+
:return_type => return_type
|
192
|
+
)
|
193
|
+
|
194
|
+
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, local_var_path, new_options)
|
195
|
+
if @api_client.config.debugging
|
196
|
+
@api_client.config.logger.debug "API called: {{classname}}#{{operationId}}\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
197
|
+
end
|
198
|
+
return data, status_code, headers
|
199
|
+
end
|
200
|
+
{{^-last}}
|
201
|
+
|
202
|
+
{{/-last}}
|
203
|
+
{{/operation}}
|
204
|
+
end
|
205
|
+
{{/operations}}
|
206
|
+
end
|