class SendgridThreads::Api

Attributes

connection[R]

Public Class Methods

new( params = {} ) click to toggle source
# File lib/sendgrid_threads/api.rb, line 5
def initialize( params = {} )
  @connection = SendgridThreads::Client.new(params)
end

Public Instance Methods

identify(user_id, traits = {}, timestamp = Time.now ) click to toggle source
# File lib/sendgrid_threads/api.rb, line 9
def identify(user_id, traits = {}, timestamp = Time.now )
  body = {userId: user_id, traits: traits, timestamp: utc_iso8601(timestamp)}
  @connection.post("identify", body)
end
page_view(user_id, name, properties = {}, timestamp = Time.now) click to toggle source
# File lib/sendgrid_threads/api.rb, line 19
def page_view(user_id, name, properties = {}, timestamp = Time.now)
  body = {userId: user_id, name: name, timestamp: utc_iso8601(timestamp), properties: properties}
  @connection.post("page", body)
end
remove(user_id, timestamp = Time.now) click to toggle source
# File lib/sendgrid_threads/api.rb, line 24
def remove(user_id, timestamp = Time.now)
  body = {userId: user_id, timestamp: utc_iso8601(timestamp)}
  @connection.post("remove", body)
end
track(user_id, event, properties = {}, timestamp = Time.now) click to toggle source
# File lib/sendgrid_threads/api.rb, line 14
def track(user_id, event, properties = {}, timestamp = Time.now)
  body = {userId: user_id, event: event, timestamp: utc_iso8601(timestamp), properties: properties}
  @connection.post("track", body)
end

Private Instance Methods

utc_iso8601(timestamp) click to toggle source
# File lib/sendgrid_threads/api.rb, line 31
def utc_iso8601(timestamp)
  timestamp.utc.iso8601.gsub(/Z$/, '.000Z')
end