Module: Millionsend::Segments

Defined in:
lib/millionsend/segments.rb

Overview

Dynamic segments — a saved filter over the team's contacts. A MillionSend extension with no Resend equivalent.

Class Method Summary collapse

Class Method Details

.contacts(id, options = {}) ⇒ Object

GET /segments/:id/contacts — the contacts currently matching, paginated with limit:/after:/before:; include: (["properties", "topics"]) as on Contacts.list.



28
29
30
31
32
33
# File 'lib/millionsend/segments.rb', line 28

def contacts(id, options = {})
  query = Millionsend::Util.list_query(options).merge(include: Millionsend::Util.include_query(options[:include]))
  Millionsend::Request.new(
    method: :get, path: "/segments/#{Millionsend::Util.encode(id)}/contacts", query: query
  ).perform
end

.create(params) ⇒ Object

POST /segments



9
10
11
# File 'lib/millionsend/segments.rb', line 9

def create(params)
  Millionsend::Request.new(method: :post, path: "/segments", body: params).perform
end

.get(id) ⇒ Object

GET /segments/:id — also returns a live contact_count.



14
15
16
# File 'lib/millionsend/segments.rb', line 14

def get(id)
  Millionsend::Request.new(method: :get, path: "/segments/#{Millionsend::Util.encode(id)}").perform
end

.list(options = {}) ⇒ Object

GET /segments — accepts limit:/after:/before:.



19
20
21
22
23
# File 'lib/millionsend/segments.rb', line 19

def list(options = {})
  Millionsend::Request.new(
    method: :get, path: "/segments", query: Millionsend::Util.list_query(options)
  ).perform
end

.remove(id) ⇒ Object

DELETE /segments/:id



41
42
43
# File 'lib/millionsend/segments.rb', line 41

def remove(id)
  Millionsend::Request.new(method: :delete, path: "/segments/#{Millionsend::Util.encode(id)}").perform
end

.update(id, params) ⇒ Object

PATCH /segments/:id



36
37
38
# File 'lib/millionsend/segments.rb', line 36

def update(id, params)
  Millionsend::Request.new(method: :patch, path: "/segments/#{Millionsend::Util.encode(id)}", body: params).perform
end