Class: MaropostApi::Journeys

Inherits:
Object
  • Object
show all
Defined in:
lib/maropost_api/journeys.rb

Overview

Contains methods that get journey contacts based on provided parameters. The method names themselves reveal the type of reports they are getting.

Instance Method Summary collapse

Constructor Details

#initialize(account = ENV["ACCOUNT"], api_key = ENV["API_KEY"]) ⇒ Journeys

Creates a new instance of Reports class.



10
11
12
13
# File 'lib/maropost_api/journeys.rb', line 10

def initialize( = ENV["ACCOUNT"], api_key = ENV["API_KEY"])
  MaropostApi.instance_variable_set(:@api_key, api_key)
  MaropostApi.instance_variable_set(:@account, )
end

Instance Method Details

#get(page) ⇒ Object

gets all the journey contacts grouped by



18
19
20
21
22
23
# File 'lib/maropost_api/journeys.rb', line 18

def get(page)
  full_path = full_resource_path
  query_params = MaropostApi.set_query_params({:page => page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_campaigns(journey_id, page) ⇒ Object

gets all campaigns for the provided



29
30
31
32
33
34
# File 'lib/maropost_api/journeys.rb', line 29

def get_campaigns(journey_id, page)
  full_path = full_resource_path("/#{journey_id}/journey_campaigns")
  query_params = MaropostApi.set_query_params({:pae => page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_contacts(journey_id, page) ⇒ Object

gets contacts for the provided



40
41
42
43
44
45
# File 'lib/maropost_api/journeys.rb', line 40

def get_contacts(journey_id, page)
  full_path = full_resource_path("/#{journey_id}/journey_contacts")
  query_params = MaropostApi.set_query_params({:pae => page})
  
  MaropostApi.get_result(full_path, query_params)
end

#pause_for_contact(journey_id, contact_id) ⇒ Object

pauses journey for for the provided



67
68
69
70
71
72
# File 'lib/maropost_api/journeys.rb', line 67

def pause_for_contact(journey_id, contact_id)
  full_path = full_resource_path "/#{journey_id}/stop/#{contact_id}"
  query_params = MaropostApi.set_query_params
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#pause_for_uid(journey_id, uid) ⇒ Object

pauses journey for the given



78
79
80
81
82
83
# File 'lib/maropost_api/journeys.rb', line 78

def pause_for_uid(journey_id, uid)
  full_path = full_resource_path "/#{journey_id}/stop/uid"
  query_params = MaropostApi.set_query_params({:uid => uid})
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#reset_for_contact(journey_id, contact_id) ⇒ Object

resets journey for the given contact



89
90
91
92
93
94
# File 'lib/maropost_api/journeys.rb', line 89

def reset_for_contact(journey_id, contact_id)
  full_path = full_resource_path "/#{journey_id}/reset/#{contact_id}"
  query_params = MaropostApi.set_query_params
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#reset_for_uid(journey_id, uid) ⇒ Object

resets journey for the given uid



100
101
102
103
104
105
# File 'lib/maropost_api/journeys.rb', line 100

def reset_for_uid(journey_id, uid)
  full_path = full_resource_path "/#{journey_id}/reset/uid"
  query_params = MaropostApi.set_query_params({:uid => uid})
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#start_for_contact(journey_id, contact_id) ⇒ Object

starts journey for the given contact



111
112
113
114
115
116
# File 'lib/maropost_api/journeys.rb', line 111

def start_for_contact(journey_id, contact_id)
  full_path = full_resource_path "/#{journey_id}/start/#{contact_id}"
  query_params = MaropostApi.set_query_params
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#start_for_uid(journey_id, uid) ⇒ Object

starts journey for the given uid



122
123
124
125
126
127
# File 'lib/maropost_api/journeys.rb', line 122

def start_for_uid(journey_id, uid)
  full_path = full_resource_path "/#{journey_id}/start/uid"
  query_params = MaropostApi.set_query_params({:uid => uid})
  
  MaropostApi.put_result(full_path, {}, query_params)
end

#stop_all(contact_id: nil, uid: nil, email_recipient: nil) ⇒ Object

stops all journeys for the given



52
53
54
55
56
57
58
59
60
61
# File 'lib/maropost_api/journeys.rb', line 52

def stop_all(contact_id: nil, uid: nil, email_recipient: nil)
  query_params = {}
  query_params[:contact_id] = contact_id unless contact_id.nil?
  query_params[:uid] = uid unless uid.nil?
  query_params[:email] = email_recipient unless email_recipient.nil?
  full_path = full_resource_path "/stop_all_journeys"
  
  MaropostApi.put_result(full_path, {}, MaropostApi.set_query_params(query_params))
  
end