Class: Leadsquared::Activity

Inherits:
ApiConnection show all
Defined in:
lib/leadsquared/activity.rb

Constant Summary collapse

SERVICE =
'/v2/ProspectActivity.svc/'.freeze

Instance Attribute Summary

Attributes inherited from ApiConnection

#connection

Instance Method Summary collapse

Constructor Details

#initializeActivity

Returns a new instance of Activity.



8
9
10
# File 'lib/leadsquared/activity.rb', line 8

def initialize
  super(SERVICE)
end

Instance Method Details

#create(email, event_id, notes = nil, first_name = nil, last_name = nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/leadsquared/activity.rb', line 49

def create(email, event_id, notes = nil, first_name = nil, last_name = nil)
  url = url_with_service("Create")
  body = {
    "EmailAddress"      => email,
    "ActivityEvent"     => event_id,
    "ActivityNote"      => notes,
    "ActivityDateTime"  => current_utc_time,
    "FirstName"         => first_name,
    "LastName"          => last_name
  }
  response = connection.post(url, {}, body.to_json)
  parsed_response = handle_response response
  parsed_response["Message"]["Id"]
end

#create_activity_type(name, score, description, direction = 0) ⇒ Object

direction - Use ‘1’ as direction for Outbound Activity and ‘0’ for Inbound Activity



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/leadsquared/activity.rb', line 23

def create_activity_type(name, score, description, direction = 0)
  url = url_with_service("CreateType")
  body = {
    "ActivityEventName" => name,
    "Score" => score,
    "Description" => description,
    "Direction" => direction
  }
  response = connection.post(url, {}, body.to_json)
  parsed_response = handle_response response
  parsed_response["Message"]["Id"]
end

#create_lead_activity(lead_id, event_id, notes = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/leadsquared/activity.rb', line 36

def create_lead_activity(lead_id, event_id, notes = nil)
  url = url_with_service("Create")
  body = {
    "RelatedProspectId" => lead_id,
    "ActivityEvent"     => event_id,
    "ActivityNote"      => notes,
    "ActivityDateTime"  => current_utc_time
  }
  response = connection.post(url, {leadId: lead_id}, body.to_json)
  parsed_response = handle_response response
  parsed_response["Message"]["Id"]
end

#get_activities(lead_id, activity_event_id, offset = 0, row_count = 10) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/leadsquared/activity.rb', line 12

def get_activities(lead_id, activity_event_id, offset = 0, row_count = 10)
  url = url_with_service("Retrieve")
  body = {
    "Parameter" => {"ActivityEvent" => activity_event_id},
    "Paging" => {"Offset" => offset, "RowCount" => row_count}
  }
  response = connection.post(url, {leadId: lead_id}, body.to_json)
  handle_response response
end