Class: CreateSend::Segment
- Inherits:
-
CreateSend
- Object
- CreateSend
- CreateSend::Segment
- Defined in:
- lib/createsend/segment.rb
Overview
Represents a subscriber list segment and associated functionality.
Constant Summary
Constants included from CreateSend
Instance Attribute Summary collapse
-
#segment_id ⇒ Object
readonly
Returns the value of attribute segment_id.
Class Method Summary collapse
-
.create(auth, list_id, title, rule_groups) ⇒ Object
Creates a new segment.
Instance Method Summary collapse
-
#add_rule_group(rule_group) ⇒ Object
Adds a rule to this segment.
-
#clear_rules ⇒ Object
Clears all rules of this segment.
-
#delete ⇒ Object
Deletes this segment.
-
#details ⇒ Object
Gets the details of this segment.
-
#initialize(auth, segment_id) ⇒ Segment
constructor
A new instance of Segment.
-
#subscribers(date = "", page = 1, page_size = 1000, order_field = "email", order_direction = "asc", include_tracking_preference = false) ⇒ Object
Gets the active subscribers in this segment.
-
#update(title, rule_groups) ⇒ Object
Updates this segment.
Constructor Details
#initialize(auth, segment_id) ⇒ Segment
Returns a new instance of Segment.
6 7 8 9 |
# File 'lib/createsend/segment.rb', line 6 def initialize(auth, segment_id) @segment_id = segment_id super end |
Instance Attribute Details
#segment_id ⇒ Object (readonly)
Returns the value of attribute segment_id.
4 5 6 |
# File 'lib/createsend/segment.rb', line 4 def segment_id @segment_id end |
Class Method Details
.create(auth, list_id, title, rule_groups) ⇒ Object
Creates a new segment.
12 13 14 15 16 17 18 19 |
# File 'lib/createsend/segment.rb', line 12 def self.create(auth, list_id, title, rule_groups) = { :body => { :Title => title, :RuleGroups => rule_groups }.to_json } cs = CreateSend.new auth response = cs.post "/segments/#{list_id}.json", response.parsed_response end |
Instance Method Details
#add_rule_group(rule_group) ⇒ Object
Adds a rule to this segment.
30 31 32 33 34 |
# File 'lib/createsend/segment.rb', line 30 def add_rule_group(rule_group) = { :body => { :Rules => rule_group }.to_json } post "rules", end |
#clear_rules ⇒ Object
Clears all rules of this segment.
57 58 59 |
# File 'lib/createsend/segment.rb', line 57 def clear_rules cs_delete "/segments/#{segment_id}/rules.json", {} end |
#delete ⇒ Object
Deletes this segment.
62 63 64 |
# File 'lib/createsend/segment.rb', line 62 def delete super "/segments/#{segment_id}.json", {} end |
#details ⇒ Object
Gets the details of this segment
51 52 53 54 |
# 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) ⇒ Object
Gets the active subscribers in this segment.
37 38 39 40 41 42 43 44 45 46 47 48 |
# 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) = { :query => { :date => date, :page => page, :pagesize => page_size, :orderfield => order_field, :orderdirection => order_direction, :includetrackingpreference => include_tracking_preference } } response = get "active", Hashie::Mash.new(response) end |
#update(title, rule_groups) ⇒ Object
Updates this segment.
22 23 24 25 26 27 |
# File 'lib/createsend/segment.rb', line 22 def update(title, rule_groups) = { :body => { :Title => title, :RuleGroups => rule_groups }.to_json } cs_put "/segments/#{segment_id}.json", end |