Class: WhatCounts::List
- Inherits:
-
Object
show all
- Defined in:
- lib/whatcounts/list.rb
Defined Under Namespace
Classes: MissingRequiredListOptionError, UnknownListOptionError
Constant Summary
collapse
- REQUIRED_OPTIONS =
Options which are required for new/create
[:name]
- VALID_OPTIONS =
List of options which this class will accept
OPTIONS_TO_HTTP_PARAMS_MAP.keys
- SUBSCRIBE_OPTIONS_TO_HTTP_PARAMS_MAP =
{:list => :list_id, :format => :format,
:force_subscribe => :force_sub, :data => :data }
- SUBSCRIBE_REQUIRED_OPTIONS =
[:list]
- SUBSCRIBE_IRREGULAR_OPTIONS =
[:data]
- LAUNCH_OPTIONS_TO_HTTP_PARAMS_MAP =
{:list => :list_id, :template => :template_id,
:subject => :subject, :format => :format,
:segmentation_id => :segmentation_id, :campaign_alias => :campaign_alias,
:send_rss => :target_rss, :virtual_mta => :vmta,
:goodmail_token => :gm_token_type, :notification_email => :notify_email }
- LAUNCH_REQUIRED_OPTIONS =
[:list]
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ List
Returns a new instance of List.
Class Method Details
.create!(options) ⇒ Object
51
52
53
54
|
# File 'lib/whatcounts/list.rb', line 51
def create!(options)
o = self.new options
o.create!
end
|
Instance Method Details
#add_recipients!(recipient_ary) ⇒ Object
#create! ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/whatcounts/list.rb', line 31
def create!
res = WhatCounts::HttpClient.execute('excreatelist',self)
if res.success?
self.instance_variable_set(:@id,res.body.to_i)
return self
else
raise CreationError, res.body end
end
|
#id ⇒ Object
41
|
# File 'lib/whatcounts/list.rb', line 41
def id; @id end
|
#launch!(options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/whatcounts/list.rb', line 73
def launch!(options={})
options = {:list => @id, :format => 99}.merge(options)
res = WhatCounts::HttpClient.execute('launch',convert_to_whatcounts_parameters(options,LAUNCH_OPTIONS_TO_HTTP_PARAMS_MAP))
if res.success?
return res
else
puts res.url
raise DeployError, res.body
end
end
|
#to_param_string ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/whatcounts/list.rb', line 42
def to_param_string
@param_string ||= OPTIONS_TO_HTTP_PARAMS_MAP.keys.inject([]) do |acc,k|
val = self.send :"#{k}"
acc << "#{OPTIONS_TO_HTTP_PARAMS_MAP[k]}=#{CGI.escape(val.to_s)}" unless val.nil?
acc
end.join("&")
end
|