Class: Rails::Contact::Google::PayloadMapper
- Inherits:
-
Object
- Object
- Rails::Contact::Google::PayloadMapper
- Defined in:
- lib/rails/contact/google/payload_mapper.rb
Instance Method Summary collapse
-
#initialize(contact) ⇒ PayloadMapper
constructor
A new instance of PayloadMapper.
- #to_people_payload ⇒ Object
Constructor Details
#initialize(contact) ⇒ PayloadMapper
Returns a new instance of PayloadMapper.
5 6 7 |
# File 'lib/rails/contact/google/payload_mapper.rb', line 5 def initialize(contact) @contact = contact end |
Instance Method Details
#to_people_payload ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails/contact/google/payload_mapper.rb', line 9 def to_people_payload { names: [ { givenName: @contact.given_name, familyName: @contact.family_name } ], emailAddresses: @contact.emails.map { |email| { value: email.value, type: (email.label || "other") } }, phoneNumbers: @contact.phones.map { |phone| { value: phone.e164.presence || phone.value, type: (phone.label || "mobile") } }, addresses: @contact.addresses.map do |address| { city: address.city, formattedValue: address.formatted_value.presence || "Current city: #{@contact.current_city}\nDeparture city: #{@contact.departure_city}" } end, biographies: [ { value: [ @contact.biography, @contact.region_name ].compact.join("\n") } ] }.compact end |