Class: Mailtrap::Contact

Inherits:
Struct
  • Object
show all
Defined in:
lib/mailtrap/contact.rb

Overview

Data Transfer Object for Contact

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Contact

Returns a new instance of Contact.



23
24
25
26
# File 'lib/mailtrap/contact.rb', line 23

def initialize(options)
  @action = options[:action]
  super(options.except(:action))
end

Instance Attribute Details

#created_at ⇒ Integer (readonly)

The creation timestamp

Returns:

  • (Integer) —

    the current value of created_at



13
14
15
# File 'lib/mailtrap/contact.rb', line 13

def created_at
  @created_at
end

#email ⇒ String (readonly)

The contact's email address

Returns:

  • (String) —

    the current value of email



13
14
15
# File 'lib/mailtrap/contact.rb', line 13

def email
  @email
end

#fields ⇒ Hash (readonly)

Object of fields with merge tags

Returns:

  • (Hash) —

    the current value of fields



13
14
15
# File 'lib/mailtrap/contact.rb', line 13

def fields
  @fields
end

#id ⇒ String (readonly)

The contact ID

Returns:

  • (String) —

    the current value of id



13
14
15
# File 'lib/mailtrap/contact.rb', line 13

def id
  @id
end

#list_ids ⇒ Array<Integer> (readonly)

Array of list IDs

Returns:

  • (Array<Integer>) —

    the current value 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)

Returns:

  • (String) —

    the current value of status



13
14
15
# File 'lib/mailtrap/contact.rb', line 13

def status
  @status
end

#updated_at ⇒ Integer (readonly)

The last update timestamp

Returns:

  • (Integer) —

    the current value of updated_at



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.

Returns:

  • (Boolean) —

    Whether the contact was newly created



29
30
31
# File 'lib/mailtrap/contact.rb', line 29

def newly_created?
  @action != 'updated'
end