Class: ConnectWise::WorkType
- Inherits:
-
Object
- Object
- ConnectWise::WorkType
- Defined in:
- lib/connect_wise/models/work_type.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#_info ⇒ Object
Returns the value of attribute _info.
-
#accrual_type ⇒ Object
Returns the value of attribute accrual_type.
-
#activity_default_flag ⇒ Object
Returns the value of attribute activity_default_flag.
-
#add_all_agreement_exclusions ⇒ Object
Used only on create to add the work type to all agreement and agreement type exclusion lists.
-
#bill_time ⇒ Object
Returns the value of attribute bill_time.
-
#cost_multiplier ⇒ Object
Returns the value of attribute cost_multiplier.
-
#hours_max ⇒ Object
Returns the value of attribute hours_max.
-
#hours_min ⇒ Object
Returns the value of attribute hours_min.
-
#id ⇒ Object
Returns the value of attribute id.
-
#inactive_flag ⇒ Object
Returns the value of attribute inactive_flag.
-
#integration_x_ref ⇒ Object
Max length: 50;.
-
#name ⇒ Object
Max length: 50;.
-
#overall_default_flag ⇒ Object
Returns the value of attribute overall_default_flag.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#rate_type ⇒ Object
Returns the value of attribute rate_type.
-
#round_bill_hours_to ⇒ Object
Returns the value of attribute round_bill_hours_to.
-
#utilization_flag ⇒ Object
Returns the value of attribute utilization_flag.
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ WorkType
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ WorkType
Initializes the object
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 163 164 165 166 |
# File 'lib/connect_wise/models/work_type.rb', line 120 def initialize(attributes = {}) raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::WorkType` initialize method' unless attributes.is_a?(Hash) # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) do |(k, v), h| raise ArgumentError, "`#{k}` is not a valid attribute in `ConnectWise::WorkType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym) h[k.to_sym] = v end self.name = attributes[:name] if attributes.key?(:name) self.bill_time = attributes[:bill_time] if attributes.key?(:bill_time) self.rate_type = attributes[:rate_type] if attributes.key?(:rate_type) self.rate = attributes[:rate] if attributes.key?(:rate) self.id = attributes[:id] if attributes.key?(:id) self.hours_min = attributes[:hours_min] if attributes.key?(:hours_min) self.hours_max = attributes[:hours_max] if attributes.key?(:hours_max) self.round_bill_hours_to = attributes[:round_bill_hours_to] if attributes.key?(:round_bill_hours_to) self.accrual_type = attributes[:accrual_type] if attributes.key?(:accrual_type) self.inactive_flag = attributes[:inactive_flag] if attributes.key?(:inactive_flag) self.overall_default_flag = attributes[:overall_default_flag] if attributes.key?(:overall_default_flag) self.activity_default_flag = attributes[:activity_default_flag] if attributes.key?(:activity_default_flag) self.utilization_flag = attributes[:utilization_flag] if attributes.key?(:utilization_flag) self.cost_multiplier = attributes[:cost_multiplier] if attributes.key?(:cost_multiplier) self.integration_x_ref = attributes[:integration_x_ref] if attributes.key?(:integration_x_ref) self.add_all_agreement_exclusions = attributes[:add_all_agreement_exclusions] if attributes.key?(:add_all_agreement_exclusions) return unless attributes.key?(:_info) return unless (value = attributes[:_info]).is_a?(Hash) self._info = value end |
Instance Attribute Details
#_info ⇒ Object
Returns the value of attribute _info.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def _info @_info end |
#accrual_type ⇒ Object
Returns the value of attribute accrual_type.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def accrual_type @accrual_type end |
#activity_default_flag ⇒ Object
Returns the value of attribute activity_default_flag.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def activity_default_flag @activity_default_flag end |
#add_all_agreement_exclusions ⇒ Object
Used only on create to add the work type to all agreement and agreement type exclusion lists
25 26 27 |
# File 'lib/connect_wise/models/work_type.rb', line 25 def add_all_agreement_exclusions @add_all_agreement_exclusions end |
#bill_time ⇒ Object
Returns the value of attribute bill_time.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def bill_time @bill_time end |
#cost_multiplier ⇒ Object
Returns the value of attribute cost_multiplier.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def cost_multiplier @cost_multiplier end |
#hours_max ⇒ Object
Returns the value of attribute hours_max.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def hours_max @hours_max end |
#hours_min ⇒ Object
Returns the value of attribute hours_min.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def hours_min @hours_min end |
#id ⇒ Object
Returns the value of attribute id.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def id @id end |
#inactive_flag ⇒ Object
Returns the value of attribute inactive_flag.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def inactive_flag @inactive_flag end |
#integration_x_ref ⇒ Object
Max length: 50;
22 23 24 |
# File 'lib/connect_wise/models/work_type.rb', line 22 def integration_x_ref @integration_x_ref end |
#name ⇒ Object
Max length: 50;
17 18 19 |
# File 'lib/connect_wise/models/work_type.rb', line 17 def name @name end |
#overall_default_flag ⇒ Object
Returns the value of attribute overall_default_flag.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def overall_default_flag @overall_default_flag end |
#rate ⇒ Object
Returns the value of attribute rate.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def rate @rate end |
#rate_type ⇒ Object
Returns the value of attribute rate_type.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def rate_type @rate_type end |
#round_bill_hours_to ⇒ Object
Returns the value of attribute round_bill_hours_to.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def round_bill_hours_to @round_bill_hours_to end |
#utilization_flag ⇒ Object
Returns the value of attribute utilization_flag.
19 20 21 |
# File 'lib/connect_wise/models/work_type.rb', line 19 def utilization_flag @utilization_flag end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
72 73 74 |
# File 'lib/connect_wise/models/work_type.rb', line 72 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/connect_wise/models/work_type.rb', line 49 def self.attribute_map { name: :name, bill_time: :billTime, rate_type: :rateType, rate: :rate, id: :id, hours_min: :hoursMin, hours_max: :hoursMax, round_bill_hours_to: :roundBillHoursTo, accrual_type: :accrualType, inactive_flag: :inactiveFlag, overall_default_flag: :overallDefaultFlag, activity_default_flag: :activityDefaultFlag, utilization_flag: :utilizationFlag, cost_multiplier: :costMultiplier, integration_x_ref: :integrationXRef, add_all_agreement_exclusions: :addAllAgreementExclusions, _info: :_info } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
261 262 263 |
# File 'lib/connect_wise/models/work_type.rb', line 261 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/connect_wise/models/work_type.rb', line 100 def self.openapi_nullable Set.new(i[ bill_time rate_type rate hours_min hours_max round_bill_hours_to accrual_type inactive_flag overall_default_flag activity_default_flag utilization_flag cost_multiplier add_all_agreement_exclusions ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/connect_wise/models/work_type.rb', line 77 def self.openapi_types { name: :String, bill_time: :String, rate_type: :String, rate: :Float, id: :Integer, hours_min: :Float, hours_max: :Float, round_bill_hours_to: :Float, accrual_type: :String, inactive_flag: :Boolean, overall_default_flag: :Boolean, activity_default_flag: :Boolean, utilization_flag: :Boolean, cost_multiplier: :Float, integration_x_ref: :String, add_all_agreement_exclusions: :Boolean, _info: :'Hash<String, String>' } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/connect_wise/models/work_type.rb', line 223 def ==(other) return true if equal?(other) self.class == other.class && name == other.name && bill_time == other.bill_time && rate_type == other.rate_type && rate == other.rate && id == other.id && hours_min == other.hours_min && hours_max == other.hours_max && round_bill_hours_to == other.round_bill_hours_to && accrual_type == other.accrual_type && inactive_flag == other.inactive_flag && overall_default_flag == other.overall_default_flag && activity_default_flag == other.activity_default_flag && utilization_flag == other.utilization_flag && cost_multiplier == other.cost_multiplier && integration_x_ref == other.integration_x_ref && add_all_agreement_exclusions == other.add_all_agreement_exclusions && _info == other._info end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
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 322 323 324 325 326 327 328 |
# File 'lib/connect_wise/models/work_type.rb', line 291 def _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 = ConnectWise.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/connect_wise/models/work_type.rb', line 362 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
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/connect_wise/models/work_type.rb', line 268 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) send("#{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 send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }) if attributes[self.class.attribute_map[key]].is_a?(Array) elsif !attributes[self.class.attribute_map[key]].nil? send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(other) ⇒ Boolean
248 249 250 |
# File 'lib/connect_wise/models/work_type.rb', line 248 def eql?(other) self == other end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
254 255 256 |
# File 'lib/connect_wise/models/work_type.rb', line 254 def hash [name, bill_time, rate_type, rate, id, hours_min, hours_max, round_bill_hours_to, accrual_type, inactive_flag, overall_default_flag, activity_default_flag, utilization_flag, cost_multiplier, integration_x_ref, add_all_agreement_exclusions, _info].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
170 171 172 173 174 175 |
# File 'lib/connect_wise/models/work_type.rb', line 170 def list_invalid_properties invalid_properties = [] invalid_properties.push('invalid value for "name", name cannot be nil.') if @name.nil? invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
338 339 340 |
# File 'lib/connect_wise/models/work_type.rb', line 338 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/connect_wise/models/work_type.rb', line 344 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = 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_s ⇒ String
Returns the string representation of the object
332 333 334 |
# File 'lib/connect_wise/models/work_type.rb', line 332 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/connect_wise/models/work_type.rb', line 179 def valid? return false if @name.nil? bill_time_validator = EnumAttributeValidator.new('String', %w[Billable DoNotBill NoCharge]) return false unless bill_time_validator.valid?(@bill_time) rate_type_validator = EnumAttributeValidator.new('String', %w[AdjAmount Custom Multiplier]) return false unless rate_type_validator.valid?(@rate_type) accrual_type_validator = EnumAttributeValidator.new('String', %w[Holiday PTO Sick Vacation]) return false unless accrual_type_validator.valid?(@accrual_type) true end |