Class: ConnectWise::AgreementTypeWorkType

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AgreementTypeWorkType

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 100

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?(:'type')
    self.type = attributes[:'type']
  end

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

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

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

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

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

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

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

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

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

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

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

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

end

Instance Attribute Details

#_infoObject

Metadata of the entity



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

def _info
  @_info
end

#bill_timeObject

Returns the value of attribute bill_time.



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

def bill_time
  @bill_time
end

#effective_dateObject

Returns the value of attribute effective_date.



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

def effective_date
  @effective_date
end

#ending_dateObject

Returns the value of attribute ending_date.



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

def ending_date
  @ending_date
end

#hours_maxObject

Returns the value of attribute hours_max.



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

def hours_max
  @hours_max
end

#hours_minObject

Returns the value of attribute hours_min.



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

def hours_min
  @hours_min
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#overage_rateObject

Returns the value of attribute overage_rate.



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

def overage_rate
  @overage_rate
end

#overage_rate_typeObject

Returns the value of attribute overage_rate_type.



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

def overage_rate_type
  @overage_rate_type
end

#rateObject

Returns the value of attribute rate.



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

def rate
  @rate
end

#rate_typeObject

Returns the value of attribute rate_type.



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

def rate_type
  @rate_type
end

#round_bill_hoursObject

Returns the value of attribute round_bill_hours.



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

def round_bill_hours
  @round_bill_hours
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#work_typeObject

Returns the value of attribute work_type.



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

def work_type
  @work_type
end

Class Method Details

.attribute_mapObject

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



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

def self.attribute_map
  {
    :'id' => :'id',
    :'type' => :'type',
    :'work_type' => :'workType',
    :'effective_date' => :'effectiveDate',
    :'ending_date' => :'endingDate',
    :'rate' => :'rate',
    :'rate_type' => :'rateType',
    :'bill_time' => :'billTime',
    :'hours_min' => :'hoursMin',
    :'hours_max' => :'hoursMax',
    :'round_bill_hours' => :'roundBillHours',
    :'overage_rate' => :'overageRate',
    :'overage_rate_type' => :'overageRateType',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



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

def self.swagger_types
  {
    :'id' => :'Integer',
    :'type' => :'AgreementTypeReference',
    :'work_type' => :'WorkTypeReference',
    :'effective_date' => :'DateTime',
    :'ending_date' => :'DateTime',
    :'rate' => :'Float',
    :'rate_type' => :'String',
    :'bill_time' => :'String',
    :'hours_min' => :'Float',
    :'hours_max' => :'Float',
    :'round_bill_hours' => :'Float',
    :'overage_rate' => :'Float',
    :'overage_rate_type' => :'String',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 230

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      type == o.type &&
      work_type == o.work_type &&
      effective_date == o.effective_date &&
      ending_date == o.ending_date &&
      rate == o.rate &&
      rate_type == o.rate_type &&
      bill_time == o.bill_time &&
      hours_min == o.hours_min &&
      hours_max == o.hours_max &&
      round_bill_hours == o.round_bill_hours &&
      overage_rate == o.overage_rate &&
      overage_rate_type == o.overage_rate_type &&
      _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



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
317
318
319
320
321
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 285

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



351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 351

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



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 264

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


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

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



257
258
259
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 257

def hash
  [id, type, work_type, effective_date, ending_date, rate, rate_type, bill_time, hours_min, hours_max, round_bill_hours, overage_rate, overage_rate_type, _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



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 166

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

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

  if @overage_rate_type.nil?
    invalid_properties.push("invalid value for 'overage_rate_type', overage_rate_type cannot be nil.")
  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



331
332
333
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 331

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



337
338
339
340
341
342
343
344
345
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 337

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



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

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



185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/connectwise-ruby-sdk/models/agreement_type_work_type.rb', line 185

def valid?
  return false if @rate_type.nil?
  rate_type_validator = EnumAttributeValidator.new('String', ["AdjAmount", "Custom", "Multiplier"])
  return false unless rate_type_validator.valid?(@rate_type)
  return false if @bill_time.nil?
  bill_time_validator = EnumAttributeValidator.new('String', ["Billable", "DoNotBill", "NoCharge", "NoDefault"])
  return false unless bill_time_validator.valid?(@bill_time)
  return false if @overage_rate_type.nil?
  overage_rate_type_validator = EnumAttributeValidator.new('String', ["AdjAmount", "Custom", "Multiplier"])
  return false unless overage_rate_type_validator.valid?(@overage_rate_type)
  return true
end