Class: HelpScout::Customer

Inherits:
Base
  • Object
show all
Extended by:
Getable, Listable
Defined in:
lib/help_scout/customer.rb

Constant Summary collapse

BASIC_ATTRIBUTES =
%i[
  first_name
  last_name
  photo_url
  job_title
  photo_type
  background
  location
  created_at
  updated_at
  organization
  gender
  age
  id
].freeze
EMBEDDED_ATTRIBUTES =
%i[
  addresses
  chats
  emails
  phones
  social_profiles
  websites
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Getable

get

Methods included from Listable

list, list_path

Methods inherited from Base

#as_json, #to_h, #to_json

Constructor Details

#initialize(params = {}) ⇒ Customer

Returns a new instance of Customer.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/help_scout/customer.rb', line 34

def initialize(params = {})
  BASIC_ATTRIBUTES.each do |attribute|
    next unless params[attribute]

    instance_variable_set("@#{attribute}", params[attribute])
  end

  embedded_params = params.fetch(:_embedded, {})
  EMBEDDED_ATTRIBUTES.each do |attribute|
    next unless embedded_params[attribute]

    instance_variable_set("@#{attribute}", embedded_params[attribute])
  end

  @hrefs = HelpScout::Util.map_links(params[:_links])
end

Instance Attribute Details

#hrefsObject (readonly)

Returns the value of attribute hrefs.



32
33
34
# File 'lib/help_scout/customer.rb', line 32

def hrefs
  @hrefs
end