Class: ConnectWise::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/connect_wise/models/service.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Service

Initializes the object

Parameters:

  • (defaults to: {})

    Model attributes in the form of hash

Raises:



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
# File 'lib/connect_wise/models/service.rb', line 116

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::Service` 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::Service`. 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.sr_notify = attributes[:sr_notify] if attributes.key?(:sr_notify)

  self.schedule_span = attributes[:schedule_span] if attributes.key?(:schedule_span)

  self.id = attributes[:id] if attributes.key?(:id)

  self.hide_delimiter_flag = attributes[:hide_delimiter_flag] if attributes.key?(:hide_delimiter_flag)

  self.allow_cc_flag = attributes[:allow_cc_flag] if attributes.key?(:allow_cc_flag)

  self.allow_to_flag = attributes[:allow_to_flag] if attributes.key?(:allow_to_flag)

  self.header_color = attributes[:header_color] if attributes.key?(:header_color)

  self.member_color = attributes[:member_color] if attributes.key?(:member_color)

  self.contact_color = attributes[:contact_color] if attributes.key?(:contact_color)

  self.unknown_color = attributes[:unknown_color] if attributes.key?(:unknown_color)

  self.calendar_setup = attributes[:calendar_setup] if attributes.key?(:calendar_setup)

  self.header_color_disable_flag = attributes[:header_color_disable_flag] if attributes.key?(:header_color_disable_flag)

  self.member_color_disable_flag = attributes[:member_color_disable_flag] if attributes.key?(:member_color_disable_flag)

  self.contact_color_disable_flag = attributes[:contact_color_disable_flag] if attributes.key?(:contact_color_disable_flag)

  self.unknown_color_disable_flag = attributes[:unknown_color_disable_flag] if attributes.key?(:unknown_color_disable_flag)

  return unless attributes.key?(:_info)
  return unless (value = attributes[:_info]).is_a?(Hash)

  self._info = value
end

Instance Attribute Details

#_infoObject

Returns the value of attribute _info.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def _info
  @_info
end

#allow_cc_flagObject

Returns the value of attribute allow_cc_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def allow_cc_flag
  @allow_cc_flag
end

#allow_to_flagObject

Returns the value of attribute allow_to_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def allow_to_flag
  @allow_to_flag
end

#calendar_setupObject

Returns the value of attribute calendar_setup.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def calendar_setup
  @calendar_setup
end

#contact_colorObject

Max length: 50;



25
26
27
# File 'lib/connect_wise/models/service.rb', line 25

def contact_color
  @contact_color
end

#contact_color_disable_flagObject

Returns the value of attribute contact_color_disable_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def contact_color_disable_flag
  @contact_color_disable_flag
end

#header_colorObject

Max length: 50;



19
20
21
# File 'lib/connect_wise/models/service.rb', line 19

def header_color
  @header_color
end

#header_color_disable_flagObject

Returns the value of attribute header_color_disable_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def header_color_disable_flag
  @header_color_disable_flag
end

#hide_delimiter_flagObject

Returns the value of attribute hide_delimiter_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def hide_delimiter_flag
  @hide_delimiter_flag
end

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def id
  @id
end

#member_colorObject

Max length: 50;



22
23
24
# File 'lib/connect_wise/models/service.rb', line 22

def member_color
  @member_color
end

#member_color_disable_flagObject

Returns the value of attribute member_color_disable_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def member_color_disable_flag
  @member_color_disable_flag
end

#schedule_spanObject

Returns the value of attribute schedule_span.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def schedule_span
  @schedule_span
end

#sr_notifyObject

Returns the value of attribute sr_notify.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def sr_notify
  @sr_notify
end

#unknown_colorObject

Max length: 50;



28
29
30
# File 'lib/connect_wise/models/service.rb', line 28

def unknown_color
  @unknown_color
end

#unknown_color_disable_flagObject

Returns the value of attribute unknown_color_disable_flag.



16
17
18
# File 'lib/connect_wise/models/service.rb', line 16

def unknown_color_disable_flag
  @unknown_color_disable_flag
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



74
75
76
# File 'lib/connect_wise/models/service.rb', line 74

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/connect_wise/models/service.rb', line 52

def self.attribute_map
  {
    sr_notify: :srNotify,
    schedule_span: :scheduleSpan,
    id: :id,
    hide_delimiter_flag: :hideDelimiterFlag,
    allow_cc_flag: :allowCCFlag,
    allow_to_flag: :allowTOFlag,
    header_color: :headerColor,
    member_color: :memberColor,
    contact_color: :contactColor,
    unknown_color: :unknownColor,
    calendar_setup: :calendarSetup,
    header_color_disable_flag: :headerColorDisableFlag,
    member_color_disable_flag: :memberColorDisableFlag,
    contact_color_disable_flag: :contactColorDisableFlag,
    unknown_color_disable_flag: :unknownColorDisableFlag,
    _info: :_info
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • Model attributes in the form of hash

Returns:

  • Returns the model itself



241
242
243
# File 'lib/connect_wise/models/service.rb', line 241

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/connect_wise/models/service.rb', line 101

def self.openapi_nullable
  Set.new(i[
            sr_notify
            hide_delimiter_flag
            allow_cc_flag
            allow_to_flag
            header_color_disable_flag
            member_color_disable_flag
            contact_color_disable_flag
            unknown_color_disable_flag
          ])
end

.openapi_typesObject

Attribute type mapping.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/connect_wise/models/service.rb', line 79

def self.openapi_types
  {
    sr_notify: :String,
    schedule_span: :String,
    id: :Integer,
    hide_delimiter_flag: :Boolean,
    allow_cc_flag: :Boolean,
    allow_to_flag: :Boolean,
    header_color: :String,
    member_color: :String,
    contact_color: :String,
    unknown_color: :String,
    calendar_setup: :CalendarSetupReference,
    header_color_disable_flag: :Boolean,
    member_color_disable_flag: :Boolean,
    contact_color_disable_flag: :Boolean,
    unknown_color_disable_flag: :Boolean,
    _info: :'Hash<String, String>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • to be compared



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/connect_wise/models/service.rb', line 204

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    sr_notify == other.sr_notify &&
    schedule_span == other.schedule_span &&
    id == other.id &&
    hide_delimiter_flag == other.hide_delimiter_flag &&
    allow_cc_flag == other.allow_cc_flag &&
    allow_to_flag == other.allow_to_flag &&
    header_color == other.header_color &&
    member_color == other.member_color &&
    contact_color == other.contact_color &&
    unknown_color == other.unknown_color &&
    calendar_setup == other.calendar_setup &&
    header_color_disable_flag == other.header_color_disable_flag &&
    member_color_disable_flag == other.member_color_disable_flag &&
    contact_color_disable_flag == other.contact_color_disable_flag &&
    unknown_color_disable_flag == other.unknown_color_disable_flag &&
    _info == other._info
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • type Data type

  • value Value to be deserialized

Returns:

  • Deserialized data



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
299
300
301
302
303
304
305
306
307
308
# File 'lib/connect_wise/models/service.rb', line 271

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

Parameters:

  • Any valid value

Returns:

  • Returns the value in the form of hash



342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/connect_wise/models/service.rb', line 342

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:

  • Model attributes in the form of hash

Returns:

  • Returns the model itself



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/connect_wise/models/service.rb', line 248

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

Parameters:

  • to be compared

Returns:

See Also:

  • `==` method


228
229
230
# File 'lib/connect_wise/models/service.rb', line 228

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • Hash code



234
235
236
# File 'lib/connect_wise/models/service.rb', line 234

def hash
  [sr_notify, schedule_span, id, hide_delimiter_flag, allow_cc_flag, allow_to_flag, header_color, member_color, contact_color, unknown_color, calendar_setup, header_color_disable_flag, member_color_disable_flag, contact_color_disable_flag, unknown_color_disable_flag, _info].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



164
165
166
167
168
169
# File 'lib/connect_wise/models/service.rb', line 164

def list_invalid_properties
  invalid_properties = []
  invalid_properties.push('invalid value for "schedule_span", schedule_span cannot be nil.') if @schedule_span.nil?

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • Returns the object in the form of hash



318
319
320
# File 'lib/connect_wise/models/service.rb', line 318

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • Returns the object in the form of hash



324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/connect_wise/models/service.rb', line 324

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_sString

Returns the string representation of the object

Returns:

  • String presentation of the object



312
313
314
# File 'lib/connect_wise/models/service.rb', line 312

def to_s
  to_hash.to_s
end

#valid?Boolean

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

Returns:

  • true if the model is valid



173
174
175
176
177
178
179
180
181
182
# File 'lib/connect_wise/models/service.rb', line 173

def valid?
  sr_notify_validator = EnumAttributeValidator.new('String', %w[All NewAndClosedRequests ClosedRequestsOnly NewRequestsOnly None])
  return false unless sr_notify_validator.valid?(@sr_notify)
  return false if @schedule_span.nil?

  schedule_span_validator = EnumAttributeValidator.new('String', %w[Standard OfficeHours Overnight])
  return false unless schedule_span_validator.valid?(@schedule_span)

  true
end