Class: Iterable::Services::ListService

Inherits:
BaseService show all
Defined in:
lib/iterable/services/list_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#api_key

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Iterable::Services::BaseService

Instance Method Details

#allObject



10
11
12
# File 'lib/iterable/services/list_service.rb', line 10

def all
  get(Util::Config.get('endpoints.lists'), nil, Iterable::Responses::Lists)
end

#find_by_id(id) ⇒ Object



14
15
16
17
# File 'lib/iterable/services/list_service.rb', line 14

def find_by_id(id)
  # iterate over all lists to find the id
  all.lists.select{|x| x.id == id.to_i}.first
end

#subscribe(list_id, subscribers) ⇒ Object



19
20
21
22
# File 'lib/iterable/services/list_service.rb', line 19

def subscribe(list_id, subscribers)
  request = Iterable::Requests::Subscribe.new(listId: list_id, subscribers: subscribers)
  post(Util::Config.get('endpoints.lists_subscribe'), request, nil, Iterable::Responses::Subscribe)
end