Class: Teamsupport::Identity

Inherits:
Base
  • Object
show all
Defined in:
lib/teamsupport/identity.rb

Direct Known Subclasses

Customer, Product, Ticket

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], attr_reader, define_attribute_method, define_predicate_method, object_attr_reader, predicate_attr_reader

Methods included from Utils

flat_pmap, pmap

Constructor Details

#initialize(attrs = {}) ⇒ Teamsupport::Identity

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a new object

Parameters:

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

Raises:

  • (ArgumentError)

    Error raised when supplied argument is missing an :ID key.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/teamsupport/identity.rb', line 29

def initialize(attrs = {})
  # Workaround for dealing with TeamSupport API inconsistently sending ID for objects
  unless attrs[:ID]
    attrs[:ID] = attrs.fetch(:OrganizationID) if attrs[:OrganizationID]

    attrs[:ID] = attrs.fetch(:ProductID) if attrs[:ProductID]

    attrs[:ID] = attrs.fetch(:TicketID) if attrs[:TicketID]
  end

  attrs.fetch(:ID)
  super
end

Instance Attribute Details

#IDInteger (readonly)

Method for reading the TeamSupport ID of an object

Examples:

teamsupport_object = Teamsupport::Identity.new(ID: 1)
teamsupport_object.ID

Returns:

  • (Integer)


18
19
20
# File 'lib/teamsupport/identity.rb', line 18

def ID
  @ID
end