class CreateSend::Segment
Represents a subscriber list segment and associated functionality.
Attributes
segment_id[R]
Public Class Methods
create(auth, list_id, title, rule_groups)
click to toggle source
Creates a new segment.
# File lib/createsend/segment.rb, line 12 def self.create(auth, list_id, title, rule_groups) options = { :body => { :Title => title, :RuleGroups => rule_groups }.to_json } cs = CreateSend.new auth response = cs.post "/segments/#{list_id}.json", options response.parsed_response end
new(auth, segment_id)
click to toggle source
Calls superclass method
# File lib/createsend/segment.rb, line 6 def initialize(auth, segment_id) @segment_id = segment_id super end
Public Instance Methods
add_rule_group(rule_group)
click to toggle source
Adds a rule to this segment.
# File lib/createsend/segment.rb, line 30 def add_rule_group(rule_group) options = { :body => { :Rules => rule_group }.to_json } post "rules", options end
clear_rules()
click to toggle source
Clears all rules of this segment.
# File lib/createsend/segment.rb, line 57 def clear_rules cs_delete "/segments/#{segment_id}/rules.json", {} end
delete()
click to toggle source
Deletes this segment.
Calls superclass method
# File lib/createsend/segment.rb, line 62 def delete super "/segments/#{segment_id}.json", {} end
details()
click to toggle source
Gets the details of this segment
# File lib/createsend/segment.rb, line 51 def details response = cs_get "/segments/#{segment_id}.json", {} Hashie::Mash.new(response) end
subscribers(date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=false)
click to toggle source
Gets the active subscribers in this segment.
# File lib/createsend/segment.rb, line 37 def subscribers(date="", page=1, page_size=1000, order_field="email", order_direction="asc", include_tracking_preference=false) options = { :query => { :date => date, :page => page, :pagesize => page_size, :orderfield => order_field, :orderdirection => order_direction, :includetrackingpreference => include_tracking_preference } } response = get "active", options Hashie::Mash.new(response) end
update(title, rule_groups)
click to toggle source
Updates this segment.
# File lib/createsend/segment.rb, line 22 def update(title, rule_groups) options = { :body => { :Title => title, :RuleGroups => rule_groups }.to_json } cs_put "/segments/#{segment_id}.json", options end
Private Instance Methods
get(action, options = {})
click to toggle source
Calls superclass method
# File lib/createsend/segment.rb, line 68 def get(action, options = {}) super uri_for(action), options end
post(action, options = {})
click to toggle source
Calls superclass method
# File lib/createsend/segment.rb, line 72 def post(action, options = {}) super uri_for(action), options end
uri_for(action)
click to toggle source
# File lib/createsend/segment.rb, line 76 def uri_for(action) "/segments/#{segment_id}/#{action}.json" end