Class: Sendly::Contact
- Inherits:
-
Object
- Object
- Sendly::Contact
- Defined in:
- lib/sendly/contacts_resource.rb
Instance Attribute Summary collapse
-
#carrier_name ⇒ Object
readonly
Returns the value of attribute carrier_name.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#invalid_reason ⇒ Object
readonly
Returns the value of attribute invalid_reason.
-
#invalidated_at ⇒ Object
readonly
Returns the value of attribute invalidated_at.
-
#line_type ⇒ Object
readonly
Returns the value of attribute line_type.
-
#line_type_checked_at ⇒ Object
readonly
Returns the value of attribute line_type_checked_at.
-
#lists ⇒ Object
readonly
Returns the value of attribute lists.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opted_out ⇒ Object
readonly
Returns the value of attribute opted_out.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#user_marked_valid_at ⇒ Object
readonly
Returns the value of attribute user_marked_valid_at.
Instance Method Summary collapse
-
#initialize(data) ⇒ Contact
constructor
A new instance of Contact.
- #invalid? ⇒ Boolean
- #opted_out? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ Contact
Returns a new instance of Contact.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sendly/contacts_resource.rb', line 10 def initialize(data) @id = data["id"] @phone_number = data["phone_number"] || data["phoneNumber"] @name = data["name"] @email = data["email"] @metadata = data["metadata"] || {} @opted_out = data["opted_out"] || data["optedOut"] || false @line_type = data["line_type"] || data["lineType"] @carrier_name = data["carrier_name"] || data["carrierName"] @line_type_checked_at = parse_time(data["line_type_checked_at"] || data["lineTypeCheckedAt"]) @invalid_reason = data["invalid_reason"] || data["invalidReason"] @invalidated_at = parse_time(data["invalidated_at"] || data["invalidatedAt"]) @user_marked_valid_at = parse_time(data["user_marked_valid_at"] || data["userMarkedValidAt"]) @created_at = parse_time(data["created_at"] || data["createdAt"]) @updated_at = parse_time(data["updated_at"] || data["updatedAt"]) @lists = data["lists"]&.map { |l| { id: l["id"], name: l["name"] } } end |
Instance Attribute Details
#carrier_name ⇒ Object (readonly)
Returns the value of attribute carrier_name.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def carrier_name @carrier_name end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def created_at @created_at end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def id @id end |
#invalid_reason ⇒ Object (readonly)
Returns the value of attribute invalid_reason.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def invalid_reason @invalid_reason end |
#invalidated_at ⇒ Object (readonly)
Returns the value of attribute invalidated_at.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def invalidated_at @invalidated_at end |
#line_type ⇒ Object (readonly)
Returns the value of attribute line_type.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def line_type @line_type end |
#line_type_checked_at ⇒ Object (readonly)
Returns the value of attribute line_type_checked_at.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def line_type_checked_at @line_type_checked_at end |
#lists ⇒ Object (readonly)
Returns the value of attribute lists.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def lists @lists end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def name @name end |
#opted_out ⇒ Object (readonly)
Returns the value of attribute opted_out.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def opted_out @opted_out end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def phone_number @phone_number end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def updated_at @updated_at end |
#user_marked_valid_at ⇒ Object (readonly)
Returns the value of attribute user_marked_valid_at.
5 6 7 |
# File 'lib/sendly/contacts_resource.rb', line 5 def user_marked_valid_at @user_marked_valid_at end |
Instance Method Details
#invalid? ⇒ Boolean
32 33 34 |
# File 'lib/sendly/contacts_resource.rb', line 32 def invalid? !invalid_reason.nil? end |
#opted_out? ⇒ Boolean
28 29 30 |
# File 'lib/sendly/contacts_resource.rb', line 28 def opted_out? opted_out end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sendly/contacts_resource.rb', line 36 def to_h { id: id, phone_number: phone_number, name: name, email: email, metadata: , opted_out: opted_out, line_type: line_type, carrier_name: carrier_name, line_type_checked_at: line_type_checked_at&.iso8601, invalid_reason: invalid_reason, invalidated_at: invalidated_at&.iso8601, user_marked_valid_at: user_marked_valid_at&.iso8601, created_at: created_at&.iso8601, updated_at: updated_at&.iso8601, lists: lists }.compact end |