Class: Knowtify::Client
- Inherits:
-
Object
- Object
- Knowtify::Client
- Defined in:
- lib/knowtify/client.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
Instance Method Summary collapse
- #config ⇒ Object
-
#contacts_create_or_update(contacts = [], request_options = {}, api_key = nil) ⇒ Object
(also: #contacts_upsert)
POST /contacts/upsert Sends a request to create or update contacts with the supplied data.
-
#contacts_delete(contacts = [], http_request_options = {}, api_key = nil) ⇒ Object
POST /contacts/delete Sends a request to delete contacts whose emails match those provided.
-
#global_edit(data = {}, http_request_options = {}, api_key = nil) ⇒ Object
POST /data/edit Updates global data based on the data provided Example data: { “users”:890, “comments”:994, “top_story_url”:“test.com/story”, “top_story_title”:“Article!” }.
-
#initialize ⇒ Client
constructor
TODO: Refactor to separate classes for each method.
-
#transactional_email(event, contacts = [], http_request_options = {}, api_key = nil) ⇒ Object
POST contacts/upsert Sends a transaction email with the event and contacts provided { “event”:“purchase”, “contacts”: [ { “email”:“[email protected]” } ] }.
Constructor Details
#initialize ⇒ Client
TODO: Refactor to separate classes for each method
6 7 8 |
# File 'lib/knowtify/client.rb', line 6 def initialize @handler = config.handler.new end |
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
3 4 5 |
# File 'lib/knowtify/client.rb', line 3 def handler @handler end |
Instance Method Details
#config ⇒ Object
112 113 114 |
# File 'lib/knowtify/client.rb', line 112 def config Knowtify.config end |
#contacts_create_or_update(contacts = [], request_options = {}, api_key = nil) ⇒ Object Also known as: contacts_upsert
POST /contacts/upsert Sends a request to create or update contacts with the supplied data. Example contacts: [
{
"name":"John",
"email":"[email protected]",
"data":{
"category":"sports",
"followers":300
}
},
{
"name":"Samuel",
"email":"[email protected]",
"data":{
"category":"sports",
"followers":32,
"comments":54,
"role":"Editor"
}
}
]
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/knowtify/client.rb', line 34 def contacts_create_or_update(contacts=[],={},api_key=nil) = { :path => "#{config.base_path}/contacts/upsert", :params => {:contacts => contacts}, :request_options => , :api_key => api_key } request = Knowtify::Request.new() handler.post(request) end |
#contacts_delete(contacts = [], http_request_options = {}, api_key = nil) ⇒ Object
POST /contacts/delete Sends a request to delete contacts whose emails match those provided. Example contacts: [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
]
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/knowtify/client.rb', line 60 def contacts_delete(contacts=[],={},api_key=nil) = { :path => "#{config.base_path}/contacts/delete", :params => {:contacts => contacts}, :http_request_options => , :api_key => api_key } request = Knowtify::Request.new() handler.post(request) end |
#global_edit(data = {}, http_request_options = {}, api_key = nil) ⇒ Object
POST /data/edit Updates global data based on the data provided Example data:
"users":890,
"comments":994,
"top_story_url":"test.com/story",
"top_story_title":"Article!"
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/knowtify/client.rb', line 80 def global_edit(data={},={},api_key=nil) = { :path => "#{config.base_path}/data/edit", :params => {:data => data}, :http_request_options => , :api_key => api_key } request = Knowtify::Request.new() handler.post(request) end |
#transactional_email(event, contacts = [], http_request_options = {}, api_key = nil) ⇒ Object
POST contacts/upsert Sends a transaction email with the event and contacts provided {
"event":"purchase",
"contacts": [
{
"email":"[email protected]"
}
]
}
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/knowtify/client.rb', line 101 def transactional_email(event, contacts=[],={},api_key=nil) = { :path => "#{config.base_path}/data/edit", :params => {:data => contacts}, :http_request_options => , :api_key => api_key } request = Knowtify::Request.new() handler.post(request) end |