Class: EmailDirect::Campaign

Inherits:
Object
  • Object
show all
Defined in:
lib/emaildirect/campaign.rb

Overview

Represents a campaign and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(campaign_id) ⇒ Campaign



47
48
49
# File 'lib/emaildirect/campaign.rb', line 47

def initialize(campaign_id)
  @campaign_id = campaign_id
end

Instance Attribute Details

#campaign_idObject (readonly)

Returns the value of attribute campaign_id.



45
46
47
# File 'lib/emaildirect/campaign.rb', line 45

def campaign_id
  @campaign_id
end

Class Method Details

.active(options = {}) ⇒ Object



8
9
10
11
# File 'lib/emaildirect/campaign.rb', line 8

def active(options = {})
  response = EmailDirect.get '/Campaigns', :query => options
  Hashie::Mash.new(response)
end

.all(options = {}) ⇒ Object



33
34
35
36
# File 'lib/emaildirect/campaign.rb', line 33

def all(options = {})
  response = EmailDirect.get '/Campaigns/All', :query => options
  Hashie::Mash.new(response)
end

.create(name, creative_id, subject, from_name, publication_id, options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/emaildirect/campaign.rb', line 38

def create(name, creative_id, subject, from_name, publication_id, options = {})
  options.merge! :Name => name, :CreativeID => creative_id, :Subject => subject, :FromName => from_name, :PublicationID => publication_id
  response = EmailDirect.post '/Campaigns', :body => options.to_json
  Hashie::Mash.new(response)
end

.drafts(options = {}) ⇒ Object



13
14
15
16
# File 'lib/emaildirect/campaign.rb', line 13

def drafts(options = {})
  response = EmailDirect.get '/Campaigns/Drafts', :query => options
  Hashie::Mash.new(response)
end

.scheduled(options = {}) ⇒ Object



28
29
30
31
# File 'lib/emaildirect/campaign.rb', line 28

def scheduled(options = {})
  response = EmailDirect.get '/Campaigns/Scheduled', :query => options
  Hashie::Mash.new(response)
end

.sending(options = {}) ⇒ Object



23
24
25
26
# File 'lib/emaildirect/campaign.rb', line 23

def sending(options = {})
  response = EmailDirect.get '/Campaigns/Sending', :query => options
  Hashie::Mash.new(response)
end

.sent(options = {}) ⇒ Object



18
19
20
21
# File 'lib/emaildirect/campaign.rb', line 18

def sent(options = {})
  response = EmailDirect.get '/Campaigns/Sent', :query => options
  Hashie::Mash.new(response)
end

Instance Method Details

#cancelObject



113
114
115
116
# File 'lib/emaildirect/campaign.rb', line 113

def cancel
  response = EmailDirect.post '/Campaigns/Cancel', :body => campaign_id.to_json
  Hashie::Mash.new(response)
end

#clicks(options = {}) ⇒ Object



76
77
78
79
# File 'lib/emaildirect/campaign.rb', line 76

def clicks(options = {})
  response = get 'Clicks', options
  Hashie::Mash.new(response)
end

#complaints(options = {}) ⇒ Object



86
87
88
89
# File 'lib/emaildirect/campaign.rb', line 86

def complaints(options = {})
  response = get 'Complaints', options
  Hashie::Mash.new(response)
end

#deleteObject



118
119
120
121
# File 'lib/emaildirect/campaign.rb', line 118

def delete
  response = EmailDirect.delete uri_for, {}
  Hashie::Mash.new(response)
end

#detailsObject



51
52
53
54
# File 'lib/emaildirect/campaign.rb', line 51

def details
  response = get
  Hashie::Mash.new(response)
end

#hard_bounces(options = {}) ⇒ Object



96
97
98
99
# File 'lib/emaildirect/campaign.rb', line 96

def hard_bounces(options = {})
  response = get 'HardBounces', options
  Hashie::Mash.new(response)
end


61
62
63
64
# File 'lib/emaildirect/campaign.rb', line 61

def links
  response = get 'Links'
  Hashie::Mash.new(response)
end

#messageObject



56
57
58
59
# File 'lib/emaildirect/campaign.rb', line 56

def message
  response = get 'Email'
  Hashie::Mash.new(response)
end

#opens(options = {}) ⇒ Object



71
72
73
74
# File 'lib/emaildirect/campaign.rb', line 71

def opens(options = {})
  response = get 'Opens', options
  Hashie::Mash.new(response)
end

#recipients(options = {}) ⇒ Object



66
67
68
69
# File 'lib/emaildirect/campaign.rb', line 66

def recipients(options = {})
  response = get 'Recipients', options
  Hashie::Mash.new(response)
end

#removes(options = {}) ⇒ Object



81
82
83
84
# File 'lib/emaildirect/campaign.rb', line 81

def removes(options = {})
  response = get 'Removes', options
  Hashie::Mash.new(response)
end

#schedule(schedule_date) ⇒ Object



107
108
109
110
111
# File 'lib/emaildirect/campaign.rb', line 107

def schedule(schedule_date)
  options = { :CampaignID => campaign_id, :ScheduleDate => schedule_date.strftime('%FT%TZ') }
  response = EmailDirect.post '/Campaigns/Schedule', :body => options.to_json
  Hashie::Mash.new(response)
end

#soft_bounces(options = {}) ⇒ Object



91
92
93
94
# File 'lib/emaildirect/campaign.rb', line 91

def soft_bounces(options = {})
  response = get 'SoftBounces', options
  Hashie::Mash.new(response)
end

#update(name, creative_id, subject, from_name, publication_id, options = {}) ⇒ Object



101
102
103
104
105
# File 'lib/emaildirect/campaign.rb', line 101

def update(name, creative_id, subject, from_name, publication_id, options = {})
  options.merge! :Name => name, :CreativeID => creative_id, :Subject => subject, :FromName => from_name, :PublicationID => publication_id
  response = EmailDirect.put uri_for, :body => options.to_json
  Hashie::Mash.new(response)
end