Class: LucidIntercom::UserAttributes

Inherits:
Attributes show all
Defined in:
lib/lucid_intercom/user_attributes.rb

Instance Method Summary collapse

Methods inherited from Attributes

#shopify_data

Instance Method Details

#idString

Returns:

  • (String)


34
35
36
# File 'lib/lucid_intercom/user_attributes.rb', line 34

def id
  shopify_data[id_key.to_s]
end

#id_keySymbol

Either :user_id or :email. Currently, we are using the email address.

Returns:

  • (Symbol)


27
28
29
# File 'lib/lucid_intercom/user_attributes.rb', line 27

def id_key
  :email
end

#to_h(browser: false, convert: Convert.new) ⇒ Hash

Parameters:

  • browser (Boolean) (defaults to: false)

    format for browser snippet

  • convert (#call) (defaults to: Convert.new)

Returns:

  • (Hash)


14
15
16
17
18
19
20
# File 'lib/lucid_intercom/user_attributes.rb', line 14

def to_h(browser: false, convert: Convert.new)
  convert.({}.tap do |h|
    h[:user_hash] = user_hash(id) if browser # or myshopify_domain
    h[:email] = shopify_data['email']
    h[:name] = shopify_data['shop_owner']
  end)
end