Class: Kickflow::RouteStep

Inherits:
Object
  • Object
show all
Defined in:
lib/kickflow/models/route_step.rb

Overview

経路ステップ

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ RouteStep

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/kickflow/models/route_step.rb', line 144

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Kickflow::RouteStep` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Kickflow::RouteStep`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'step_order')
    self.step_order = attributes[:'step_order']
  else
    self.step_order = nil
  end

  if attributes.key?(:'step_type')
    self.step_type = attributes[:'step_type']
  else
    self.step_type = nil
  end

  if attributes.key?(:'title')
    self.title = attributes[:'title']
  else
    self.title = nil
  end

  if attributes.key?(:'action_type')
    self.action_type = attributes[:'action_type']
  else
    self.action_type = nil
  end

  if attributes.key?(:'instruction')
    self.instruction = attributes[:'instruction']
  else
    self.instruction = nil
  end

  if attributes.key?(:'required_approvals_number')
    self.required_approvals_number = attributes[:'required_approvals_number']
  else
    self.required_approvals_number = nil
  end

  if attributes.key?(:'required_approvals_percent')
    self.required_approvals_percent = attributes[:'required_approvals_percent']
  else
    self.required_approvals_percent = nil
  end

  if attributes.key?(:'fallback_type')
    self.fallback_type = attributes[:'fallback_type']
  else
    self.fallback_type = nil
  end

  if attributes.key?(:'allow_self_approval')
    self.allow_self_approval = attributes[:'allow_self_approval']
  else
    self.allow_self_approval = nil
  end

  if attributes.key?(:'min_custom_assignees')
    self.min_custom_assignees = attributes[:'min_custom_assignees']
  else
    self.min_custom_assignees = nil
  end

  if attributes.key?(:'users')
    if (value = attributes[:'users']).is_a?(Array)
      self.users = value
    end
  else
    self.users = nil
  end

  if attributes.key?(:'targets')
    if (value = attributes[:'targets']).is_a?(Array)
      self.targets = value
    end
  end

  if attributes.key?(:'route_step_condition')
    self.route_step_condition = attributes[:'route_step_condition']
  end

  if attributes.key?(:'code')
    self.code = attributes[:'code']
  else
    self.code = nil
  end
end

Instance Attribute Details

#action_typeObject

アクションタイプ。承認/差し戻しの場合approve、回覧(確認あり)の場合confirm、回覧(確認なし)の場合noneになります。



32
33
34
# File 'lib/kickflow/models/route_step.rb', line 32

def action_type
  @action_type
end

#allow_self_approvalObject

自己承認を許可するか



47
48
49
# File 'lib/kickflow/models/route_step.rb', line 47

def allow_self_approval
  @allow_self_approval
end

#codeObject

コード



61
62
63
# File 'lib/kickflow/models/route_step.rb', line 61

def code
  @code
end

#fallback_typeObject

フォールバックのタイプ



44
45
46
# File 'lib/kickflow/models/route_step.rb', line 44

def fallback_type
  @fallback_type
end

#idObject

UUID



20
21
22
# File 'lib/kickflow/models/route_step.rb', line 20

def id
  @id
end

#instructionObject

承認者への指示



35
36
37
# File 'lib/kickflow/models/route_step.rb', line 35

def instruction
  @instruction
end

#min_custom_assigneesObject

最小指名人数。「申請者が指名」ステップのみ設定可能。



50
51
52
# File 'lib/kickflow/models/route_step.rb', line 50

def min_custom_assignees
  @min_custom_assignees
end

#required_approvals_numberObject

必要な承認人数



38
39
40
# File 'lib/kickflow/models/route_step.rb', line 38

def required_approvals_number
  @required_approvals_number
end

#required_approvals_percentObject

必要な承認割合(%)



41
42
43
# File 'lib/kickflow/models/route_step.rb', line 41

def required_approvals_percent
  @required_approvals_percent
end

#route_step_conditionObject

Returns the value of attribute route_step_condition.



58
59
60
# File 'lib/kickflow/models/route_step.rb', line 58

def route_step_condition
  @route_step_condition
end

#step_orderObject

ステップ順序(1から始まります)



23
24
25
# File 'lib/kickflow/models/route_step.rb', line 23

def step_order
  @step_order
end

#step_typeObject

ステップのタイプ



26
27
28
# File 'lib/kickflow/models/route_step.rb', line 26

def step_type
  @step_type
end

#targetsObject

承認者の指定に使うチームと役職の条件



56
57
58
# File 'lib/kickflow/models/route_step.rb', line 56

def targets
  @targets
end

#titleObject

タイトル



29
30
31
# File 'lib/kickflow/models/route_step.rb', line 29

def title
  @title
end

#usersObject

承認者の指定に使うユーザーの配列



53
54
55
# File 'lib/kickflow/models/route_step.rb', line 53

def users
  @users
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/kickflow/models/route_step.rb', line 425

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Kickflow.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



107
108
109
# File 'lib/kickflow/models/route_step.rb', line 107

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/kickflow/models/route_step.rb', line 86

def self.attribute_map
  {
    :'id' => :'id',
    :'step_order' => :'stepOrder',
    :'step_type' => :'stepType',
    :'title' => :'title',
    :'action_type' => :'actionType',
    :'instruction' => :'instruction',
    :'required_approvals_number' => :'requiredApprovalsNumber',
    :'required_approvals_percent' => :'requiredApprovalsPercent',
    :'fallback_type' => :'fallbackType',
    :'allow_self_approval' => :'allowSelfApproval',
    :'min_custom_assignees' => :'minCustomAssignees',
    :'users' => :'users',
    :'targets' => :'targets',
    :'route_step_condition' => :'routeStepCondition',
    :'code' => :'code'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/kickflow/models/route_step.rb', line 401

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



133
134
135
136
137
138
139
140
# File 'lib/kickflow/models/route_step.rb', line 133

def self.openapi_nullable
  Set.new([
    :'instruction',
    :'fallback_type',
    :'min_custom_assignees',
    :'route_step_condition',
  ])
end

.openapi_typesObject

Attribute type mapping.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/kickflow/models/route_step.rb', line 112

def self.openapi_types
  {
    :'id' => :'String',
    :'step_order' => :'Integer',
    :'step_type' => :'String',
    :'title' => :'String',
    :'action_type' => :'String',
    :'instruction' => :'String',
    :'required_approvals_number' => :'Integer',
    :'required_approvals_percent' => :'Integer',
    :'fallback_type' => :'String',
    :'allow_self_approval' => :'Boolean',
    :'min_custom_assignees' => :'Integer',
    :'users' => :'Array<User>',
    :'targets' => :'Array<RouteStepTarget>',
    :'route_step_condition' => :'RouteStepCondition',
    :'code' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/kickflow/models/route_step.rb', line 366

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      step_order == o.step_order &&
      step_type == o.step_type &&
      title == o.title &&
      action_type == o.action_type &&
      instruction == o.instruction &&
      required_approvals_number == o.required_approvals_number &&
      required_approvals_percent == o.required_approvals_percent &&
      fallback_type == o.fallback_type &&
      allow_self_approval == o.allow_self_approval &&
      min_custom_assignees == o.min_custom_assignees &&
      users == o.users &&
      targets == o.targets &&
      route_step_condition == o.route_step_condition &&
      code == o.code
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/kickflow/models/route_step.rb', line 496

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


388
389
390
# File 'lib/kickflow/models/route_step.rb', line 388

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



394
395
396
# File 'lib/kickflow/models/route_step.rb', line 394

def hash
  [id, step_order, step_type, title, action_type, instruction, required_approvals_number, required_approvals_percent, fallback_type, allow_self_approval, min_custom_assignees, users, targets, route_step_condition, code].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/kickflow/models/route_step.rb', line 250

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @step_order.nil?
    invalid_properties.push('invalid value for "step_order", step_order cannot be nil.')
  end

  if @step_type.nil?
    invalid_properties.push('invalid value for "step_type", step_type cannot be nil.')
  end

  if @title.nil?
    invalid_properties.push('invalid value for "title", title cannot be nil.')
  end

  if @action_type.nil?
    invalid_properties.push('invalid value for "action_type", action_type cannot be nil.')
  end

  if @required_approvals_number.nil?
    invalid_properties.push('invalid value for "required_approvals_number", required_approvals_number cannot be nil.')
  end

  if @required_approvals_percent.nil?
    invalid_properties.push('invalid value for "required_approvals_percent", required_approvals_percent cannot be nil.')
  end

  if @allow_self_approval.nil?
    invalid_properties.push('invalid value for "allow_self_approval", allow_self_approval cannot be nil.')
  end

  if @min_custom_assignees < 0
    invalid_properties.push('invalid value for "min_custom_assignees", must be greater than or equal to 0.')
  end

  if @users.nil?
    invalid_properties.push('invalid value for "users", users cannot be nil.')
  end

  if @code.nil?
    invalid_properties.push('invalid value for "code", code cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



472
473
474
# File 'lib/kickflow/models/route_step.rb', line 472

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/kickflow/models/route_step.rb', line 478

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



466
467
468
# File 'lib/kickflow/models/route_step.rb', line 466

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/kickflow/models/route_step.rb', line 302

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @step_order.nil?
  return false if @step_type.nil?
  step_type_validator = EnumAttributeValidator.new('String', ["author", "manager", "team", "user", "author_customizable", "assignee_customizable"])
  return false unless step_type_validator.valid?(@step_type)
  return false if @title.nil?
  return false if @action_type.nil?
  action_type_validator = EnumAttributeValidator.new('String', ["approve", "confirm", "none"])
  return false unless action_type_validator.valid?(@action_type)
  return false if @required_approvals_number.nil?
  return false if @required_approvals_percent.nil?
  fallback_type_validator = EnumAttributeValidator.new('String', ["direct_manager", "higher_manager", "skip"])
  return false unless fallback_type_validator.valid?(@fallback_type)
  return false if @allow_self_approval.nil?
  return false if @min_custom_assignees < 0
  return false if @users.nil?
  return false if @code.nil?
  true
end