Class: Mailtrap::Contact
- Inherits:
-
Struct
- Object
- Struct
- Mailtrap::Contact
- Defined in:
- lib/mailtrap/contact.rb
Overview
Data Transfer Object for Contact
Instance Attribute Summary collapse
-
#created_at ⇒ Integer
readonly
The creation timestamp.
-
#email ⇒ String
readonly
The contact’s email address.
-
#fields ⇒ Hash
readonly
Object of fields with merge tags.
-
#id ⇒ String
readonly
The contact ID.
-
#list_ids ⇒ Array<Integer>
readonly
Array of list IDs.
-
#status ⇒ String
readonly
The contact status (subscribed/unsubscribed).
-
#updated_at ⇒ Integer
readonly
The last update timestamp.
Instance Method Summary collapse
-
#initialize(options) ⇒ Contact
constructor
A new instance of Contact.
-
#newly_created? ⇒ Boolean
Whether the contact was newly created.
-
#to_h ⇒ Hash
The contact attributes as a hash.
Constructor Details
#initialize(options) ⇒ Contact
Returns a new instance of Contact.
23 24 25 26 |
# File 'lib/mailtrap/contact.rb', line 23 def initialize() @action = [:action] super(.except(:action)) end |
Instance Attribute Details
#created_at ⇒ Integer (readonly)
The creation timestamp
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def created_at @created_at end |
#email ⇒ String (readonly)
The contact’s email address
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def email @email end |
#fields ⇒ Hash (readonly)
Object of fields with merge tags
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def fields @fields end |
#id ⇒ String (readonly)
The contact ID
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def id @id end |
#list_ids ⇒ Array<Integer> (readonly)
Array of list IDs
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def list_ids @list_ids end |
#status ⇒ String (readonly)
The contact status (subscribed/unsubscribed)
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def status @status end |
#updated_at ⇒ Integer (readonly)
The last update timestamp
13 14 15 |
# File 'lib/mailtrap/contact.rb', line 13 def updated_at @updated_at end |
Instance Method Details
#newly_created? ⇒ Boolean
Returns Whether the contact was newly created.
29 30 31 |
# File 'lib/mailtrap/contact.rb', line 29 def newly_created? @action != 'updated' end |
#to_h ⇒ Hash
Returns The contact attributes as a hash.
34 35 36 |
# File 'lib/mailtrap/contact.rb', line 34 def to_h super.compact end |