Class: Esputnik::Contact

Inherits:
Struct
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/esputnik/contact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address

Returns:

  • (Object)

    the current value of address



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def address
  @address
end

#address_book_idObject

Returns the value of attribute address_book_id

Returns:

  • (Object)

    the current value of address_book_id



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def address_book_id
  @address_book_id
end

#channelsObject

Returns the value of attribute channels

Returns:

  • (Object)

    the current value of channels



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def channels
  @channels
end

#contact_keyObject

Returns the value of attribute contact_key

Returns:

  • (Object)

    the current value of contact_key



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def contact_key
  @contact_key
end

#fieldsObject

Returns the value of attribute fields

Returns:

  • (Object)

    the current value of fields



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def fields
  @fields
end

#first_nameObject

Returns the value of attribute first_name

Returns:

  • (Object)

    the current value of first_name



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def first_name
  @first_name
end

#groupsObject

Returns the value of attribute groups

Returns:

  • (Object)

    the current value of groups



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def groups
  @groups
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name

Returns:

  • (Object)

    the current value of last_name



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def last_name
  @last_name
end

#orders_infoObject

Returns the value of attribute orders_info

Returns:

  • (Object)

    the current value of orders_info



4
5
6
# File 'lib/esputnik/contact.rb', line 4

def orders_info
  @orders_info
end

Instance Method Details

#as_jsonObject



18
19
20
21
22
23
24
25
26
# File 'lib/esputnik/contact.rb', line 18

def as_json
  hash = self.class.members.each_with_object({}) do |method_name, h|
    value = public_send(method_name)
    value = value.as_json if value.respond_to? :as_json
    h[method_name.to_s.camelize(:lower)] = value if value.present?
  end
  hash['channels'] = channels&.map(&:as_json)
  hash
end