Class: ConnectWise::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/connectwise-ruby-sdk/models/workflow.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Workflow

Initializes the object

Parameters:

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

    Model attributes in the form of hash



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 97

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'tableType')
    self.table_type = attributes[:'tableType']
  end

  if attributes.has_key?(:'location')
    self.location = attributes[:'location']
  end

  if attributes.has_key?(:'department')
    self.department = attributes[:'department']
  end

  if attributes.has_key?(:'activateFlag')
    self.activate_flag = attributes[:'activateFlag']
  end

  if attributes.has_key?(:'batchInterval')
    self.batch_interval = attributes[:'batchInterval']
  end

  if attributes.has_key?(:'batchFrequencyUnit')
    self.batch_frequency_unit = attributes[:'batchFrequencyUnit']
  end

  if attributes.has_key?(:'batchLastRan')
    self.batch_last_ran = attributes[:'batchLastRan']
  end

  if attributes.has_key?(:'batchSchedule')
    self.batch_schedule = attributes[:'batchSchedule']
  end

  if attributes.has_key?(:'board')
    self.board = attributes[:'board']
  end

  if attributes.has_key?(:'_info')
    self._info = attributes[:'_info']
  end

end

Instance Attribute Details

#_infoObject

Metadata of the entity



35
36
37
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 35

def _info
  @_info
end

#activate_flagObject

Batches can not be turned on until after the workflow is created and it has atleast one event associated with it



20
21
22
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 20

def activate_flag
  @activate_flag
end

#batch_frequency_unitObject

If not specified, defaults to Minutes. Months is not supported as month length varies



25
26
27
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 25

def batch_frequency_unit
  @batch_frequency_unit
end

#batch_intervalObject

Returns the value of attribute batch_interval.



22
23
24
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 22

def batch_interval
  @batch_interval
end

#batch_last_ranObject

Returns the value of attribute batch_last_ran.



27
28
29
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 27

def batch_last_ran
  @batch_last_ran
end

#batch_scheduleObject

If activateFlag is true, batchSchedule is required



30
31
32
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 30

def batch_schedule
  @batch_schedule
end

#boardObject

Returns the value of attribute board.



32
33
34
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 32

def board
  @board
end

#departmentObject

Must belong to the specified location



17
18
19
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 17

def department
  @department
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 7

def id
  @id
end

#locationObject

If a department is set, a location that contains it must be set



14
15
16
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 14

def location
  @location
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 9

def name
  @name
end

#table_typeObject

Returns the value of attribute table_type.



11
12
13
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 11

def table_type
  @table_type
end

Class Method Details

.attribute_mapObject

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 60

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'table_type' => :'tableType',
    :'location' => :'location',
    :'department' => :'department',
    :'activate_flag' => :'activateFlag',
    :'batch_interval' => :'batchInterval',
    :'batch_frequency_unit' => :'batchFrequencyUnit',
    :'batch_last_ran' => :'batchLastRan',
    :'batch_schedule' => :'batchSchedule',
    :'board' => :'board',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 78

def self.swagger_types
  {
    :'id' => :'Integer',
    :'name' => :'String',
    :'table_type' => :'WorkflowTableTypeReference',
    :'location' => :'SystemLocationReference',
    :'department' => :'SystemDepartmentReference',
    :'activate_flag' => :'BOOLEAN',
    :'batch_interval' => :'Integer',
    :'batch_frequency_unit' => :'String',
    :'batch_last_ran' => :'DateTime',
    :'batch_schedule' => :'String',
    :'board' => :'BoardReference',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 227

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      table_type == o.table_type &&
      location == o.location &&
      department == o.department &&
      activate_flag == o.activate_flag &&
      batch_interval == o.batch_interval &&
      batch_frequency_unit == o.batch_frequency_unit &&
      batch_last_ran == o.batch_last_ran &&
      batch_schedule == o.batch_schedule &&
      board == o.board &&
      _info == o._info
end

#_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



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 280

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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
    temp_model = ConnectWise.const_get(type).new
    temp_model.build_from_hash(value)
  end
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



346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 346

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

#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



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 259

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


246
247
248
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 246

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



252
253
254
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 252

def hash
  [id, name, table_type, location, department, activate_flag, batch_interval, batch_frequency_unit, batch_last_ran, batch_schedule, board, _info].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 155

def list_invalid_properties
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push("invalid value for 'name', name cannot be nil.")
  end

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

  if !@batch_interval.nil? && @batch_interval > 2147483647
    invalid_properties.push("invalid value for 'batch_interval', must be smaller than or equal to 2147483647.")
  end

  if !@batch_interval.nil? && @batch_interval < 0
    invalid_properties.push("invalid value for 'batch_interval', must be greater than or equal to 0.")
  end

  return 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



326
327
328
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 326

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



332
333
334
335
336
337
338
339
340
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 332

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



320
321
322
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 320

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



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/connectwise-ruby-sdk/models/workflow.rb', line 178

def valid?
  return false if @name.nil?
  return false if @table_type.nil?
  return false if !@batch_interval.nil? && @batch_interval > 2147483647
  return false if !@batch_interval.nil? && @batch_interval < 0
  batch_frequency_unit_validator = EnumAttributeValidator.new('String', ["Minutes", "Hours", "Days"])
  return false unless batch_frequency_unit_validator.valid?(@batch_frequency_unit)
  batch_schedule_validator = EnumAttributeValidator.new('String', ["AnyTime", "MyCompanyOfficeHours", "SlaHours"])
  return false unless batch_schedule_validator.valid?(@batch_schedule)
  return true
end