Class: SendgridThreads::Api
- Inherits:
-
Object
- Object
- SendgridThreads::Api
- Defined in:
- lib/sendgrid_threads/api.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #identify(user_id, traits = {}, timestamp = Time.now) ⇒ Object
-
#initialize(params = {}) ⇒ Api
constructor
A new instance of Api.
- #page_view(user_id, name, properties = {}, timestamp = Time.now) ⇒ Object
- #remove(user_id, timestamp = Time.now) ⇒ Object
- #track(user_id, event, properties = {}, timestamp = Time.now) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Api
Returns a new instance of Api.
5 6 7 |
# File 'lib/sendgrid_threads/api.rb', line 5 def initialize( params = {} ) @connection = SendgridThreads::Client.new(params) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/sendgrid_threads/api.rb', line 3 def connection @connection end |
Instance Method Details
#identify(user_id, traits = {}, timestamp = Time.now) ⇒ Object
9 10 11 12 |
# File 'lib/sendgrid_threads/api.rb', line 9 def identify(user_id, traits = {}, = Time.now ) body = {userId: user_id, traits: traits, timestamp: utc_iso8601()} @connection.post("identify", body) end |
#page_view(user_id, name, properties = {}, timestamp = Time.now) ⇒ Object
19 20 21 22 |
# File 'lib/sendgrid_threads/api.rb', line 19 def page_view(user_id, name, properties = {}, = Time.now) body = {userId: user_id, name: name, timestamp: utc_iso8601(), properties: properties} @connection.post("page", body) end |
#remove(user_id, timestamp = Time.now) ⇒ Object
24 25 26 27 |
# File 'lib/sendgrid_threads/api.rb', line 24 def remove(user_id, = Time.now) body = {userId: user_id, timestamp: utc_iso8601()} @connection.post("remove", body) end |
#track(user_id, event, properties = {}, timestamp = Time.now) ⇒ Object
14 15 16 17 |
# File 'lib/sendgrid_threads/api.rb', line 14 def track(user_id, event, properties = {}, = Time.now) body = {userId: user_id, event: event, timestamp: utc_iso8601(), properties: properties} @connection.post("track", body) end |