Class: Acw::Client
Constant Summary collapse
- API_VERSION =
3
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #add_contact_tag(args = {}) ⇒ Object
- #connection ⇒ Object
- #create_contact(args = {}) ⇒ Object
- #create_field_value(args = {}) ⇒ Object
- #create_tag(args = {}) ⇒ Object
-
#initialize(configs = {}) ⇒ Client
constructor
A new instance of Client.
- #remove_contact_tag(id) ⇒ Object
- #retrieve_contact(id) ⇒ Object
- #retrieve_contact_by_email(email) ⇒ Object
- #retrieve_lists ⇒ Object
- #sync_contact(params) ⇒ Object
- #update_field_value(id, args = {}) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(configs = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 |
# File 'lib/acw/client.rb', line 13 def initialize(configs = {}) @config = configs end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
17 18 19 |
# File 'lib/acw/client.rb', line 17 def config @config end |
Instance Method Details
#add_contact_tag(args = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/acw/client.rb', line 83 def add_contact_tag(args = {}) safe_http_call do params = { 'contactTag': args } connection.post( path: "/api/#{API_VERSION}/contactTags", headers: headers(config[:token]), body: params.to_json ) end end |
#connection ⇒ Object
19 20 21 |
# File 'lib/acw/client.rb', line 19 def connection @connection ||= Excon.new(config[:url]) end |
#create_contact(args = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/acw/client.rb', line 23 def create_contact(args = {}) safe_http_call do params = { contact: args } connection.post( path: "/api/#{API_VERSION}/contacts", headers: headers(config[:token]), body: params.to_json ) end end |
#create_field_value(args = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/acw/client.rb', line 103 def create_field_value(args = {}) safe_http_call do params = { 'fieldValue': args } connection.post( path: "/api/#{API_VERSION}/fieldValues", headers: headers(config[:token]), body: params.to_json ) end end |
#create_tag(args = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/acw/client.rb', line 72 def create_tag(args = {}) safe_http_call do params = { tag: args } connection.post( path: "/api/#{API_VERSION}/tags", headers: headers(config[:token]), body: params.to_json ) end end |
#remove_contact_tag(id) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/acw/client.rb', line 94 def remove_contact_tag(id) safe_http_call do connection.delete( path: "/api/#{API_VERSION}/contactTags/#{id}", headers: headers(config[:token]) ) end end |
#retrieve_contact(id) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/acw/client.rb', line 44 def retrieve_contact(id) safe_http_call do connection.get( path: "/api/#{API_VERSION}/contacts/#{id}", headers: headers(config[:token]) ) end end |
#retrieve_contact_by_email(email) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/acw/client.rb', line 53 def retrieve_contact_by_email(email) safe_http_call do uemail = CGI.escape email connection.get( path: "/api/#{API_VERSION}/contacts?search=#{uemail}", headers: headers(config[:token]) ) end end |
#retrieve_lists ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/acw/client.rb', line 63 def retrieve_lists safe_http_call do connection.get( path: "/api/#{API_VERSION}/lists", headers: headers(config[:token]) ) end end |
#sync_contact(params) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/acw/client.rb', line 34 def sync_contact(params) safe_http_call do connection.post( path: "/api/#{API_VERSION}/contact/sync", headers: headers(config[:token]), body: params.to_json ) end end |
#update_field_value(id, args = {}) ⇒ Object
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/acw/client.rb', line 114 def update_field_value(id, args = {}) safe_http_call do params = { 'fieldValue': args } connection.put( path: "/api/#{API_VERSION}/fieldValues/#{id}", headers: headers(config[:token]), body: params.to_json ) end end |