Class: Keplars::Resources::Automations

Inherits:
Base
  • Object
show all
Defined in:
lib/keplars/automations.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Keplars::Resources::Base

Instance Method Details

#enroll(id, email:, properties: nil) ⇒ Object



17
18
19
20
21
# File 'lib/keplars/automations.rb', line 17

def enroll(id, email:, properties: nil)
  body = { email: email }
  body[:properties] = properties if properties
  @client.request('POST', "/api/v1/public/automations/add-automation/#{id}/enroll", body: body)[:data]
end

#get(id) ⇒ Object



13
14
15
# File 'lib/keplars/automations.rb', line 13

def get(id)
  @client.request('GET', "/api/v1/public/automations/get-automation/#{id}")[:data]
end

#list(page: nil, limit: nil) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/keplars/automations.rb', line 4

def list(page: nil, limit: nil)
  params = {}
  params[:page] = page if page
  params[:limit] = limit if limit

  query = @client.send(:build_query_string, params)
  @client.request('GET', "/api/v1/public/automations/get-all#{query}")[:data]
end

#track_event(email, event_name, event_properties: nil) ⇒ Object



27
28
29
30
31
# File 'lib/keplars/automations.rb', line 27

def track_event(email, event_name, event_properties: nil)
  body = { email: email, event_name: event_name }
  body[:event_properties] = event_properties if event_properties
  @client.request('POST', '/api/v1/public/automations/events/track', body: body)[:data]
end

#unenroll(id, email:) ⇒ Object



23
24
25
# File 'lib/keplars/automations.rb', line 23

def unenroll(id, email:)
  @client.request('DELETE', "/api/v1/public/automations/delete-automation/#{id}/subscribers", body: { email: email })[:data]
end