Class: Sendly::ContactList
- Inherits:
-
Object
- Object
- Sendly::ContactList
- Defined in:
- lib/sendly/contacts_resource.rb
Instance Attribute Summary collapse
-
#contact_count ⇒ Object
readonly
Returns the value of attribute contact_count.
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#contacts_total ⇒ Object
readonly
Returns the value of attribute contacts_total.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(data) ⇒ ContactList
constructor
A new instance of ContactList.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ ContactList
Returns a new instance of ContactList.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/sendly/contacts_resource.rb', line 64 def initialize(data) @id = data["id"] @name = data["name"] @description = data["description"] @contact_count = data["contact_count"] || data["contactCount"] || 0 @created_at = parse_time(data["created_at"] || data["createdAt"]) @updated_at = parse_time(data["updated_at"] || data["updatedAt"]) @contacts = data["contacts"]&.map do |c| { id: c["id"], phone_number: c["phone_number"] || c["phoneNumber"], name: c["name"], email: c["email"] } end @contacts_total = data["contacts_total"] || data["contactsTotal"] end |
Instance Attribute Details
#contact_count ⇒ Object (readonly)
Returns the value of attribute contact_count.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def contact_count @contact_count end |
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def contacts @contacts end |
#contacts_total ⇒ Object (readonly)
Returns the value of attribute contacts_total.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def contacts_total @contacts_total end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def name @name end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
61 62 63 |
# File 'lib/sendly/contacts_resource.rb', line 61 def updated_at @updated_at end |
Instance Method Details
#to_h ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/sendly/contacts_resource.rb', line 82 def to_h { id: id, name: name, description: description, contact_count: contact_count, created_at: created_at&.iso8601, updated_at: updated_at&.iso8601, contacts: contacts, contacts_total: contacts_total }.compact end |