Class: Workarea::Listrak::EmailApi::Contacts
- Inherits:
-
Object
- Object
- Workarea::Listrak::EmailApi::Contacts
- Defined in:
- app/services/workarea/listrak/email_api/contacts.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #get(list_id, contactIdentifier, options = {}) ⇒ Workarea::Listrak::Models::Contact
-
#initialize(client) ⇒ Contacts
constructor
A new instance of Contacts.
- #upsert(list_id, contact, options = {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Contacts
Returns a new instance of Contacts.
6 7 8 |
# File 'app/services/workarea/listrak/email_api/contacts.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/workarea/listrak/email_api/contacts.rb', line 4 def client @client end |
Instance Method Details
#get(list_id, contactIdentifier, options = {}) ⇒ Workarea::Listrak::Models::Contact
36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/workarea/listrak/email_api/contacts.rb', line 36 def get(list_id, contactIdentifier, = {}) params = validate_query_params(, get_params) path = [ "/email/v1/List/#{list_id}/Contact/#{contactIdentifier}", params ].compact.join '?' request = Net::HTTP::Get.new(path) response = client.request request body = JSON.parse response.body Listrak::Models::Contact.new(body["data"]) end |
#upsert(list_id, contact, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/workarea/listrak/email_api/contacts.rb', line 19 def upsert(list_id, contact, = {}) params = validate_query_params(, upsert_params) path = ["/email/v1/List/#{list_id}/Contact", params].compact.join '?' request = Net::HTTP::Post.new(path).tap do |post| post.body = contact.to_json end response = client.request request body = JSON.parse(response.body) body["data"] end |