createsend 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- createsend (2.3.0)
4
+ createsend (2.4.0)
5
5
  hashie (~> 1.0)
6
6
  httparty (~> 0.8)
7
7
  json
@@ -15,17 +15,17 @@ GEM
15
15
  cane (2.0.0)
16
16
  fakeweb (1.3.0)
17
17
  hashie (1.2.0)
18
- httparty (0.8.1)
19
- multi_json
18
+ httparty (0.9.0)
19
+ multi_json (~> 1.0)
20
20
  multi_xml
21
21
  i18n (0.6.1)
22
22
  jnunemaker-matchy (0.4.0)
23
- json (1.7.4)
23
+ json (1.7.5)
24
24
  metaclass (0.0.1)
25
25
  mocha (0.10.0)
26
26
  metaclass (~> 0.0.1)
27
27
  multi_json (1.0.3)
28
- multi_xml (0.4.1)
28
+ multi_xml (0.4.4)
29
29
  rake (0.9.2.2)
30
30
  shoulda (3.3.0)
31
31
  shoulda-context (~> 1.0)
data/HISTORY.md ADDED
@@ -0,0 +1,83 @@
1
+ # createsend-ruby history
2
+
3
+ ## v2.4.0 - 5 Nov, 2012 (4277d8d9)
4
+
5
+ * Added CreateSend::Campaign#email_client_usage.
6
+ * Added support for ReadsEmailWith field on subscriber objects.
7
+ * Added support for retrieving unconfirmed subscribers for a list.
8
+ * Added support for suppressing email addresses.
9
+ * Added support for retrieving spam complaints for a campaign, as well as
10
+ adding SpamComplaints field to campaign summary output.
11
+ * Added VisibleInPreferenceCenter field to custom field output.
12
+ * Added support for setting preference center visibility when creating custom
13
+ fields.
14
+ * Added the ability to update a custom field name and preference visibility.
15
+ * Added documentation explaining that text_url may now be nil or an empty
16
+ string when creating a campaign.
17
+
18
+ ## v2.3.0 - 10 Oct, 2012 (6639c1f6)
19
+
20
+ * Added support for creating campaigns from templates.
21
+ * Added support for unsuppressing an email address.
22
+ * Improved documentation and tests for getting active subscribers. Clearly
23
+ documented the data structure for multi option multi select fields.
24
+
25
+ ## v2.2.0 - 17 Sep, 2012 (17409634)
26
+
27
+ * Added WorldviewURL field to campaign summary response.
28
+ * Added Latitude, Longitude, City, Region, CountryCode, and CountryName fields
29
+ to campaign opens and clicks response.
30
+
31
+ ## v2.1.0 - 30 Aug, 2012 (ee936259)
32
+
33
+ * Added support for basic / unlimited pricing.
34
+
35
+ ## v2.0.0 - 22 Aug, 2012 (8a5ab6b4)
36
+
37
+ * Added support for UnsubscribeSetting field when creating, updating and
38
+ getting list details.
39
+ * Added support for including AddUnsubscribesToSuppList and
40
+ ScrubActiveWithSuppList fields when updating a list.
41
+ * Added support for getting all client lists to which a subscriber with a
42
+ specific email address belongs.
43
+ * Removed deprecated warnings and disallowed calls to be made in a deprecated
44
+ manner.
45
+
46
+ ## v1.1.1 - 24 Jul, 2012 (72934e66)
47
+
48
+ * Added support for specifying whether subscription-based autoresponders
49
+ should be restarted when adding or updating subscribers.
50
+
51
+ ## v1.1.0 - 11 Jul, 2012 (93e856b6)
52
+
53
+ * Added support for newly released team management functionality.
54
+
55
+ ## v1.0.4 - 4 May, 2012 (9bce25c1)
56
+
57
+ * Added Travis CI support.
58
+ * Added Gemnasium support.
59
+ * Fixes to usage of Shoulda and Hashie libraries.
60
+
61
+ ## v1.0.3 - 3 Dec, 2011 (1ed2b56a)
62
+
63
+ * Fixes to support Ruby 1.9.* (both the library as well as the rake tasks).
64
+ * Fixed the User-Agent header so that it now uses the correct module VERSION.
65
+
66
+ ## v1.0.2 - 31 Oct, 2011 (83020409)
67
+
68
+ * Added support for deleting a subscriber.
69
+ * Added support for specifying a 'clear' field when updating or importing
70
+ subscribers.
71
+ * Added support for queuing subscription-based autoresponders when importing
72
+ subscribers.
73
+ * Added support for retrieving deleted subscribers.
74
+ * Added support for including more social sharing stats in campaign summary.
75
+ * Added support for unscheduling a campaign.
76
+
77
+ ## v1.0.1 - 25 Oct, 2011 (347b2b95)
78
+
79
+ * Remove CreateSendOptions and remove usage of yaml config file.
80
+
81
+ ## v1.0.0 - 26 Sep, 2011 (0a078b09)
82
+
83
+ * Initial release which supports current Campaign Monitor API.
data/createsend.gemspec CHANGED
@@ -15,13 +15,13 @@ Gem::Specification.new do |s|
15
15
  s.add_runtime_dependency('httparty', '~> 0.8')
16
16
  s.name = "createsend"
17
17
  s.author = "James Dennes"
18
- s.description = %q{Implements the complete functionality of the createsend API.}
18
+ s.description = %q{Implements the complete functionality of the Campaign Monitor API.}
19
19
  s.email = ["jdennes@gmail.com"]
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.homepage = "http://campaignmonitor.github.com/createsend-ruby/"
23
23
  s.require_paths = ["lib"]
24
- s.summary = %q{A library which implements the complete functionality of v3 of the createsend API.}
24
+ s.summary = %q{A library which implements the complete functionality of the Campaign Monitor API.}
25
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
26
  s.version = CreateSend::VERSION
27
27
  s.platform = Gem::Platform::RUBY
@@ -11,6 +11,21 @@ module CreateSend
11
11
  end
12
12
 
13
13
  # Creates a new campaign for a client.
14
+ # client_id - String representing the ID of the client for whom the
15
+ # campaign will be created.
16
+ # subject - String representing the subject of the campaign.
17
+ # name - String representing the name of the campaign.
18
+ # from_name - String representing the from name for the campaign.
19
+ # from_email - String representing the from address for the campaign.
20
+ # reply_to - String representing the reply-to address for the campaign.
21
+ # html_url - String representing the URL for the campaign HTML content.
22
+ # text_url - String representing the URL for the campaign text content.
23
+ # Note that text_url is optional and if nil or an empty string, text
24
+ # content will be automatically generated from the HTML content.
25
+ # list_ids - Array of Strings representing the IDs of the lists to
26
+ # which the campaign will be sent.
27
+ # segment_ids - Array of Strings representing the IDs of the segments to
28
+ # which the campaign will be sent.
14
29
  def self.create(client_id, subject, name, from_name, from_email,
15
30
  reply_to, html_url, text_url, list_ids, segment_ids)
16
31
  options = { :body => {
@@ -28,6 +43,23 @@ module CreateSend
28
43
  end
29
44
 
30
45
  # Creates a new campaign for a client, from a template.
46
+ # client_id - String representing the ID of the client for whom the
47
+ # campaign will be created.
48
+ # subject - String representing the subject of the campaign.
49
+ # name - String representing the name of the campaign.
50
+ # from_name - String representing the from name for the campaign.
51
+ # from_email - String representing the from address for the campaign.
52
+ # reply_to - String representing the reply-to address for the campaign.
53
+ # list_ids - Array of Strings representing the IDs of the lists to
54
+ # which the campaign will be sent.
55
+ # segment_ids - Array of Strings representing the IDs of the segments to
56
+ # which the campaign will be sent.
57
+ # template_id - String representing the ID of the template on which
58
+ # the campaign will be based.
59
+ # template_content - Hash representing the content to be used for the
60
+ # editable areas of the template. See documentation at
61
+ # campaignmonitor.com/api/campaigns/#creating_a_campaign_from_template
62
+ # for full details of template content format.
31
63
  def self.create_from_template(client_id, subject, name, from_name,
32
64
  from_email, reply_to, list_ids, segment_ids, template_id,
33
65
  template_content)
@@ -80,6 +112,12 @@ module CreateSend
80
112
  Hashie::Mash.new(response)
81
113
  end
82
114
 
115
+ # Gets the email clients that subscribers used to open the campaign
116
+ def email_client_usage
117
+ response = get "emailclientusage", {}
118
+ response.map{|item| Hashie::Mash.new(item)}
119
+ end
120
+
83
121
  # Retrieves the lists and segments to which this campaaign will
84
122
  # be (or was) sent.
85
123
  def lists_and_segments
@@ -138,6 +176,19 @@ module CreateSend
138
176
  Hashie::Mash.new(response)
139
177
  end
140
178
 
179
+ # Retrieves the spam complaints for this campaign.
180
+ def spam(date, page=1, page_size=1000, order_field="date",
181
+ order_direction="asc")
182
+ options = { :query => {
183
+ :date => date,
184
+ :page => page,
185
+ :pagesize => page_size,
186
+ :orderfield => order_field,
187
+ :orderdirection => order_direction } }
188
+ response = get "spam", options
189
+ Hashie::Mash.new(response)
190
+ end
191
+
141
192
  # Retrieves the bounces for this campaign.
142
193
  def bounces(date="1900-01-01", page=1, page_size=1000, order_field="date",
143
194
  order_direction="asc")
@@ -93,6 +93,14 @@ module CreateSend
93
93
  Hashie::Mash.new(response)
94
94
  end
95
95
 
96
+ # Adds email addresses to a client's suppression list
97
+ def suppress(emails)
98
+ options = { :body => {
99
+ :EmailAddresses => emails.kind_of?(String) ?
100
+ [ emails ] : emails }.to_json }
101
+ response = post "suppress", options
102
+ end
103
+
96
104
  # Unsuppresses an email address by removing it from the the client's
97
105
  # suppression list
98
106
  def unsuppress(email)
@@ -41,15 +41,40 @@ module CreateSend
41
41
  end
42
42
 
43
43
  # Creates a new custom field for this list.
44
- def create_custom_field(field_name, data_type, options=[])
44
+ # field_name - String representing the name to be given to the field
45
+ # data_type - String representing the data type of the field. Valid data
46
+ # types are 'Text', 'Number', 'MultiSelectOne', 'MultiSelectMany',
47
+ # 'Date', 'Country', and 'USState'.
48
+ # options - Array of Strings representing the options for the field if it
49
+ # is of type 'MultiSelectOne' or 'MultiSelectMany'.
50
+ # visible_in_preference_center - Boolean indicating whether or not the
51
+ # field should be visible in the subscriber preference center
52
+ def create_custom_field(field_name, data_type, options=[],
53
+ visible_in_preference_center=true)
45
54
  options = { :body => {
46
55
  :FieldName => field_name,
47
56
  :DataType => data_type,
48
- :Options => options }.to_json }
57
+ :Options => options,
58
+ :VisibleInPreferenceCenter => visible_in_preference_center }.to_json }
49
59
  response = post "customfields", options
50
60
  response.parsed_response
51
61
  end
52
62
 
63
+ # Updates a custom field belonging to this list.
64
+ # custom_field_key - String which represents the key for the custom field
65
+ # field_name - String representing the name to be given to the field
66
+ # visible_in_preference_center - Boolean indicating whether or not the
67
+ # field should be visible in the subscriber preference center
68
+ def update_custom_field(custom_field_key, field_name,
69
+ visible_in_preference_center)
70
+ custom_field_key = CGI.escape(custom_field_key)
71
+ options = { :body => {
72
+ :FieldName => field_name,
73
+ :VisibleInPreferenceCenter => visible_in_preference_center }.to_json }
74
+ response = put "customfields/#{custom_field_key}", options
75
+ response.parsed_response
76
+ end
77
+
53
78
  # Deletes a custom field associated with this list.
54
79
  def delete_custom_field(custom_field_key)
55
80
  custom_field_key = CGI.escape(custom_field_key)
@@ -104,6 +129,19 @@ module CreateSend
104
129
  Hashie::Mash.new(response)
105
130
  end
106
131
 
132
+ # Gets the unconfirmed subscribers for this list.
133
+ def unconfirmed(date, page=1, page_size=1000, order_field="email",
134
+ order_direction="asc")
135
+ options = { :query => {
136
+ :date => date,
137
+ :page => page,
138
+ :pagesize => page_size,
139
+ :orderfield => order_field,
140
+ :orderdirection => order_direction } }
141
+ response = get "unconfirmed", options
142
+ Hashie::Mash.new(response)
143
+ end
144
+
107
145
  # Gets the bounced subscribers for this list.
108
146
  def bounced(date, page=1, page_size=1000, order_field="email",
109
147
  order_direction="asc")
@@ -1,3 +1,3 @@
1
1
  module CreateSend
2
- VERSION = "2.3.0" unless defined?(CreateSend::VERSION)
2
+ VERSION = "2.4.0" unless defined?(CreateSend::VERSION)
3
3
  end
@@ -14,6 +14,19 @@ class CampaignTest < Test::Unit::TestCase
14
14
  campaign_id = CreateSend::Campaign.create client_id, "subject", "name", "g'day", "good.day@example.com", "good.day@example.com",
15
15
  "http://example.com/campaign.html", "http://example.com/campaign.txt", [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
16
16
  [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
17
+ request = FakeWeb.last_request.body
18
+ request.include?("\"TextUrl\":\"http://example.com/campaign.txt\"").should == true
19
+ campaign_id.should == "787y87y87y87y87y87y87"
20
+ end
21
+
22
+ should "create a campaign with a nil text_url param" do
23
+ client_id = '87y8d7qyw8d7yq8w7ydwqwd'
24
+ stub_post(@api_key, "campaigns/#{client_id}.json", "create_campaign.json")
25
+ campaign_id = CreateSend::Campaign.create client_id, "subject", "name", "g'day", "good.day@example.com", "good.day@example.com",
26
+ "http://example.com/campaign.html", nil, [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
27
+ [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
28
+ request = FakeWeb.last_request.body
29
+ request.include?("\"TextUrl\":null").should == true
17
30
  campaign_id.should == "787y87y87y87y87y87y87"
18
31
  end
19
32
 
@@ -22,7 +35,6 @@ class CampaignTest < Test::Unit::TestCase
22
35
  :Singlelines => [
23
36
  {
24
37
  :Content => "This is a heading",
25
- :Alt => "This is alt text",
26
38
  :Href => "http://example.com/"
27
39
  }
28
40
  ],
@@ -99,7 +111,12 @@ class CampaignTest < Test::Unit::TestCase
99
111
  campaign_id.should == "787y87y87y87y87y87y87"
100
112
  end
101
113
 
102
- should "send a preview of a draft campaign" do
114
+ should "send a preview of a draft campaign to a single recipient" do
115
+ stub_post(@api_key, "campaigns/#{@campaign.campaign_id}/sendpreview.json", nil)
116
+ @campaign.send_preview "test+89898u9@example.com", "random"
117
+ end
118
+
119
+ should "send a preview of a draft campaign to multiple recipients" do
103
120
  stub_post(@api_key, "campaigns/#{@campaign.campaign_id}/sendpreview.json", nil)
104
121
  @campaign.send_preview [ "test+89898u9@example.com", "test+787y8y7y8@example.com" ], "random"
105
122
  end
@@ -133,8 +150,19 @@ class CampaignTest < Test::Unit::TestCase
133
150
  summary.Likes.should == 32
134
151
  summary.WebVersionURL.should == "http://createsend.com/t/r-3A433FC72FFE3B8B"
135
152
  summary.WorldviewURL.should == "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
153
+ summary.SpamComplaints.should == 23
136
154
  end
137
-
155
+
156
+ should "get the email client usage for a campaign" do
157
+ stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/emailclientusage.json", "email_client_usage.json")
158
+ ecu = @campaign.email_client_usage
159
+ ecu.size.should == 6
160
+ ecu.first.Client.should == "iOS Devices"
161
+ ecu.first.Version.should == "iPhone"
162
+ ecu.first.Percentage.should == 19.83
163
+ ecu.first.Subscribers.should == 7056
164
+ end
165
+
138
166
  should "get the lists and segments for a campaign" do
139
167
  stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/listsandsegments.json", "campaign_listsandsegments.json")
140
168
  ls = @campaign.lists_and_segments
@@ -229,6 +257,23 @@ class CampaignTest < Test::Unit::TestCase
229
257
  unsubscribes.NumberOfPages.should == 1
230
258
  end
231
259
 
260
+ should "get the spam complaints for a campaign" do
261
+ min_date = "2010-01-01"
262
+ stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/spam.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_spam.json")
263
+ spam = @campaign.spam min_date
264
+ spam.Results.size.should == 1
265
+ spam.Results.first.EmailAddress.should == "subs+6576576576@example.com"
266
+ spam.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
267
+ spam.Results.first.Date.should == "2010-10-11 08:29:00"
268
+ spam.ResultsOrderedBy.should == "date"
269
+ spam.OrderDirection.should == "asc"
270
+ spam.PageNumber.should == 1
271
+ spam.PageSize.should == 1000
272
+ spam.RecordsOnThisPage.should == 1
273
+ spam.TotalNumberOfRecords.should == 1
274
+ spam.NumberOfPages.should == 1
275
+ end
276
+
232
277
  should "get the bounces for a campaign" do
233
278
  min_date = "2010-01-01"
234
279
  stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/bounces.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_bounces.json")
data/test/client_test.rb CHANGED
@@ -107,6 +107,17 @@ class ClientTest < Test::Unit::TestCase
107
107
  res.Results.first.State.should == "Suppressed"
108
108
  end
109
109
 
110
+ should "suppress a single email address" do
111
+ email = "example@example.com"
112
+ stub_post(@api_key, "clients/#{@client.client_id}/suppress.json", nil)
113
+ result = @client.suppress email
114
+ end
115
+
116
+ should "suppress multiple email address" do
117
+ stub_post(@api_key, "clients/#{@client.client_id}/suppress.json", nil)
118
+ result = @client.suppress [ "one@example.com", "two@example.com" ]
119
+ end
120
+
110
121
  should "unsuppress an email address" do
111
122
  email = "example@example.com"
112
123
  stub_put(@api_key, "clients/#{@client.client_id}/unsuppress.json?email=#{CGI.escape(email)}", nil)
@@ -26,7 +26,8 @@
26
26
  "Key": "subscription date",
27
27
  "Value": "2010-03-09"
28
28
  }
29
- ]
29
+ ],
30
+ "ReadsEmailWith": "Gmail"
30
31
  },
31
32
  {
32
33
  "EmailAddress": "subs+7878787y8ggg@example.com",
@@ -38,7 +39,8 @@
38
39
  "Key": "website",
39
40
  "Value": "http://subdomain.example.com"
40
41
  }
41
- ]
42
+ ],
43
+ "ReadsEmailWith": "Gmail"
42
44
  },
43
45
  {
44
46
  "EmailAddress": "subs+7890909i0ggg@example.com",
@@ -50,21 +52,24 @@
50
52
  "Key": "website",
51
53
  "Value": "http://subdomain.example.com"
52
54
  }
53
- ]
55
+ ],
56
+ "ReadsEmailWith": ""
54
57
  },
55
58
  {
56
59
  "EmailAddress": "subs@example.com",
57
60
  "Name": "Person Four",
58
61
  "Date": "2010-10-27 13:13:00",
59
62
  "State": "Active",
60
- "CustomFields": []
63
+ "CustomFields": [],
64
+ "ReadsEmailWith": ""
61
65
  },
62
66
  {
63
67
  "EmailAddress": "joey@example.com",
64
68
  "Name": "Person Five",
65
69
  "Date": "2010-10-27 13:13:00",
66
70
  "State": "Active",
67
- "CustomFields": []
71
+ "CustomFields": [],
72
+ "ReadsEmailWith": "Gmail"
68
73
  }
69
74
  ],
70
75
  "ResultsOrderedBy": "email",
@@ -5,7 +5,8 @@
5
5
  "Name": "Bounced One",
6
6
  "Date": "2010-10-25 13:11:00",
7
7
  "State": "Bounced",
8
- "CustomFields": []
8
+ "CustomFields": [],
9
+ "ReadsEmailWith": ""
9
10
  }
10
11
  ],
11
12
  "ResultsOrderedBy": "email",
@@ -0,0 +1,16 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "subs+6576576576@example.com",
5
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
6
+ "Date": "2010-10-11 08:29:00"
7
+ }
8
+ ],
9
+ "ResultsOrderedBy": "date",
10
+ "OrderDirection": "asc",
11
+ "PageNumber": 1,
12
+ "PageSize": 1000,
13
+ "RecordsOnThisPage": 1,
14
+ "TotalNumberOfRecords": 1,
15
+ "NumberOfPages": 1
16
+ }
@@ -9,5 +9,6 @@
9
9
  "Forwards": 11,
10
10
  "Likes": 32,
11
11
  "WebVersionURL": "http://createsend.com/t/r-3A433FC72FFE3B8B",
12
- "WorldviewURL": "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
12
+ "WorldviewURL": "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B",
13
+ "SpamComplaints": 23
13
14
  }
@@ -3,18 +3,21 @@
3
3
  "FieldName": "website",
4
4
  "Key": "[website]",
5
5
  "DataType": "Text",
6
- "FieldOptions": []
6
+ "FieldOptions": [],
7
+ "VisibleInPreferenceCenter": true
7
8
  },
8
9
  {
9
10
  "FieldName": "age",
10
11
  "Key": "[age]",
11
12
  "DataType": "Number",
12
- "FieldOptions": []
13
+ "FieldOptions": [],
14
+ "VisibleInPreferenceCenter": true
13
15
  },
14
16
  {
15
17
  "FieldName": "subscription date",
16
18
  "Key": "[subscriptiondate]",
17
19
  "DataType": "Date",
18
- "FieldOptions": []
20
+ "FieldOptions": [],
21
+ "VisibleInPreferenceCenter": false
19
22
  }
20
23
  ]
@@ -5,7 +5,8 @@
5
5
  "Name": "Deleted One",
6
6
  "Date": "2010-10-25 13:11:00",
7
7
  "State": "Deleted",
8
- "CustomFields": []
8
+ "CustomFields": [],
9
+ "ReadsEmailWith": "Gmail"
9
10
  },
10
11
  {
11
12
  "EmailAddress": "subscriberone@example.com",
@@ -17,28 +18,32 @@
17
18
  "Key": "website",
18
19
  "Value": "http://google.com"
19
20
  }
20
- ]
21
+ ],
22
+ "ReadsEmailWith": "Gmail"
21
23
  },
22
24
  {
23
25
  "EmailAddress": "example+1@example.com",
24
26
  "Name": "Example One",
25
27
  "Date": "2010-10-26 10:56:00",
26
28
  "State": "Deleted",
27
- "CustomFields": []
29
+ "CustomFields": [],
30
+ "ReadsEmailWith": ""
28
31
  },
29
32
  {
30
33
  "EmailAddress": "example+2@example.com",
31
34
  "Name": "Example Two",
32
35
  "Date": "2010-10-26 10:56:00",
33
36
  "State": "Deleted",
34
- "CustomFields": []
37
+ "CustomFields": [],
38
+ "ReadsEmailWith": ""
35
39
  },
36
40
  {
37
41
  "EmailAddress": "example+3@example.com",
38
42
  "Name": "Example Three",
39
43
  "Date": "2010-10-26 10:56:00",
40
44
  "State": "Deleted",
41
- "CustomFields": []
45
+ "CustomFields": [],
46
+ "ReadsEmailWith": "Gmail"
42
47
  }
43
48
  ],
44
49
  "ResultsOrderedBy": "email",
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "Client": "iOS Devices",
4
+ "Version": "iPhone",
5
+ "Percentage": 19.83,
6
+ "Subscribers": 7056
7
+ },
8
+ {
9
+ "Client": "Apple Mail",
10
+ "Version": "Apple Mail 6",
11
+ "Percentage": 13.02,
12
+ "Subscribers": 4633
13
+ },
14
+ {
15
+ "Client": "Apple Mail",
16
+ "Version": "Apple Mail 5",
17
+ "Percentage": 10.60,
18
+ "Subscribers": 3773
19
+ },
20
+ {
21
+ "Client": "Microsoft Outlook",
22
+ "Version": "Outlook 2010",
23
+ "Percentage": 7.18,
24
+ "Subscribers": 2556
25
+ },
26
+ {
27
+ "Client": "iOS Devices",
28
+ "Version": "iPad",
29
+ "Percentage": 4.43,
30
+ "Subscribers": 1577
31
+ },
32
+ {
33
+ "Client": "Undetectable",
34
+ "Version": "Undetectable",
35
+ "Percentage": 4.94,
36
+ "Subscribers": 1632
37
+ }
38
+ ]
@@ -16,5 +16,6 @@
16
16
  "Key": "subscription date",
17
17
  "Value": "2010-03-09"
18
18
  }
19
- ]
19
+ ],
20
+ "ReadsEmailWith": "Gmail"
20
21
  }
@@ -0,0 +1,37 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "subs+7t8787Y@example.com",
5
+ "Name": "Unconfirmed One",
6
+ "Date": "2010-10-25 10:28:00",
7
+ "State": "Unconfirmed",
8
+ "CustomFields": [
9
+ {
10
+ "Key": "website",
11
+ "Value": "http://example.com"
12
+ }
13
+ ],
14
+ "ReadsEmailWith": ""
15
+ },
16
+ {
17
+ "EmailAddress": "subs+7878787y8ggg@example.com",
18
+ "Name": "Unconfirmed Two",
19
+ "Date": "2010-10-25 12:17:00",
20
+ "State": "Unconfirmed",
21
+ "CustomFields": [
22
+ {
23
+ "Key": "website",
24
+ "Value": "http://subdomain.example.com"
25
+ }
26
+ ],
27
+ "ReadsEmailWith": ""
28
+ }
29
+ ],
30
+ "ResultsOrderedBy": "email",
31
+ "OrderDirection": "asc",
32
+ "PageNumber": 1,
33
+ "PageSize": 1000,
34
+ "RecordsOnThisPage": 2,
35
+ "TotalNumberOfRecords": 2,
36
+ "NumberOfPages": 1
37
+ }
@@ -5,7 +5,8 @@
5
5
  "Name": "Unsub One",
6
6
  "Date": "2010-10-25 13:11:00",
7
7
  "State": "Unsubscribed",
8
- "CustomFields": []
8
+ "CustomFields": [],
9
+ "ReadsEmailWith": "Gmail"
9
10
  },
10
11
  {
11
12
  "EmailAddress": "subscriberone@example.com",
@@ -17,28 +18,32 @@
17
18
  "Key": "website",
18
19
  "Value": "http://google.com"
19
20
  }
20
- ]
21
+ ],
22
+ "ReadsEmailWith": "Gmail"
21
23
  },
22
24
  {
23
25
  "EmailAddress": "example+1@example.com",
24
26
  "Name": "Example One",
25
27
  "Date": "2010-10-26 10:56:00",
26
28
  "State": "Unsubscribed",
27
- "CustomFields": []
29
+ "CustomFields": [],
30
+ "ReadsEmailWith": ""
28
31
  },
29
32
  {
30
33
  "EmailAddress": "example+2@example.com",
31
34
  "Name": "Example Two",
32
35
  "Date": "2010-10-26 10:56:00",
33
36
  "State": "Unsubscribed",
34
- "CustomFields": []
37
+ "CustomFields": [],
38
+ "ReadsEmailWith": ""
35
39
  },
36
40
  {
37
41
  "EmailAddress": "example+3@example.com",
38
42
  "Name": "Example Three",
39
43
  "Date": "2010-10-26 10:56:00",
40
44
  "State": "Unsubscribed",
41
- "CustomFields": []
45
+ "CustomFields": [],
46
+ "ReadsEmailWith": "Gmail"
42
47
  }
43
48
  ],
44
49
  "ResultsOrderedBy": "email",
@@ -0,0 +1 @@
1
+ "[myrenamedcustomfield]"
data/test/list_test.rb CHANGED
@@ -45,9 +45,37 @@ class ListTest < Test::Unit::TestCase
45
45
  should "create a custom field" do
46
46
  stub_post(@api_key, "lists/#{@list.list_id}/customfields.json", "create_custom_field.json")
47
47
  personalisation_tag = @list.create_custom_field "new date field", "Date"
48
+ request = FakeWeb.last_request.body
49
+ request.include?("\"FieldName\":\"new date field\"").should == true
50
+ request.include?("\"DataType\":\"Date\"").should == true
51
+ request.include?("\"Options\":[]").should == true
52
+ request.include?("\"VisibleInPreferenceCenter\":true").should == true
48
53
  personalisation_tag.should == "[newdatefield]"
49
54
  end
50
55
 
56
+ should "create a custom field with options and visible_in_preference_center" do
57
+ stub_post(@api_key, "lists/#{@list.list_id}/customfields.json", "create_custom_field.json")
58
+ options = ["one", "two"]
59
+ personalisation_tag = @list.create_custom_field("newsletter format",
60
+ "MultiSelectOne", options, false)
61
+ request = FakeWeb.last_request.body
62
+ request.include?("\"FieldName\":\"newsletter format\"").should == true
63
+ request.include?("\"DataType\":\"MultiSelectOne\"").should == true
64
+ request.include?("\"Options\":[\"one\",\"two\"]").should == true
65
+ request.include?("\"VisibleInPreferenceCenter\":false").should == true
66
+ personalisation_tag.should == "[newdatefield]"
67
+ end
68
+
69
+ should "update a custom field" do
70
+ key = "[mycustomfield]"
71
+ stub_put(@api_key, "lists/#{@list.list_id}/customfields/#{CGI.escape(key)}.json", "update_custom_field.json")
72
+ personalisation_tag = @list.update_custom_field key, "my renamed custom field", true
73
+ request = FakeWeb.last_request.body
74
+ request.include?("\"FieldName\":\"my renamed custom field\"").should == true
75
+ request.include?("\"VisibleInPreferenceCenter\":true").should == true
76
+ personalisation_tag.should == "[myrenamedcustomfield]"
77
+ end
78
+
51
79
  should "delete a custom field" do
52
80
  custom_field_key = "[newdatefield]"
53
81
  stub_delete(@api_key, "lists/#{@list.list_id}/customfields/#{CGI.escape(custom_field_key)}.json", nil)
@@ -80,6 +108,7 @@ class ListTest < Test::Unit::TestCase
80
108
  cfs.first.Key.should == "[website]"
81
109
  cfs.first.DataType.should == "Text"
82
110
  cfs.first.FieldOptions.should == []
111
+ cfs.first.VisibleInPreferenceCenter.should == true
83
112
  end
84
113
 
85
114
  should "get the segments for a list" do
@@ -124,8 +153,27 @@ class ListTest < Test::Unit::TestCase
124
153
  res.Results.first.CustomFields[1].Value.should == "option one"
125
154
  res.Results.first.CustomFields[2].Key.should == "multi select field"
126
155
  res.Results.first.CustomFields[2].Value.should == "option two"
156
+ res.Results.first.ReadsEmailWith.should == "Gmail"
127
157
  end
128
-
158
+
159
+ should "get the unconfirmed subscribers for a list" do
160
+ min_date = "2010-01-01"
161
+ stub_get(@api_key, "lists/#{@list.list_id}/unconfirmed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
162
+ "unconfirmed_subscribers.json")
163
+ res = @list.unconfirmed min_date
164
+ res.ResultsOrderedBy.should == "email"
165
+ res.OrderDirection.should == "asc"
166
+ res.PageNumber.should == 1
167
+ res.PageSize.should == 1000
168
+ res.RecordsOnThisPage.should == 2
169
+ res.TotalNumberOfRecords.should == 2
170
+ res.NumberOfPages.should == 1
171
+ res.Results.size.should == 2
172
+ res.Results.first.EmailAddress.should == "subs+7t8787Y@example.com"
173
+ res.Results.first.Name.should =="Unconfirmed One"
174
+ res.Results.first.State.should == "Unconfirmed"
175
+ end
176
+
129
177
  should "get the unsubscribed subscribers for a list" do
130
178
  min_date = "2010-01-01"
131
179
  stub_get(@api_key, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
@@ -144,6 +192,7 @@ class ListTest < Test::Unit::TestCase
144
192
  res.Results.first.Date.should == "2010-10-25 13:11:00"
145
193
  res.Results.first.State.should == "Unsubscribed"
146
194
  res.Results.first.CustomFields.size.should == 0
195
+ res.Results.first.ReadsEmailWith.should == "Gmail"
147
196
  end
148
197
 
149
198
  should "get the deleted subscribers for a list" do
@@ -164,6 +213,7 @@ class ListTest < Test::Unit::TestCase
164
213
  res.Results.first.Date.should == "2010-10-25 13:11:00"
165
214
  res.Results.first.State.should == "Deleted"
166
215
  res.Results.first.CustomFields.size.should == 0
216
+ res.Results.first.ReadsEmailWith.should == "Gmail"
167
217
  end
168
218
 
169
219
  should "get the bounced subscribers for a list" do
@@ -184,6 +234,7 @@ class ListTest < Test::Unit::TestCase
184
234
  res.Results.first.Date.should == "2010-10-25 13:11:00"
185
235
  res.Results.first.State.should == "Bounced"
186
236
  res.Results.first.CustomFields.size.should == 0
237
+ res.Results.first.ReadsEmailWith.should == ""
187
238
  end
188
239
 
189
240
  should "get the webhooks for a list" do
@@ -20,6 +20,7 @@ class SubscriberTest < Test::Unit::TestCase
20
20
  subscriber.CustomFields.size.should == 3
21
21
  subscriber.CustomFields.first.Key.should == 'website'
22
22
  subscriber.CustomFields.first.Value.should == 'http://example.com'
23
+ subscriber.ReadsEmailWith.should == "Gmail"
23
24
  end
24
25
 
25
26
  should "add a subscriber without custom fields" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: createsend
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2012-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70321789088920 !ruby/object:Gem::Requirement
16
+ requirement: &70098807897300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70321789088920
24
+ version_requirements: *70098807897300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fakeweb
27
- requirement: &70321789088160 !ruby/object:Gem::Requirement
27
+ requirement: &70098807896180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.3'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70321789088160
35
+ version_requirements: *70098807896180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jnunemaker-matchy
38
- requirement: &70321789084600 !ruby/object:Gem::Requirement
38
+ requirement: &70098807915080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.4'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70321789084600
46
+ version_requirements: *70098807915080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &70321789096560 !ruby/object:Gem::Requirement
49
+ requirement: &70098807914240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.9'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70321789096560
57
+ version_requirements: *70098807914240
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &70321789092060 !ruby/object:Gem::Requirement
60
+ requirement: &70098807913600 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.3.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70321789092060
68
+ version_requirements: *70098807913600
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: cane
71
- requirement: &70321789105720 !ruby/object:Gem::Requirement
71
+ requirement: &70098807912660 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70321789105720
79
+ version_requirements: *70098807912660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: json
82
- requirement: &70321789104280 !ruby/object:Gem::Requirement
82
+ requirement: &70098807911800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70321789104280
90
+ version_requirements: *70098807911800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: hashie
93
- requirement: &70321789103040 !ruby/object:Gem::Requirement
93
+ requirement: &70098807911160 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '1.0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70321789103040
101
+ version_requirements: *70098807911160
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: httparty
104
- requirement: &70321789101200 !ruby/object:Gem::Requirement
104
+ requirement: &70098807910060 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,8 +109,8 @@ dependencies:
109
109
  version: '0.8'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70321789101200
113
- description: Implements the complete functionality of the createsend API.
112
+ version_requirements: *70098807910060
113
+ description: Implements the complete functionality of the Campaign Monitor API.
114
114
  email:
115
115
  - jdennes@gmail.com
116
116
  executables: []
@@ -121,6 +121,7 @@ files:
121
121
  - .travis.yml
122
122
  - Gemfile
123
123
  - Gemfile.lock
124
+ - HISTORY.md
124
125
  - LICENSE
125
126
  - README.md
126
127
  - Rakefile
@@ -154,6 +155,7 @@ files:
154
155
  - test/fixtures/campaign_listsandsegments.json
155
156
  - test/fixtures/campaign_opens.json
156
157
  - test/fixtures/campaign_recipients.json
158
+ - test/fixtures/campaign_spam.json
157
159
  - test/fixtures/campaign_summary.json
158
160
  - test/fixtures/campaign_unsubscribes.json
159
161
  - test/fixtures/campaigns.json
@@ -173,6 +175,7 @@ files:
173
175
  - test/fixtures/custom_fields.json
174
176
  - test/fixtures/deleted_subscribers.json
175
177
  - test/fixtures/drafts.json
178
+ - test/fixtures/email_client_usage.json
176
179
  - test/fixtures/import_subscribers.json
177
180
  - test/fixtures/import_subscribers_partial_success.json
178
181
  - test/fixtures/list_details.json
@@ -193,7 +196,9 @@ files:
193
196
  - test/fixtures/template_details.json
194
197
  - test/fixtures/templates.json
195
198
  - test/fixtures/timezones.json
199
+ - test/fixtures/unconfirmed_subscribers.json
196
200
  - test/fixtures/unsubscribed_subscribers.json
201
+ - test/fixtures/update_custom_field.json
197
202
  - test/helper.rb
198
203
  - test/list_test.rb
199
204
  - test/person_test.rb
@@ -212,9 +217,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
217
  - - ! '>='
213
218
  - !ruby/object:Gem::Version
214
219
  version: '0'
215
- segments:
216
- - 0
217
- hash: 3175201096736061315
218
220
  required_rubygems_version: !ruby/object:Gem::Requirement
219
221
  none: false
220
222
  requirements:
@@ -226,7 +228,7 @@ rubyforge_project:
226
228
  rubygems_version: 1.8.15
227
229
  signing_key:
228
230
  specification_version: 3
229
- summary: A library which implements the complete functionality of v3 of the createsend
231
+ summary: A library which implements the complete functionality of the Campaign Monitor
230
232
  API.
231
233
  test_files:
232
234
  - test/administrator_test.rb
@@ -248,6 +250,7 @@ test_files:
248
250
  - test/fixtures/campaign_listsandsegments.json
249
251
  - test/fixtures/campaign_opens.json
250
252
  - test/fixtures/campaign_recipients.json
253
+ - test/fixtures/campaign_spam.json
251
254
  - test/fixtures/campaign_summary.json
252
255
  - test/fixtures/campaign_unsubscribes.json
253
256
  - test/fixtures/campaigns.json
@@ -267,6 +270,7 @@ test_files:
267
270
  - test/fixtures/custom_fields.json
268
271
  - test/fixtures/deleted_subscribers.json
269
272
  - test/fixtures/drafts.json
273
+ - test/fixtures/email_client_usage.json
270
274
  - test/fixtures/import_subscribers.json
271
275
  - test/fixtures/import_subscribers_partial_success.json
272
276
  - test/fixtures/list_details.json
@@ -287,7 +291,9 @@ test_files:
287
291
  - test/fixtures/template_details.json
288
292
  - test/fixtures/templates.json
289
293
  - test/fixtures/timezones.json
294
+ - test/fixtures/unconfirmed_subscribers.json
290
295
  - test/fixtures/unsubscribed_subscribers.json
296
+ - test/fixtures/update_custom_field.json
291
297
  - test/helper.rb
292
298
  - test/list_test.rb
293
299
  - test/person_test.rb