Class: SendgridThreads::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/sendgrid_threads/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (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 = {}, 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) ⇒ Object



19
20
21
22
# 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) ⇒ Object



24
25
26
27
# 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) ⇒ Object



14
15
16
17
# 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