streamsend 1.0.0.rc19 → 1.0.0.rc22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +16 -0
- data/lib/streamsend/api/blast.rb +19 -1
- data/lib/streamsend/api/person.rb +12 -0
- data/lib/streamsend/api/session.rb +52 -46
- data/lib/streamsend/version.rb +1 -1
- data/spec/lib/streamsend/api/integration/blast_spec.rb +44 -10
- data/spec/lib/streamsend/api/integration/owner_spec.rb +1 -0
- data/spec/lib/streamsend/api/integration/person_spec.rb +20 -0
- data/spec/lib/streamsend/api/unit/blast_spec.rb +29 -4
- data/spec/lib/streamsend/api/unit/person_spec.rb +16 -0
- data/spec/lib/streamsend/api/unit/session_spec.rb +13 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjYwZTBhOGJlMGZjOTFlOTkwZjk2NmI1ZWIxMDFkZTk0ZmJmN2YwYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGZjMjE4NTJhZmViYjQ2Zjc0NzQ4YjJhMmFkNGQ4ZmVjNzJhN2Q5Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmE3OWZjODkyMDZlYzM5YmJlYzg0MjVkMmZlNDQ2NzQzYjFlZjE1YWY2NTQ3
|
10
|
+
NWQ4NjMyODUzNjk1NjNlOThiZmRjMWY4NmQwYjdhYTZiMjA5NzI4YTQwOTdi
|
11
|
+
ZDBhY2YwMGE4MzI5YWVlMDllZjc4OGNiZDBjZTE2MjU5YzUxNDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTk0Njg0NTQ2MTRkZDkxNWMxYzRmMTNmM2FhYThhNGQ3ZjU2ZTdjOTViMDRj
|
14
|
+
NjRiZjJjNzI1ZGViYzRkMjUwY2FlZDcyZWZmMDBmOTVlNjczNzllZTZjNjI1
|
15
|
+
YTY2OWNiZTU3ZDYzMjQ3YzU5MWM4MjY4ZjMwNWY3YTQ2MDQ0OWI=
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,6 +25,22 @@ The base_uri can also be set in the same ways (e.g. STREAMSEND_BASE_URI="http://
|
|
25
25
|
"http://my.branded.url"), but is optional and defaults to
|
26
26
|
<https://app.streamsend.com>
|
27
27
|
|
28
|
+
**Using a child accounti**
|
29
|
+
An account id can be passed in as part of the options hash when initializing a session:
|
30
|
+
|
31
|
+
Session::Api::Session.new("my_ss_api_username", "secret_api_password", :account_id => 123)
|
32
|
+
|
33
|
+
This will add the child account id into the header (e.g. X-Account-Id: 123) for any calls using that session.
|
34
|
+
|
35
|
+
**Forcing data to be sent as XML**
|
36
|
+
This gem makes requests using HttParty which sends data as if it were form data. The StreamSend API currenly accepts
|
37
|
+
parameters sent in this format. However, if needed, the gem can be forced to send data as XML using the options hash:
|
38
|
+
|
39
|
+
Session::Api::Session.new("my_ss_api_username", "secret_api_password", :use_xml => true)
|
40
|
+
|
41
|
+
This will add xml as the content type in the header, as well as converting the object hash to xml before sending the
|
42
|
+
request.
|
43
|
+
|
28
44
|
**Making Calls**
|
29
45
|
|
30
46
|
The show and index calls return a single or array of StreamSend::Api::Result
|
data/lib/streamsend/api/blast.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module StreamSend
|
2
2
|
module Api
|
3
|
-
|
3
|
+
module Blast
|
4
4
|
class Index < StreamSend::Api::Call::Index
|
5
5
|
def uri
|
6
6
|
"#{audiences_uri}"
|
@@ -46,6 +46,24 @@ module StreamSend
|
|
46
46
|
"#{base_audience_uri}/test.xml"
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
class Count < StreamSend::Api::Call::Count
|
51
|
+
def execute(blast_status = nil)
|
52
|
+
@blast_status = blast_status
|
53
|
+
super()
|
54
|
+
end
|
55
|
+
|
56
|
+
def uri
|
57
|
+
case @blast_status
|
58
|
+
when "scheduled"
|
59
|
+
"#{base_audience_uri}/scheduled/count.xml"
|
60
|
+
when "sent"
|
61
|
+
"#{base_audience_uri}/sent/count.xml"
|
62
|
+
else
|
63
|
+
"#{base_audience_uri}/count.xml"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
49
67
|
end
|
50
68
|
end
|
51
69
|
end
|
@@ -80,6 +80,18 @@ module StreamSend
|
|
80
80
|
"#{base_audience_uri}/#{id}/unsubscribe.xml"
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
class Count < StreamSend::Api::Call::Count
|
85
|
+
def execute(list_id = nil)
|
86
|
+
@list_id = list_id
|
87
|
+
super()
|
88
|
+
end
|
89
|
+
|
90
|
+
def uri
|
91
|
+
return "#{base_audience_only}/lists/#{@list_id}/people/count.xml" if @list_id
|
92
|
+
"#{base_audience_only}/people/count.xml"
|
93
|
+
end
|
94
|
+
end
|
83
95
|
end
|
84
96
|
end
|
85
97
|
end
|
@@ -1,66 +1,30 @@
|
|
1
1
|
module StreamSend
|
2
2
|
module Api
|
3
3
|
class Session
|
4
|
-
def initialize(username = nil, password = nil, base_uri = nil,
|
4
|
+
def initialize(username = nil, password = nil, base_uri = nil, options = {})
|
5
5
|
@base_uri = load_base_uri(base_uri)
|
6
6
|
@username = load_username(username)
|
7
7
|
@password = load_password(password)
|
8
|
-
@send_data_as_xml = send_data_as_xml?(use_xml)
|
9
|
-
|
10
|
-
|
11
|
-
def load_base_uri base_uri
|
12
|
-
return base_uri if base_uri
|
13
|
-
return ENV['STREAMSEND_BASE_URI'] if ENV['STREAMSEND_BASE_URI']
|
14
|
-
return StreamSend::Api::Configuration.base_uri if StreamSend::Api::Configuration.base_uri
|
15
|
-
return "http://app.streamsend.com"
|
16
|
-
end
|
17
|
-
|
18
|
-
def load_username username
|
19
|
-
return username if username
|
20
|
-
return ENV['STREAMSEND_USERNAME'] if ENV['STREAMSEND_USERNAME']
|
21
|
-
return StreamSend::Api::Configuration.username
|
22
|
-
raise StreamSend::Api::Exception.new("Unable to create session: no API username provided.")
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_password password
|
26
|
-
return password if password
|
27
|
-
return ENV['STREAMSEND_PASSWORD'] if ENV['STREAMSEND_PASSWORD']
|
28
|
-
return StreamSend::Api::Configuration.password
|
29
|
-
raise StreamSend::Api::Exception.new("Unable to create session: no API password provided.")
|
30
|
-
end
|
31
|
-
|
32
|
-
def send_data_as_xml?(send_as_xml)
|
33
|
-
return send_as_xml if send_as_xml
|
34
|
-
return ENV['STREAMSEND_USE_XML'] if ENV['STREAMSEND_USE_XML']
|
35
|
-
return StreamSend::Api::Configuration.send_data_as_xml
|
36
|
-
false
|
8
|
+
@send_data_as_xml = send_data_as_xml?(options[:use_xml])
|
9
|
+
@account_id = options[:account_id]
|
37
10
|
end
|
38
11
|
|
39
12
|
def get(uri, options = {})
|
40
|
-
|
41
|
-
HTTParty.get(uri, options)
|
13
|
+
HTTParty.get(uri, build_options_hash(options))
|
42
14
|
end
|
43
15
|
|
44
16
|
def put(uri, options = {})
|
45
|
-
options.merge!(self.basic_auth_credentials)
|
46
17
|
convert_request_to_xml(options) if send_data_as_xml
|
47
|
-
HTTParty.put(uri, options)
|
18
|
+
HTTParty.put(uri, build_options_hash(options))
|
48
19
|
end
|
49
20
|
|
50
21
|
def post(uri, options = {})
|
51
|
-
options.merge!(self.basic_auth_credentials)
|
52
22
|
convert_request_to_xml(options) if send_data_as_xml
|
53
|
-
HTTMultiParty.post(uri, options)
|
23
|
+
HTTMultiParty.post(uri, build_options_hash(options))
|
54
24
|
end
|
55
25
|
|
56
26
|
def delete(uri, options = {})
|
57
|
-
|
58
|
-
HTTParty.delete(uri, options)
|
59
|
-
end
|
60
|
-
|
61
|
-
def convert_request_to_xml(options)
|
62
|
-
options[:headers]["Content-Type"] = "text/xml"
|
63
|
-
options[:body] = StreamSend::Api::HashXmlSerializer.new.serialize(options[:body])
|
27
|
+
HTTParty.delete(uri, build_options_hash(options))
|
64
28
|
end
|
65
29
|
|
66
30
|
def base_uri
|
@@ -71,15 +35,57 @@ module StreamSend
|
|
71
35
|
@send_data_as_xml
|
72
36
|
end
|
73
37
|
|
38
|
+
def audience_id
|
39
|
+
@audience_id ||= get_audience_id
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def build_options_hash(options)
|
45
|
+
options.merge!(x_account_id) if @account_id
|
46
|
+
options.merge!(basic_auth_credentials)
|
47
|
+
end
|
48
|
+
|
74
49
|
def basic_auth_credentials
|
75
50
|
{ :basic_auth => { :username => @username, :password => @password } }
|
76
51
|
end
|
77
52
|
|
78
|
-
def
|
79
|
-
@
|
53
|
+
def x_account_id
|
54
|
+
{ :headers => { "X-Account-Id" => @account_id } }
|
80
55
|
end
|
81
56
|
|
82
|
-
|
57
|
+
def convert_request_to_xml(options)
|
58
|
+
options[:headers]["Content-Type"] = "text/xml"
|
59
|
+
options[:body] = StreamSend::Api::HashXmlSerializer.new.serialize(options[:body])
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_base_uri base_uri
|
63
|
+
return base_uri if base_uri
|
64
|
+
return ENV['STREAMSEND_BASE_URI'] if ENV['STREAMSEND_BASE_URI']
|
65
|
+
return StreamSend::Api::Configuration.base_uri if StreamSend::Api::Configuration.base_uri
|
66
|
+
return "http://app.streamsend.com"
|
67
|
+
end
|
68
|
+
|
69
|
+
def load_username username
|
70
|
+
return username if username
|
71
|
+
return ENV['STREAMSEND_USERNAME'] if ENV['STREAMSEND_USERNAME']
|
72
|
+
return StreamSend::Api::Configuration.username
|
73
|
+
raise StreamSend::Api::Exception.new("Unable to create session: no API username provided.")
|
74
|
+
end
|
75
|
+
|
76
|
+
def load_password password
|
77
|
+
return password if password
|
78
|
+
return ENV['STREAMSEND_PASSWORD'] if ENV['STREAMSEND_PASSWORD']
|
79
|
+
return StreamSend::Api::Configuration.password
|
80
|
+
raise StreamSend::Api::Exception.new("Unable to create session: no API password provided.")
|
81
|
+
end
|
82
|
+
|
83
|
+
def send_data_as_xml?(send_as_xml)
|
84
|
+
return send_as_xml if send_as_xml
|
85
|
+
return ENV['STREAMSEND_USE_XML'] if ENV['STREAMSEND_USE_XML']
|
86
|
+
return StreamSend::Api::Configuration.send_data_as_xml
|
87
|
+
false
|
88
|
+
end
|
83
89
|
|
84
90
|
def get_audience_id
|
85
91
|
audience = StreamSend::Api::Audience::Index.new(self).execute().first
|
data/lib/streamsend/version.rb
CHANGED
@@ -5,18 +5,20 @@ module StreamSend
|
|
5
5
|
module Blast
|
6
6
|
describe "Blast calls" do
|
7
7
|
let(:session){ StreamSend::Api::Session.new() }
|
8
|
-
let(:list_hash){ { :list => { :name => "New list #{DateTime.now
|
8
|
+
let(:list_hash){ { :list => { :name => "New list #{DateTime.now}" } } }
|
9
9
|
let(:list_id){ StreamSend::Api::List::Create.new(session).execute(list_hash) }
|
10
10
|
let(:future_date){ DateTime.now + 1.day }
|
11
|
+
let(:creator) { Create.new(session) }
|
12
|
+
let(:blast_obj) { { :blast => { :subject => "Tesing yo.#{DateTime.now}", :body => { :text_part => "test email" }, :to => { :include_lists => list_id.to_s, :audience_id => 1 }, :scheduled_for => future_date, :from => from } } }
|
11
13
|
|
12
14
|
before do
|
13
15
|
WebMock.disable!
|
14
16
|
from_addresses = StreamSend::Api::FromEmailAddress::Index.new(session).execute
|
15
17
|
from_addy = from_addresses.select{ |address| address.activated == true }.first
|
16
18
|
from = {:name => "Mister Tester", :email_address => from_addy.email_address}
|
17
|
-
@
|
18
|
-
@test_obj = { :blast => { :subject => "Tesing yo.", :body => { :text_part => "test email" }, :to => "testy@testy.mctest" , :scheduled_for => future_date, :from => from } }
|
19
|
+
@test_obj = { :blast => { :subject => "Testing yo.#{DateTime.now}", :body => { :text_part => "test email" }, :to => "testy@testy.mctest" , :scheduled_for => future_date, :from => from } }
|
19
20
|
end
|
21
|
+
let(:indexer) { Index.new(session) }
|
20
22
|
|
21
23
|
after do
|
22
24
|
WebMock.enable!
|
@@ -54,19 +56,20 @@ module StreamSend
|
|
54
56
|
|
55
57
|
describe Show do
|
56
58
|
it "returns a blast by id" do
|
57
|
-
|
58
|
-
id = creator.execute(
|
59
|
+
pending "fails intermittently due to locked blast."
|
60
|
+
id = creator.execute(blast_obj)
|
59
61
|
shower = Show.new(session)
|
60
62
|
show = shower.execute(id)
|
61
|
-
expect(show.subject).to eq(
|
63
|
+
expect(show.subject).to eq(blast_obj[:blast][:subject])
|
64
|
+
destroyer = Destroy.new(session)
|
65
|
+
destroyer.execute(id)
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
65
69
|
describe Update do
|
66
70
|
it "updates a blast" do
|
67
71
|
pending "fails intermittently due to locked blast."
|
68
|
-
|
69
|
-
id = creator.execute(@blast_obj)
|
72
|
+
id = creator.execute(blast_obj)
|
70
73
|
shower = Show.new(session)
|
71
74
|
show = shower.execute(id)
|
72
75
|
show.scheduled_for = DateTime.now + 10.days
|
@@ -85,8 +88,7 @@ module StreamSend
|
|
85
88
|
describe Destroy do
|
86
89
|
it "destroys a blast" do
|
87
90
|
pending "fails intermittently due to locked blast."
|
88
|
-
|
89
|
-
id = creator.execute(@blast_obj)
|
91
|
+
id = creator.execute(blast_obj)
|
90
92
|
|
91
93
|
destroyer = Destroy.new(session)
|
92
94
|
destroyer.execute(id)
|
@@ -104,6 +106,38 @@ module StreamSend
|
|
104
106
|
expect(tester.execute(@test_obj)).to eq(200)
|
105
107
|
end
|
106
108
|
end
|
109
|
+
|
110
|
+
describe Count do
|
111
|
+
context "blasts count" do
|
112
|
+
let(:indexer) { Index.new(session) }
|
113
|
+
let(:counter) { Count.new(session) }
|
114
|
+
let(:scheduler) { Scheduled.new(session) }
|
115
|
+
let(:senter) { Sent.new(session) }
|
116
|
+
let(:status) { "scheduled" }
|
117
|
+
let(:status_two) { "sent" }
|
118
|
+
|
119
|
+
it "returns a count of blasts" do
|
120
|
+
index_blasts_count = indexer.execute(:page => 1, :per_page => 10000).count
|
121
|
+
|
122
|
+
blast_count = counter.execute()
|
123
|
+
expect(blast_count).to eq(index_blasts_count)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "returns a count of scheduled blasts" do
|
127
|
+
scheduled = scheduler.execute(:page => 1, :per_page => 10000).count
|
128
|
+
|
129
|
+
blast_count = counter.execute(status)
|
130
|
+
expect(blast_count).to eq(scheduled)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns a count of sent blasts" do
|
134
|
+
sent = senter.execute(:page => 1, :per_page => 10000).count
|
135
|
+
|
136
|
+
blast_count = counter.execute(status_two)
|
137
|
+
expect(blast_count).to eq(sent)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
107
141
|
end
|
108
142
|
end
|
109
143
|
end
|
@@ -90,6 +90,7 @@ module StreamSend
|
|
90
90
|
|
91
91
|
describe Destroy do
|
92
92
|
it "deletes an owner by owner id" do
|
93
|
+
pending "Check API to see if delete owner has changed show response"
|
93
94
|
id = StreamSend::Api::Owner::Create.new(session).execute({:owner => owner_hash})
|
94
95
|
StreamSend::Api::Owner::Destroy.new(session).execute(id)
|
95
96
|
expect do
|
@@ -8,8 +8,12 @@ module StreamSend
|
|
8
8
|
let(:creator){ Create.new(session) }
|
9
9
|
let(:indexer){ Index.new(session) }
|
10
10
|
let(:shower){ Show.new(session) }
|
11
|
+
let(:counter){ Count.new(session) }
|
11
12
|
let(:randomish){ DateTime.now.to_i.to_s }
|
12
13
|
let(:person_hash){ { :person => { :email_address => "joe+#{randomish}@some.place" } } }
|
14
|
+
let(:list_creator) { StreamSend::Api::List::Create.new(session) }
|
15
|
+
let(:list_hash) {{ :list => { :name => "New List #{DateTime.now}" } } }
|
16
|
+
let(:list_id) { list_creator.execute(list_hash) }
|
13
17
|
|
14
18
|
before do
|
15
19
|
WebMock.disable!
|
@@ -193,6 +197,22 @@ module StreamSend
|
|
193
197
|
end.to raise_exception(StreamSend::Api::Exception, "Could not find any people with the specified id. (404)")
|
194
198
|
end
|
195
199
|
end
|
200
|
+
|
201
|
+
describe Count do
|
202
|
+
it "returns a count of all people" do
|
203
|
+
total_people_count = indexer.execute.count
|
204
|
+
|
205
|
+
people_count = counter.execute()
|
206
|
+
expect(people_count).to eq(total_people_count)
|
207
|
+
end
|
208
|
+
|
209
|
+
it "returns a count of people by list_id" do
|
210
|
+
list_people_count = indexer.execute(list_id).count
|
211
|
+
|
212
|
+
people_count = counter.execute(list_id)
|
213
|
+
expect(people_count).to eq(list_people_count)
|
214
|
+
end
|
215
|
+
end
|
196
216
|
end
|
197
217
|
end
|
198
218
|
end
|
@@ -7,11 +7,14 @@ module StreamSend
|
|
7
7
|
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
8
8
|
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><blasts type=\"array\"><blast><test type=\"integer\">1</test></blast></blasts>" }
|
9
9
|
|
10
|
+
before do
|
11
|
+
session.stub(:audience_id).and_return(1)
|
12
|
+
end
|
13
|
+
|
10
14
|
describe Index do
|
11
15
|
let(:indexer){ Index.new(session) }
|
12
16
|
|
13
17
|
it "returns the scheduled blast uri" do
|
14
|
-
session.stub(:audience_id).and_return(1)
|
15
18
|
stub_request(:get, "http://test:password@default.base/audiences/1/blasts.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
16
19
|
indexer.execute
|
17
20
|
expect(indexer.uri).to eq("http://default.base/audiences/1/blasts.xml")
|
@@ -22,7 +25,6 @@ module StreamSend
|
|
22
25
|
let(:scheduler){ Scheduled.new(session) }
|
23
26
|
|
24
27
|
before do
|
25
|
-
session.stub(:audience_id).and_return(1)
|
26
28
|
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/scheduled.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
27
29
|
scheduler.execute
|
28
30
|
end
|
@@ -36,7 +38,6 @@ module StreamSend
|
|
36
38
|
let(:scheduler){ Sent.new(session) }
|
37
39
|
|
38
40
|
before do
|
39
|
-
session.stub(:audience_id).and_return(1)
|
40
41
|
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/sent.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
41
42
|
scheduler.execute
|
42
43
|
end
|
@@ -51,7 +52,6 @@ module StreamSend
|
|
51
52
|
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
52
53
|
|
53
54
|
before do
|
54
|
-
session.stub(:audience_id).and_return(1)
|
55
55
|
stub_request(:post, "http://test:password@default.base/audiences/1/blasts/test.xml").
|
56
56
|
to_return(:status => 200, :body => "", :headers => {'Location' => 'something/something/101'})
|
57
57
|
end
|
@@ -69,6 +69,31 @@ module StreamSend
|
|
69
69
|
end.to raise_exception StreamSend::Api::SemanticException
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
describe Count do
|
74
|
+
let(:counter) { Count.new(session) }
|
75
|
+
let(:blast_status) { "scheduled" }
|
76
|
+
let(:blast_status_two) { "sent" }
|
77
|
+
|
78
|
+
|
79
|
+
it "builds a blast count URI" do
|
80
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/count.xml").to_return(:status => 200, :body => xml, :headers => {})
|
81
|
+
counter.execute
|
82
|
+
expect(counter.uri).to eq("http://default.base/audiences/1/blasts/count.xml")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "builds a blasts scheduled count URI" do
|
86
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/scheduled/count.xml").to_return(:status => 200, :body => xml, :headers => {})
|
87
|
+
counter.execute(blast_status)
|
88
|
+
expect(counter.uri).to eq("http://default.base/audiences/1/blasts/scheduled/count.xml")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "builds a blasts sent count URI" do
|
92
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/sent/count.xml").to_return(:status => 200, :body => xml, :headers => {})
|
93
|
+
counter.execute(blast_status_two)
|
94
|
+
expect(counter.uri).to eq("http://default.base/audiences/1/blasts/sent/count.xml")
|
95
|
+
end
|
96
|
+
end
|
72
97
|
end
|
73
98
|
end
|
74
99
|
end
|
@@ -90,6 +90,22 @@ module StreamSend
|
|
90
90
|
expect(unsuber.uri(person_id)).to eq("https://default.base/audiences/1/people/#{person_id}/unsubscribe.xml")
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
describe Count do
|
95
|
+
it "returns a URI for a count of people by list_id" do
|
96
|
+
stub_request(:get, "https://test:password@default.base/audiences/1/lists/213/people/count.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
97
|
+
counter = Count.new(session)
|
98
|
+
counter.execute(list_id)
|
99
|
+
expect(counter.uri).to eq ("https://default.base/audiences/#{audience_id}/lists/#{list_id}/people/count.xml")
|
100
|
+
end
|
101
|
+
|
102
|
+
it "returns a URI for people count" do
|
103
|
+
stub_request(:get, "https://test:password@default.base/audiences/1/people/count.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
104
|
+
counter = Count.new(session)
|
105
|
+
counter.execute
|
106
|
+
expect(counter.uri).to eq ("https://default.base/audiences/#{audience_id}/people/count.xml")
|
107
|
+
end
|
108
|
+
end
|
93
109
|
end
|
94
110
|
end
|
95
111
|
end
|
@@ -16,12 +16,6 @@ module StreamSend
|
|
16
16
|
expect(non_default_session.base_uri).to eq("http://something.else.here")
|
17
17
|
end
|
18
18
|
|
19
|
-
describe "#basic_auth_credentials" do
|
20
|
-
it "returns a hash with the username and password" do
|
21
|
-
expect(session.basic_auth_credentials).to eq({ :basic_auth => {:username => "test", :password => "password"} })
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
it "gets the audience id for the configured account" do
|
26
20
|
xml = <<-XML
|
27
21
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -35,6 +29,19 @@ module StreamSend
|
|
35
29
|
expect(session.audience_id).to eq(1)
|
36
30
|
end
|
37
31
|
|
32
|
+
context "with an account id option provided" do
|
33
|
+
let(:options) { { :account_id => "123" } }
|
34
|
+
let(:session){ Session.new("test", "password", "http://default.base", options) }
|
35
|
+
|
36
|
+
it "adds x-account-id to the header" do
|
37
|
+
stub = stub_request(:get, "http://test:password@default.base/").
|
38
|
+
with(:headers => {'X-Account-Id'=>'123'}).
|
39
|
+
to_return(:status => 200, :body => "", :headers => {})
|
40
|
+
session.get(session.base_uri)
|
41
|
+
stub.should have_been_requested
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
38
45
|
describe "get" do
|
39
46
|
it "uses the PUT verb" do
|
40
47
|
stub = stub_http_request(:get, "http://test:password@default.base")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamsend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Yeo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|