Class: Mailflow::Contact
- Inherits:
-
Object
- Object
- Mailflow::Contact
- Includes:
- APIOperations
- Defined in:
- lib/mailflow-ruby/contact.rb
Instance Attribute Summary collapse
-
#confirmed ⇒ Object
Returns the value of attribute confirmed.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#email ⇒ Object
Returns the value of attribute email.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attributes ⇒ Object
- #delete ⇒ Object
-
#initialize(attributes) ⇒ Contact
constructor
A new instance of Contact.
- #set_attributes(attributes) ⇒ Object
- #tag(tags, trigger = false) ⇒ Object
- #tags ⇒ Object
- #untag(tags) ⇒ Object
Methods included from APIOperations
Constructor Details
#initialize(attributes) ⇒ Contact
Returns a new instance of Contact.
31 32 33 34 35 36 |
# File 'lib/mailflow-ruby/contact.rb', line 31 def initialize(attributes) @id = attributes["id"] @email = attributes["email"] @created_at = attributes["created_at"] @confirmed = attributes["confirmed"] end |
Instance Attribute Details
#confirmed ⇒ Object
Returns the value of attribute confirmed.
9 10 11 |
# File 'lib/mailflow-ruby/contact.rb', line 9 def confirmed @confirmed end |
#created_at ⇒ Object
Returns the value of attribute created_at.
9 10 11 |
# File 'lib/mailflow-ruby/contact.rb', line 9 def created_at @created_at end |
#email ⇒ Object
Returns the value of attribute email.
9 10 11 |
# File 'lib/mailflow-ruby/contact.rb', line 9 def email @email end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/mailflow-ruby/contact.rb', line 9 def id @id end |
Class Method Details
.create(attributes) ⇒ Object
24 25 26 27 28 |
# File 'lib/mailflow-ruby/contact.rb', line 24 def create(attributes) response = post_request('contacts', attributes) raise UnprocessableError if (response.code == 422 || response.code == 404) Contact.new(response.parsed_response) end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/mailflow-ruby/contact.rb', line 38 def ==(other) self.id == other.id && self.email == other.email && self.confirmed == other.confirmed end |
#attributes ⇒ Object
62 63 64 |
# File 'lib/mailflow-ruby/contact.rb', line 62 def attributes Mailflow::Attribute.list(contact_id: id) end |
#delete ⇒ Object
44 45 46 |
# File 'lib/mailflow-ruby/contact.rb', line 44 def delete Mailflow::Contact.delete_request('contacts', {contact_id: id}).parsed_response end |
#set_attributes(attributes) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/mailflow-ruby/contact.rb', line 66 def set_attributes(attributes) attributes = attributes.map do |key, value| {key: key.to_s, label: key.to_s, value: value} end Mailflow::Attribute.update(attributes, {contact_id: id}) self end |
#tag(tags, trigger = false) ⇒ Object
52 53 54 55 |
# File 'lib/mailflow-ruby/contact.rb', line 52 def tag(, trigger = false) Mailflow::Tag.create(, {contact_id: id}, trigger) self end |