createsend 6.0.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b2bb4cff071610599c8016946954e43a06069153feacda42c1ed0ec3f358e06
4
- data.tar.gz: f3a2e2b67d20cc392b04b469a15b6d97ee1a7af65b9e5245a4d262047863164d
3
+ metadata.gz: 6f3f52a5b4e7e7f22990a722f419a720a832de253aa12e7df6bc0f108f9bd90c
4
+ data.tar.gz: 0e6977d50918dc9ecac114644fb30842603644c745eea1fe93ddb9237fe202d1
5
5
  SHA512:
6
- metadata.gz: 229d9c032d55f82c23fed36742e5186eb7e2e4c590e5b8acf9f9463aba53241b41ba31dd5be1ca342556876f0b5f1b69c52a54bff8b161c4018b1611e2145baa
7
- data.tar.gz: 945dc9bc23760e17d1f4a47e155d3cb356e7539e61e0109f3c0324375cc2f05d2bc1224cfcdb382dfa745a2d667a2ead5b8897962de3e0f7504196baf92e065e
6
+ metadata.gz: cb9f82623a9e5c3cea4ee80891e6bb4ab158c303a59c025eee8d8f349919ed420def2b98884ba59e17b33668119f5d642cfdf99039ea9fa4eba4e4ef79140c5c
7
+ data.tar.gz: d397f0724a5e5b6428482e717eb225738c6bc03bb9a987ddd58dc9c4ad58cefff95274c42ac12ff682433d8aefdee1bfecdad9d53c5dbc3f4f380421be3573d8
data/HISTORY.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # createsend-ruby history
2
2
 
3
+ ## v6.1.1 - 20 Aug 2024
4
+ * Merged support for error code 429 (rate limiting on subscribers update)
5
+ * Merged gemspec required ruby version to `>= 2.0`
6
+ * Merged `hashie` dependency to `>= 3`, `< 6`
7
+
8
+ ## v6.1.0 - 27 Oct 2023
9
+ * Added support for add/update subscribers specifying mobile_number and/or consent_to_send_sms (optional parameters)
10
+ * Subscriber.Add
11
+ * Subscriber.Update()
12
+ * Added support for lists endpoints to be able to return the ConsentToSendSms (keyword parameter, is optional)
13
+ * List.Active(include_sms_preference:true)
14
+ * List.Bounced(include_sms_preference:true)
15
+ * List.Unsubscribed(include_sms_preference:true)
16
+ * List.Unconfirmed(include_sms_preference:true)
17
+ * List.Deleted(include_sms_preference:true)
18
+ * Clean-up various warnings associated with this package (excluding dependency package warning)
19
+ * Add more samples
20
+
3
21
  ## v6.0.0 - 10 Feb, 2022
4
22
  * Upgrades to Createsend API v3.3 which includes new breaking changes
5
23
  * Breaking: 'client.campaigns' now returned an object to support pagination (use .Results to ge the array of campaigns)
data/README.md CHANGED
@@ -194,7 +194,7 @@ should "add a subscriber with custom fields" do
194
194
  stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
195
195
  custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
196
196
  email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
197
- email_address.should == "subscriber@example.com"
197
+ email_address.should be == "subscriber@example.com"
198
198
  end
199
199
  ```
200
200
 
data/createsend.gemspec CHANGED
@@ -5,7 +5,7 @@ require File.expand_path('lib/createsend/version')
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.add_runtime_dependency 'json', '>= 1.0'
8
- s.add_runtime_dependency 'hashie', '~> 3.0'
8
+ s.add_runtime_dependency 'hashie', '>= 3.0', '< 6'
9
9
  s.add_runtime_dependency 'httparty', '~> 0.14'
10
10
  s.add_development_dependency 'rake', '~> 12.3.3'
11
11
  s.add_development_dependency 'fakeweb', '~> 1.3'
@@ -27,5 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.version = CreateSend::VERSION
28
28
  s.platform = Gem::Platform::RUBY
29
29
  s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
30
+ s.required_ruby_version = ">=2.0"
30
31
  s.licenses = ['MIT']
31
32
  end
@@ -30,6 +30,8 @@ module CreateSend
30
30
  class Unauthorized < CreateSendError; end
31
31
  # Raised for HTTP response code of 404
32
32
  class NotFound < ClientError; end
33
+ # Raised for HTTP response code of 429
34
+ class TooManyRequests < ClientError; end
33
35
 
34
36
  # Raised for HTTP response code of 401, specifically when an OAuth token
35
37
  # in invalid (Code: 120, Message: 'Invalid OAuth Token')
@@ -279,6 +281,8 @@ module CreateSend
279
281
  end
280
282
  when 404
281
283
  raise NotFound.new
284
+ when 429
285
+ raise TooManyRequests.new
282
286
  when 400...500
283
287
  raise ClientError.new
284
288
  when 500...600
@@ -116,37 +116,37 @@ module CreateSend
116
116
 
117
117
  # Gets the active subscribers for this list.
118
118
  def active(date="", page=1, page_size=1000, order_field="email",
119
- order_direction="asc", include_tracking_preference=false)
119
+ order_direction="asc", include_tracking_preference=false, include_sms_preference:false)
120
120
  paged_result_by_date("active", date, page, page_size, order_field,
121
- order_direction, include_tracking_preference)
121
+ order_direction, include_tracking_preference, include_sms_preference)
122
122
  end
123
123
 
124
124
  # Gets the unconfirmed subscribers for this list.
125
125
  def unconfirmed(date="", page=1, page_size=1000, order_field="email",
126
- order_direction="asc", include_tracking_preference=false)
126
+ order_direction="asc", include_tracking_preference=false, include_sms_preference:false)
127
127
  paged_result_by_date("unconfirmed", date, page, page_size, order_field,
128
- order_direction, include_tracking_preference)
128
+ order_direction, include_tracking_preference, include_sms_preference)
129
129
  end
130
130
 
131
131
  # Gets the bounced subscribers for this list.
132
132
  def bounced(date="", page=1, page_size=1000, order_field="email",
133
- order_direction="asc", include_tracking_preference=false)
133
+ order_direction="asc", include_tracking_preference=false, include_sms_preference:false)
134
134
  paged_result_by_date("bounced", date, page, page_size, order_field,
135
- order_direction, include_tracking_preference)
135
+ order_direction, include_tracking_preference, include_sms_preference)
136
136
  end
137
137
 
138
138
  # Gets the unsubscribed subscribers for this list.
139
139
  def unsubscribed(date="", page=1, page_size=1000, order_field="email",
140
- order_direction="asc", include_tracking_preference=false)
140
+ order_direction="asc", include_tracking_preference=false, include_sms_preference:false)
141
141
  paged_result_by_date("unsubscribed", date, page, page_size, order_field,
142
- order_direction, include_tracking_preference)
142
+ order_direction, include_tracking_preference, include_sms_preference)
143
143
  end
144
144
 
145
145
  # Gets the deleted subscribers for this list.
146
146
  def deleted(date="", page=1, page_size=1000, order_field="email",
147
- order_direction="asc", include_tracking_preference=false)
147
+ order_direction="asc", include_tracking_preference=false, include_sms_preference:false)
148
148
  paged_result_by_date("deleted", date, page, page_size, order_field,
149
- order_direction, include_tracking_preference)
149
+ order_direction, include_tracking_preference, include_sms_preference)
150
150
  end
151
151
 
152
152
  # Updates this list.
@@ -225,14 +225,15 @@ module CreateSend
225
225
  private
226
226
 
227
227
  def paged_result_by_date(resource, date, page, page_size, order_field,
228
- order_direction, include_tracking_preference)
228
+ order_direction, include_tracking_preference, include_sms_preference)
229
229
  options = { :query => {
230
230
  :date => date,
231
231
  :page => page,
232
232
  :pagesize => page_size,
233
233
  :orderfield => order_field,
234
234
  :orderdirection => order_direction,
235
- :includetrackingpreference => include_tracking_preference } }
235
+ :includetrackingpreference => include_tracking_preference,
236
+ :includesmspreference => include_sms_preference} }
236
237
  response = get resource, options
237
238
  Hashie::Mash.new(response)
238
239
  end
@@ -23,15 +23,17 @@ module CreateSend
23
23
 
24
24
  # Adds a subscriber to a subscriber list.
25
25
  def self.add(auth, list_id, email_address, name, custom_fields, resubscribe,
26
- consent_to_track, restart_subscription_based_autoresponders=false)
26
+ consent_to_track, restart_subscription_based_autoresponders=false, mobile_number=nil, consent_to_send_sms=nil)
27
27
  options = { :body => {
28
28
  :EmailAddress => email_address,
29
29
  :Name => name,
30
+ :MobileNumber => mobile_number,
30
31
  :CustomFields => custom_fields,
31
32
  :Resubscribe => resubscribe,
32
33
  :RestartSubscriptionBasedAutoresponders =>
33
34
  restart_subscription_based_autoresponders,
34
- :ConsentToTrack => consent_to_track }.to_json }
35
+ :ConsentToTrack => consent_to_track,
36
+ :ConsentToSendSms => consent_to_send_sms }.to_json }
35
37
  cs = CreateSend.new auth
36
38
  response = cs.post "/subscribers/#{list_id}.json", options
37
39
  response.parsed_response
@@ -70,17 +72,19 @@ module CreateSend
70
72
  # Updates any aspect of a subscriber, including email address, name, and
71
73
  # custom field data if supplied.
72
74
  def update(new_email_address, name, custom_fields, resubscribe,
73
- consent_to_track, restart_subscription_based_autoresponders=false)
75
+ consent_to_track, restart_subscription_based_autoresponders=false, mobile_number=nil, consent_to_send_sms=nil)
74
76
  options = {
75
77
  :query => { :email => @email_address },
76
78
  :body => {
77
79
  :EmailAddress => new_email_address,
78
80
  :Name => name,
81
+ :MobileNumber => mobile_number,
79
82
  :CustomFields => custom_fields,
80
83
  :Resubscribe => resubscribe,
81
84
  :RestartSubscriptionBasedAutoresponders =>
82
85
  restart_subscription_based_autoresponders,
83
- :ConsentToTrack => consent_to_track }.to_json }
86
+ :ConsentToTrack => consent_to_track,
87
+ :ConsentToSendSms => consent_to_send_sms }.to_json }
84
88
  put "/subscribers/#{@list_id}.json", options
85
89
  # Update @email_address, so this object can continue to be used reliably
86
90
  @email_address = new_email_address
@@ -1,3 +1,3 @@
1
1
  module CreateSend
2
- VERSION = "6.0.0" unless defined?(CreateSend::VERSION)
2
+ VERSION = "6.1.1" unless defined?(CreateSend::VERSION)
3
3
  end
@@ -12,7 +12,11 @@ class ListsSample
12
12
  end
13
13
 
14
14
  def get_active_subscribers
15
- @list.active
15
+ @list.active()
16
+ end
17
+
18
+ def get_active_with_sms_preference_subscribers
19
+ @list.active(include_sms_preference:true)
16
20
  end
17
21
 
18
22
  def get_bounced_subscribers
@@ -23,6 +27,10 @@ class ListsSample
23
27
  @list.unsubscribed
24
28
  end
25
29
 
30
+ def get_unsubscribed_with_sms_preference_subscribers
31
+ @list.unsubscribed(include_sms_preference:true)
32
+ end
33
+
26
34
  def get_unconfirmed_subscribers
27
35
  @list.unconfirmed
28
36
  end
@@ -35,7 +43,9 @@ end
35
43
  sample = ListsSample.new
36
44
 
37
45
  puts "All active subscribers: #{sample.get_active_subscribers.to_json}\n\n"
46
+ puts "All active subscribers with sms preference: #{sample.get_active_with_sms_preference_subscribers.to_json}\n\n"
38
47
  puts "All bounced subscribers: #{sample.get_bounced_subscribers.to_json}\n\n"
39
- puts "All unsubscribed subscribers: #{sample.get_unsubscribed_subscribers.to_json}\n\n"
40
48
  puts "All unconfirmed subscribers: #{sample.get_unconfirmed_subscribers.to_json}\n\n"
49
+ puts "All unsubscribed subscribers: #{sample.get_unsubscribed_subscribers.to_json}\n\n"
50
+ puts "All unsubscribed subscribers with sms preference: #{sample.get_unsubscribed_with_sms_preference_subscribers.to_json}\n\n"
41
51
  puts "All deleted subscribers: #{sample.get_deleted_subscribers.to_json}\n\n"
@@ -0,0 +1,51 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'createsend'
3
+
4
+ class SubscribersSample
5
+ def initialize
6
+ raise 'CREATESEND_ACCESS_TOKEN env var missing' if ENV['CREATESEND_ACCESS_TOKEN'].nil?
7
+ raise 'CREATESEND_REFRESH_TOKEN env var missing' if ENV['CREATESEND_REFRESH_TOKEN'].nil?
8
+ raise 'CREATESEND_LIST_ID env var missing' if ENV['CREATESEND_LIST_ID'].nil?
9
+
10
+ @auth = {:access_token => ENV['CREATESEND_ACCESS_TOKEN'], :refresh_token => ENV['CREATESEND_REFRESH_TOKEN']}
11
+ end
12
+
13
+ def add_subscriber_without_mobile
14
+ @subscriberAdded = CreateSend::Subscriber.add @auth, ENV['CREATESEND_LIST_ID'], "subscriberNoMobile@example.com", "Subscriber", [], true, "Yes", false
15
+ end
16
+
17
+ def add_subscriber_with_mobile
18
+ @subscriberAdded = CreateSend::Subscriber.add @auth, ENV['CREATESEND_LIST_ID'], "subscriberWithMobile@example.com", "SubscriberWithMobile", [], true, "Yes", false, "+61423152523"
19
+ end
20
+
21
+ def add_subscriber_with_mobile_and_consent
22
+ @subscriberAdded = CreateSend::Subscriber.add @auth, ENV['CREATESEND_LIST_ID'], "subscriberWithMobileAndConsent@example.com", "SubscriberWithMobileAndConsent", [], true, "Yes", false, "+61423152523", "Yes"
23
+ end
24
+
25
+ def get_subscriber
26
+ @subscriber = CreateSend::Subscriber.get @auth, ENV['CREATESEND_LIST_ID'], "subscriberNoMobile@example.com"
27
+ end
28
+
29
+ def import_subscribers
30
+ subscribers = [
31
+ {"EmailAddress":"subscriberImport11@example.com","Name":"subscriberImport11", "ConsentToTrack":"Yes"},
32
+ {"EmailAddress":"subscriberImport12@example.com","Name":"subscriberImport12", "ConsentToTrack":"No", "MobileNumber":"+1612105111", "ConsentToSendSms":"Yes"},
33
+ {"EmailAddress":"subscriberImport13@example.com","Name":"subscriberImport13", "ConsentToTrack":"Yes", "MobileNumber":"+1612105112"}
34
+ ]
35
+ @subscribersImported = CreateSend::Subscriber.import(@auth, ENV['CREATESEND_LIST_ID'], subscribers, true, false, false)
36
+ end
37
+
38
+ def update_subscribers
39
+ @subscriber = CreateSend::Subscriber.new(@auth, ENV['CREATESEND_LIST_ID'], 'subscriberWithMobileAndConsent@example.com')
40
+ @subscriberUpdated = @subscriber.update("subscriberWithMobileAndConsent@example.com", "Subscriber With Mobile And Consent", [], true, "Yes", false, "+16175551218")
41
+ end
42
+ end
43
+
44
+ sample = SubscribersSample.new
45
+
46
+ puts "add_subscriber_without_mobile: #{sample.add_subscriber_without_mobile.to_json}\n\n"
47
+ puts "add_subscriber_with_mobile: #{sample.add_subscriber_with_mobile.to_json}\n\n"
48
+ puts "add_subscriber_with_mobile_and_consent: #{sample.add_subscriber_with_mobile_and_consent.to_json}\n\n"
49
+ puts "get subscribers: #{sample.get_subscriber.to_json}\n\n"
50
+ puts "import_subscribers: #{sample.import_subscribers.to_json}\n\n"
51
+ puts "update_subscribers: #{sample.update_subscribers.to_json}\n\n"
@@ -10,15 +10,15 @@ class AdministratorTest < Test::Unit::TestCase
10
10
  email = "admin@example.com"
11
11
  stub_get(@auth, "admins.json?email=#{ERB::Util.url_encode(email)}", "admin_details.json")
12
12
  admin = CreateSend::Administrator.get @auth, email
13
- admin.EmailAddress.should == email
14
- admin.Name.should == "Admin One"
15
- admin.Status.should == "Active"
13
+ admin.EmailAddress.should be == email
14
+ admin.Name.should be == "Admin One"
15
+ admin.Status.should be == "Active"
16
16
  end
17
17
 
18
18
  should "add an administrator" do
19
19
  stub_post(@auth, "admins.json", "add_admin.json")
20
20
  result = CreateSend::Administrator.add @auth, "admin@example.com", "Admin"
21
- result.EmailAddress.should == "admin@example.com"
21
+ result.EmailAddress.should be == "admin@example.com"
22
22
  end
23
23
 
24
24
  should "update an administrator" do
@@ -26,7 +26,7 @@ class AdministratorTest < Test::Unit::TestCase
26
26
  new_email = "new_email_address@example.com"
27
27
  stub_put(@auth, "admins.json?email=#{ERB::Util.url_encode(email)}", nil)
28
28
  @admin.update new_email, "Admin Name"
29
- @admin.email_address.should == new_email
29
+ @admin.email_address.should be == new_email
30
30
  end
31
31
 
32
32
  should "delete an admin" do
@@ -13,8 +13,8 @@ class CampaignTest < Test::Unit::TestCase
13
13
  "http://example.com/campaign.html", "http://example.com/campaign.txt", [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
14
14
  [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
15
15
  request = FakeWeb.last_request.body
16
- request.include?("\"TextUrl\":\"http://example.com/campaign.txt\"").should == true
17
- campaign_id.should == "787y87y87y87y87y87y87"
16
+ request.include?("\"TextUrl\":\"http://example.com/campaign.txt\"").should be == true
17
+ campaign_id.should be == "787y87y87y87y87y87y87"
18
18
  end
19
19
 
20
20
  should "create a campaign with a nil text_url param" do
@@ -24,8 +24,8 @@ class CampaignTest < Test::Unit::TestCase
24
24
  "http://example.com/campaign.html", nil, [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
25
25
  [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
26
26
  request = FakeWeb.last_request.body
27
- request.include?("\"TextUrl\":null").should == true
28
- campaign_id.should == "787y87y87y87y87y87y87"
27
+ request.include?("\"TextUrl\":null").should be == true
28
+ campaign_id.should be == "787y87y87y87y87y87y87"
29
29
  end
30
30
 
31
31
  should "create a campaign from a template" do
@@ -106,7 +106,7 @@ class CampaignTest < Test::Unit::TestCase
106
106
  campaign_id = CreateSend::Campaign.create_from_template @auth, client_id, "subject", "name", "g'day", "good.day@example.com", "good.day@example.com",
107
107
  [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ], [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ],
108
108
  "7j8uw98udowy12989e8298u2e", template_content
109
- campaign_id.should == "787y87y87y87y87y87y87"
109
+ campaign_id.should be == "787y87y87y87y87y87y87"
110
110
  end
111
111
 
112
112
  should "send a preview of a draft campaign to a single recipient" do
@@ -137,160 +137,160 @@ class CampaignTest < Test::Unit::TestCase
137
137
  should "get the summary for a campaign" do
138
138
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/summary.json", "campaign_summary.json")
139
139
  summary = @campaign.summary
140
- summary.Name.should == "Campaign Name"
141
- summary.Recipients.should == 5
142
- summary.TotalOpened.should == 10
143
- summary.Clicks.should == 0
144
- summary.Unsubscribed.should == 0
145
- summary.Bounced.should == 0
146
- summary.UniqueOpened.should == 5
147
- summary.Mentions.should == 23
148
- summary.Forwards.should == 11
149
- summary.Likes.should == 32
150
- summary.WebVersionURL.should == "http://createsend.com/t/r-3A433FC72FFE3B8B"
151
- summary.WebVersionTextURL.should == "http://createsend.com/t/r-3A433FC72FFE3B8B/t"
152
- summary.WorldviewURL.should == "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
153
- summary.SpamComplaints.should == 23
140
+ summary.Name.should be == "Campaign Name"
141
+ summary.Recipients.should be == 5
142
+ summary.TotalOpened.should be == 10
143
+ summary.Clicks.should be == 0
144
+ summary.Unsubscribed.should be == 0
145
+ summary.Bounced.should be == 0
146
+ summary.UniqueOpened.should be == 5
147
+ summary.Mentions.should be == 23
148
+ summary.Forwards.should be == 11
149
+ summary.Likes.should be == 32
150
+ summary.WebVersionURL.should be == "http://createsend.com/t/r-3A433FC72FFE3B8B"
151
+ summary.WebVersionTextURL.should be == "http://createsend.com/t/r-3A433FC72FFE3B8B/t"
152
+ summary.WorldviewURL.should be == "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
153
+ summary.SpamComplaints.should be == 23
154
154
  end
155
155
 
156
156
  should "get the email client usage for a campaign" do
157
157
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/emailclientusage.json", "email_client_usage.json")
158
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
159
+ ecu.size.should be == 6
160
+ ecu.first.Client.should be == "iOS Devices"
161
+ ecu.first.Version.should be == "iPhone"
162
+ ecu.first.Percentage.should be == 19.83
163
+ ecu.first.Subscribers.should be == 7056
164
164
  end
165
165
 
166
166
  should "get the lists and segments for a campaign" do
167
167
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/listsandsegments.json", "campaign_listsandsegments.json")
168
168
  ls = @campaign.lists_and_segments
169
- ls.Lists.size.should == 1
170
- ls.Segments.size.should == 1
171
- ls.Lists.first.Name.should == "List One"
172
- ls.Lists.first.ListID.should == "a58ee1d3039b8bec838e6d1482a8a965"
173
- ls.Segments.first.Title.should == "Segment for campaign"
174
- ls.Segments.first.ListID.should == "2bea949d0bf96148c3e6a209d2e82060"
175
- ls.Segments.first.SegmentID.should == "dba84a225d5ce3d19105d7257baac46f"
169
+ ls.Lists.size.should be == 1
170
+ ls.Segments.size.should be == 1
171
+ ls.Lists.first.Name.should be == "List One"
172
+ ls.Lists.first.ListID.should be == "a58ee1d3039b8bec838e6d1482a8a965"
173
+ ls.Segments.first.Title.should be == "Segment for campaign"
174
+ ls.Segments.first.ListID.should be == "2bea949d0bf96148c3e6a209d2e82060"
175
+ ls.Segments.first.SegmentID.should be == "dba84a225d5ce3d19105d7257baac46f"
176
176
  end
177
177
 
178
178
  should "get the recipients for a campaign" do
179
179
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/recipients.json?pagesize=20&orderfield=email&page=1&orderdirection=asc", "campaign_recipients.json")
180
180
  res = @campaign.recipients page=1, page_size=20
181
- res.ResultsOrderedBy.should == "email"
182
- res.OrderDirection.should == "asc"
183
- res.PageNumber.should == 1
184
- res.PageSize.should == 20
185
- res.RecordsOnThisPage.should == 20
186
- res.TotalNumberOfRecords.should == 2200
187
- res.NumberOfPages.should == 110
188
- res.Results.size.should == 20
189
- res.Results.first.EmailAddress.should == "subs+6g76t7t0@example.com"
190
- res.Results.first.ListID.should == "a994a3caf1328a16af9a69a730eaa706"
181
+ res.ResultsOrderedBy.should be == "email"
182
+ res.OrderDirection.should be == "asc"
183
+ res.PageNumber.should be == 1
184
+ res.PageSize.should be == 20
185
+ res.RecordsOnThisPage.should be == 20
186
+ res.TotalNumberOfRecords.should be == 2200
187
+ res.NumberOfPages.should be == 110
188
+ res.Results.size.should be == 20
189
+ res.Results.first.EmailAddress.should be == "subs+6g76t7t0@example.com"
190
+ res.Results.first.ListID.should be == "a994a3caf1328a16af9a69a730eaa706"
191
191
  end
192
192
 
193
193
  should "get the opens for a campaign" do
194
194
  min_date = "2010-01-01"
195
195
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/opens.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_opens.json")
196
196
  opens = @campaign.opens min_date
197
- opens.Results.size.should == 5
198
- opens.Results.first.EmailAddress.should == "subs+6576576576@example.com"
199
- opens.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
200
- opens.Results.first.Date.should == "2010-10-11 08:29:00"
201
- opens.Results.first.IPAddress.should == "192.168.126.87"
202
- opens.Results.first.Latitude.should == -33.8683
203
- opens.Results.first.Longitude.should == 151.2086
204
- opens.Results.first.City.should == "Sydney"
205
- opens.Results.first.Region.should == "New South Wales"
206
- opens.Results.first.CountryCode.should == "AU"
207
- opens.Results.first.CountryName.should == "Australia"
208
- opens.ResultsOrderedBy.should == "date"
209
- opens.OrderDirection.should == "asc"
210
- opens.PageNumber.should == 1
211
- opens.PageSize.should == 1000
212
- opens.RecordsOnThisPage.should == 5
213
- opens.TotalNumberOfRecords.should == 5
214
- opens.NumberOfPages.should == 1
197
+ opens.Results.size.should be == 5
198
+ opens.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
199
+ opens.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
200
+ opens.Results.first.Date.should be == "2010-10-11 08:29:00"
201
+ opens.Results.first.IPAddress.should be == "192.168.126.87"
202
+ opens.Results.first.Latitude.should be == -33.8683
203
+ opens.Results.first.Longitude.should be == 151.2086
204
+ opens.Results.first.City.should be == "Sydney"
205
+ opens.Results.first.Region.should be == "New South Wales"
206
+ opens.Results.first.CountryCode.should be == "AU"
207
+ opens.Results.first.CountryName.should be == "Australia"
208
+ opens.ResultsOrderedBy.should be == "date"
209
+ opens.OrderDirection.should be == "asc"
210
+ opens.PageNumber.should be == 1
211
+ opens.PageSize.should be == 1000
212
+ opens.RecordsOnThisPage.should be == 5
213
+ opens.TotalNumberOfRecords.should be == 5
214
+ opens.NumberOfPages.should be == 1
215
215
  end
216
216
 
217
217
  should "get the subscriber clicks for a campaign" do
218
218
  min_date = "2010-01-01"
219
219
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/clicks.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_clicks.json")
220
220
  clicks = @campaign.clicks min_date
221
- clicks.Results.size.should == 3
222
- clicks.Results.first.EmailAddress.should == "subs+6576576576@example.com"
223
- clicks.Results.first.URL.should == "http://video.google.com.au/?hl=en&tab=wv"
224
- clicks.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
225
- clicks.Results.first.Date.should == "2010-10-11 08:29:00"
226
- clicks.Results.first.IPAddress.should == "192.168.126.87"
227
- clicks.Results.first.Latitude.should == -33.8683
228
- clicks.Results.first.Longitude.should == 151.2086
229
- clicks.Results.first.City.should == "Sydney"
230
- clicks.Results.first.Region.should == "New South Wales"
231
- clicks.Results.first.CountryCode.should == "AU"
232
- clicks.Results.first.CountryName.should == "Australia"
233
- clicks.ResultsOrderedBy.should == "date"
234
- clicks.OrderDirection.should == "asc"
235
- clicks.PageNumber.should == 1
236
- clicks.PageSize.should == 1000
237
- clicks.RecordsOnThisPage.should == 3
238
- clicks.TotalNumberOfRecords.should == 3
239
- clicks.NumberOfPages.should == 1
221
+ clicks.Results.size.should be == 3
222
+ clicks.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
223
+ clicks.Results.first.URL.should be == "http://video.google.com.au/?hl=en&tab=wv"
224
+ clicks.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
225
+ clicks.Results.first.Date.should be == "2010-10-11 08:29:00"
226
+ clicks.Results.first.IPAddress.should be == "192.168.126.87"
227
+ clicks.Results.first.Latitude.should be == -33.8683
228
+ clicks.Results.first.Longitude.should be == 151.2086
229
+ clicks.Results.first.City.should be == "Sydney"
230
+ clicks.Results.first.Region.should be == "New South Wales"
231
+ clicks.Results.first.CountryCode.should be == "AU"
232
+ clicks.Results.first.CountryName.should be == "Australia"
233
+ clicks.ResultsOrderedBy.should be == "date"
234
+ clicks.OrderDirection.should be == "asc"
235
+ clicks.PageNumber.should be == 1
236
+ clicks.PageSize.should be == 1000
237
+ clicks.RecordsOnThisPage.should be == 3
238
+ clicks.TotalNumberOfRecords.should be == 3
239
+ clicks.NumberOfPages.should be == 1
240
240
  end
241
241
 
242
242
  should "get the unsubscribes for a campaign" do
243
243
  min_date = "2010-01-01"
244
244
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/unsubscribes.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_unsubscribes.json")
245
245
  unsubscribes = @campaign.unsubscribes min_date
246
- unsubscribes.Results.size.should == 1
247
- unsubscribes.Results.first.EmailAddress.should == "subs+6576576576@example.com"
248
- unsubscribes.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
249
- unsubscribes.Results.first.Date.should == "2010-10-11 08:29:00"
250
- unsubscribes.Results.first.IPAddress.should == "192.168.126.87"
251
- unsubscribes.ResultsOrderedBy.should == "date"
252
- unsubscribes.OrderDirection.should == "asc"
253
- unsubscribes.PageNumber.should == 1
254
- unsubscribes.PageSize.should == 1000
255
- unsubscribes.RecordsOnThisPage.should == 1
256
- unsubscribes.TotalNumberOfRecords.should == 1
257
- unsubscribes.NumberOfPages.should == 1
246
+ unsubscribes.Results.size.should be == 1
247
+ unsubscribes.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
248
+ unsubscribes.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
249
+ unsubscribes.Results.first.Date.should be == "2010-10-11 08:29:00"
250
+ unsubscribes.Results.first.IPAddress.should be == "192.168.126.87"
251
+ unsubscribes.ResultsOrderedBy.should be == "date"
252
+ unsubscribes.OrderDirection.should be == "asc"
253
+ unsubscribes.PageNumber.should be == 1
254
+ unsubscribes.PageSize.should be == 1000
255
+ unsubscribes.RecordsOnThisPage.should be == 1
256
+ unsubscribes.TotalNumberOfRecords.should be == 1
257
+ unsubscribes.NumberOfPages.should be == 1
258
258
  end
259
259
 
260
260
  should "get the spam complaints for a campaign" do
261
261
  min_date = "2010-01-01"
262
262
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/spam.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_spam.json")
263
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
264
+ spam.Results.size.should be == 1
265
+ spam.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
266
+ spam.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
267
+ spam.Results.first.Date.should be == "2010-10-11 08:29:00"
268
+ spam.ResultsOrderedBy.should be == "date"
269
+ spam.OrderDirection.should be == "asc"
270
+ spam.PageNumber.should be == 1
271
+ spam.PageSize.should be == 1000
272
+ spam.RecordsOnThisPage.should be == 1
273
+ spam.TotalNumberOfRecords.should be == 1
274
+ spam.NumberOfPages.should be == 1
275
275
  end
276
276
 
277
277
  should "get the bounces for a campaign" do
278
278
  min_date = "2010-01-01"
279
279
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/bounces.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_bounces.json")
280
280
  bounces = @campaign.bounces min_date
281
- bounces.Results.size.should == 2
282
- bounces.Results.first.EmailAddress.should == "asdf@softbouncemyemail.com"
283
- bounces.Results.first.ListID.should == "654523a5855b4a440bae3fb295641546"
284
- bounces.Results.first.BounceType.should == "Soft"
285
- bounces.Results.first.Date.should == "2010-07-02 16:46:00"
286
- bounces.Results.first.Reason.should == "Bounce - But No Email Address Returned "
287
- bounces.ResultsOrderedBy.should == "date"
288
- bounces.OrderDirection.should == "asc"
289
- bounces.PageNumber.should == 1
290
- bounces.PageSize.should == 1000
291
- bounces.RecordsOnThisPage.should == 2
292
- bounces.TotalNumberOfRecords.should == 2
293
- bounces.NumberOfPages.should == 1
281
+ bounces.Results.size.should be == 2
282
+ bounces.Results.first.EmailAddress.should be == "asdf@softbouncemyemail.com"
283
+ bounces.Results.first.ListID.should be == "654523a5855b4a440bae3fb295641546"
284
+ bounces.Results.first.BounceType.should be == "Soft"
285
+ bounces.Results.first.Date.should be == "2010-07-02 16:46:00"
286
+ bounces.Results.first.Reason.should be == "Bounce - But No Email Address Returned "
287
+ bounces.ResultsOrderedBy.should be == "date"
288
+ bounces.OrderDirection.should be == "asc"
289
+ bounces.PageNumber.should be == 1
290
+ bounces.PageSize.should be == 1000
291
+ bounces.RecordsOnThisPage.should be == 2
292
+ bounces.TotalNumberOfRecords.should be == 2
293
+ bounces.NumberOfPages.should be == 1
294
294
  end
295
295
  end
296
296
  end