streamsend 0.2.3 → 1.0.0.rc1
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.
- data/.gitignore +18 -5
- data/.rspec +1 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +25 -17
- data/README.md +76 -0
- data/Rakefile +1 -2
- data/lib/streamsend/api/account.rb +6 -48
- data/lib/streamsend/api/audience.rb +14 -0
- data/lib/streamsend/api/base/base_call.rb +60 -0
- data/lib/streamsend/api/base/create.rb +41 -0
- data/lib/streamsend/api/base/destroy.rb +43 -0
- data/lib/streamsend/api/base/index.rb +51 -0
- data/lib/streamsend/api/base/show.rb +42 -0
- data/lib/streamsend/api/base/update.rb +43 -0
- data/lib/streamsend/api/blast.rb +51 -0
- data/lib/streamsend/api/bounce.rb +20 -0
- data/lib/streamsend/api/click.rb +18 -0
- data/lib/streamsend/api/configuration.rb +26 -0
- data/lib/streamsend/api/email.rb +20 -0
- data/lib/streamsend/api/exception.rb +4 -4
- data/lib/streamsend/api/field.rb +20 -0
- data/lib/streamsend/api/field_option.rb +60 -0
- data/lib/streamsend/api/filter.rb +20 -0
- data/lib/streamsend/api/from_email_address.rb +24 -0
- data/lib/streamsend/api/import.rb +11 -0
- data/lib/streamsend/api/link.rb +11 -0
- data/lib/streamsend/api/list.rb +13 -39
- data/lib/streamsend/api/membership.rb +28 -0
- data/lib/streamsend/api/person.rb +66 -0
- data/lib/streamsend/api/result.rb +13 -0
- data/lib/streamsend/api/session.rb +73 -0
- data/lib/streamsend/api/unsubscribe.rb +20 -0
- data/lib/streamsend/api/upload.rb +13 -0
- data/lib/streamsend/api/user.rb +67 -38
- data/lib/streamsend/api/view.rb +8 -0
- data/lib/streamsend/version.rb +3 -0
- data/lib/streamsend.rb +35 -16
- data/spec/lib/streamsend/api/integration/account_spec.rb +50 -0
- data/spec/lib/streamsend/api/integration/audience_spec.rb +56 -0
- data/spec/lib/streamsend/api/integration/blast_spec.rb +110 -0
- data/spec/lib/streamsend/api/integration/bounce_spec.rb +43 -0
- data/spec/lib/streamsend/api/integration/click_spec.rb +37 -0
- data/spec/lib/streamsend/api/integration/email_spec.rb +76 -0
- data/spec/lib/streamsend/api/integration/field_option_spec.rb +87 -0
- data/spec/lib/streamsend/api/integration/field_spec.rb +75 -0
- data/spec/lib/streamsend/api/integration/filter_spec.rb +101 -0
- data/spec/lib/streamsend/api/integration/from_email_address_spec.rb +46 -0
- data/spec/lib/streamsend/api/integration/helpers.rb +16 -0
- data/spec/lib/streamsend/api/integration/import_spec.rb +35 -0
- data/spec/lib/streamsend/api/integration/link_spec.rb +39 -0
- data/spec/lib/streamsend/api/integration/list_spec.rb +83 -0
- data/spec/lib/streamsend/api/integration/membership_spec.rb +69 -0
- data/spec/lib/streamsend/api/integration/person_spec.rb +119 -0
- data/spec/lib/streamsend/api/integration/unsubscribe_spec.rb +47 -0
- data/spec/lib/streamsend/api/integration/upload_spec.rb +29 -0
- data/spec/lib/streamsend/api/integration/user_spec.rb +99 -0
- data/spec/lib/streamsend/api/integration/view_spec.rb +27 -0
- data/spec/lib/streamsend/api/unit/base/base_call_spec.rb +66 -0
- data/spec/lib/streamsend/api/unit/base/create_spec.rb +67 -0
- data/spec/lib/streamsend/api/unit/base/destroy_spec.rb +59 -0
- data/spec/lib/streamsend/api/unit/base/index_spec.rb +85 -0
- data/spec/lib/streamsend/api/unit/base/show_spec.rb +68 -0
- data/spec/lib/streamsend/api/unit/base/update_spec.rb +76 -0
- data/spec/lib/streamsend/api/unit/blast_spec.rb +79 -0
- data/spec/lib/streamsend/api/unit/bounce_spec.rb +36 -0
- data/spec/lib/streamsend/api/unit/click_spec.rb +34 -0
- data/spec/lib/streamsend/api/unit/field_option_spec.rb +71 -0
- data/spec/lib/streamsend/api/unit/from_email_address_spec.rb +20 -0
- data/spec/lib/streamsend/api/unit/link_spec.rb +33 -0
- data/spec/lib/streamsend/api/unit/list_spec.rb +33 -0
- data/spec/lib/streamsend/api/unit/membership_spec.rb +46 -0
- data/spec/lib/streamsend/api/unit/person_spec.rb +102 -0
- data/spec/lib/streamsend/api/unit/result_spec.rb +13 -0
- data/spec/lib/streamsend/api/unit/session_spec.rb +62 -0
- data/spec/lib/streamsend/api/unit/unsubscribe_spec.rb +33 -0
- data/spec/lib/streamsend/api/unit/user_spec.rb +102 -0
- data/spec/spec_helper.rb +8 -11
- data/streamsend.gemspec +22 -23
- metadata +250 -178
- checksums.yaml +0 -7
- data/.pair +0 -10
- data/README.rdoc +0 -1
- data/lib/streamsend/api/resource.rb +0 -41
- data/lib/streamsend/api/subscriber.rb +0 -113
- data/spec/integration/account_spec.rb +0 -69
- data/spec/integration/fixtures/vcr_cassettes/streamsend.yml +0 -6831
- data/spec/integration/integration.yml +0 -5
- data/spec/integration/list_spec.rb +0 -68
- data/spec/integration/spec_helper.rb +0 -16
- data/spec/integration/subscriber_spec.rb +0 -24
- data/spec/integration/user_spec.rb +0 -58
- data/spec/lib/streamsend/api/list_spec.rb +0 -179
- data/spec/lib/streamsend/api/resource_spec.rb +0 -24
- data/spec/lib/streamsend/api/subscriber_spec.rb +0 -345
- data/spec/lib/streamsend/api/user_spec.rb +0 -149
- data/spec/lib/streamsend/api_spec.rb +0 -31
- data/watcher_config.rb +0 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Call
|
|
6
|
+
describe Create do
|
|
7
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
8
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
9
|
+
let(:creator){ Create.new(session) }
|
|
10
|
+
|
|
11
|
+
it "parses the header to return the id of the object" do
|
|
12
|
+
stub_request(:post, "http://test:password@default.base/calls.xml").
|
|
13
|
+
with(:body => "name=testing&id=123").
|
|
14
|
+
to_return(:status => 201, :body => "", :headers => {'Location' => 'something/something/101'})
|
|
15
|
+
expect(creator.execute(obj_hash)).to eq(101)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "builds an error message with the namespace name if the status is not a 200" do
|
|
19
|
+
stub_request(:post, "http://test:password@default.base/calls.xml").
|
|
20
|
+
with(:body => "name=testing&id=123").
|
|
21
|
+
to_return(:status => 404, :body => "")
|
|
22
|
+
expect do
|
|
23
|
+
creator.execute(obj_hash)
|
|
24
|
+
end.to raise_error(StreamSend::Api::Exception, "Could not create the calls. (404)")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe AudienceCreate do
|
|
29
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
30
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
31
|
+
let(:creator){ AudienceCreate.new(session) }
|
|
32
|
+
|
|
33
|
+
it "overrides uri and provides an audience uri" do
|
|
34
|
+
xml = <<-XML
|
|
35
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
36
|
+
<audiences type="array">
|
|
37
|
+
<audience>
|
|
38
|
+
<id type="integer">1</id>
|
|
39
|
+
</audience>
|
|
40
|
+
</audiences>
|
|
41
|
+
XML
|
|
42
|
+
stub_request(:get, "http://test:password@default.base/audiences.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
|
43
|
+
stub_request(:post, "http://test:password@default.base/audiences/1/calls.xml").
|
|
44
|
+
with(:body => "name=testing&id=123").
|
|
45
|
+
to_return(:status => 201, :body => "", :headers => {'Location' => 'something/something/101'})
|
|
46
|
+
creator.execute(obj_hash)
|
|
47
|
+
expect(creator.uri).to eq("http://default.base/audiences/1/calls.xml")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe BlastCreate do
|
|
52
|
+
let(:blast_id){ 1234 }
|
|
53
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
54
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
55
|
+
let(:creator){ BlastCreate.new(session) }
|
|
56
|
+
|
|
57
|
+
it "overrides uri and provides a blast uri" do
|
|
58
|
+
stub_request(:post, "http://test:password@default.base/blasts/1234/calls.xml").
|
|
59
|
+
with(:body => "name=testing&id=123").
|
|
60
|
+
to_return(:status => 201, :body => "", :headers => {'Location' => 'something/something/101'})
|
|
61
|
+
creator.execute(blast_id, obj_hash)
|
|
62
|
+
expect(creator.uri).to eq("http://default.base/blasts/1234/calls.xml")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Call
|
|
6
|
+
describe Destroy do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
8
|
+
let(:deleter){ Destroy.new(session) }
|
|
9
|
+
let(:id){ 4321 }
|
|
10
|
+
|
|
11
|
+
it "returns true when the object is deleted" do
|
|
12
|
+
stub_request(:delete, "http://test:password@default.base/calls/4321.xml").to_return(:status => 200, :body => "", :headers => {})
|
|
13
|
+
expect(deleter.execute(id)).to eq(true)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "throws an exception when the object is not deleted" do
|
|
17
|
+
stub_request(:delete, "http://test:password@default.base/calls/4321.xml").to_return(:status => 500, :body => "", :headers => {})
|
|
18
|
+
expect do
|
|
19
|
+
deleter.execute(id)
|
|
20
|
+
end.to raise_error(StreamSend::Api::Exception, "Could not delete calls. (500)")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe AudienceDestroy do
|
|
25
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
26
|
+
let(:deleter){ AudienceDestroy.new(session) }
|
|
27
|
+
let(:id){ 4321 }
|
|
28
|
+
|
|
29
|
+
it "overrides uri to provide an audience index uri" do
|
|
30
|
+
xml = <<-XML
|
|
31
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
32
|
+
<audiences type="array">
|
|
33
|
+
<audience>
|
|
34
|
+
<id type="integer">1</id>
|
|
35
|
+
</audience>
|
|
36
|
+
</audiences>
|
|
37
|
+
XML
|
|
38
|
+
stub_request(:get, "http://test:password@default.base/audiences.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
|
39
|
+
stub_request(:delete, "http://test:password@default.base/audiences/1/calls/4321.xml").to_return(:status => 200, :body => "", :headers => {})
|
|
40
|
+
deleter.execute(id)
|
|
41
|
+
expect(deleter.uri).to eq("http://default.base/audiences/1/calls/4321.xml")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe BlastDestroy do
|
|
46
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
47
|
+
let(:deleter){ BlastDestroy.new(session) }
|
|
48
|
+
let(:id){ 4321 }
|
|
49
|
+
let(:blast_id){ 55 }
|
|
50
|
+
|
|
51
|
+
it "creates a uri using the blast id provided" do
|
|
52
|
+
stub_request(:delete, "http://test:password@default.base/blasts/55/calls/4321.xml").to_return(:status => 200, :body => "", :headers => {})
|
|
53
|
+
deleter.execute(blast_id, id)
|
|
54
|
+
expect(deleter.uri).to eq("http://default.base/blasts/55/calls/4321.xml")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Call
|
|
6
|
+
describe Index do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
8
|
+
let(:indexer){ Index.new(session) }
|
|
9
|
+
let(:options){ {:page => 2, :per_page => 10} }
|
|
10
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
|
|
11
|
+
|
|
12
|
+
describe "Uris" do
|
|
13
|
+
before do
|
|
14
|
+
stub_request(:get, "http://test:password@default.base/calls.xml").to_return(:status => 200, :body => xml, :headers => {})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "builds a index uri" do
|
|
18
|
+
indexer.execute
|
|
19
|
+
expect(indexer.uri).to eq("http://default.base/calls.xml")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "#paging_query_string" do
|
|
23
|
+
it "returns paging parameters with the options provided" do
|
|
24
|
+
indexer.execute(options)
|
|
25
|
+
expect(indexer.paging_query_string).to eq("?page=2&per_page=10")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "returns default paging parameters if no options are provided." do
|
|
29
|
+
indexer.execute
|
|
30
|
+
expect(indexer.paging_query_string).to eq("?page=1&per_page=100")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#execute" do
|
|
36
|
+
it "creates an array of Result objects" do
|
|
37
|
+
stub_request(:get, "http://test:password@default.base/calls.xml").to_return(:status => 200, :body => xml, :headers => {'Content-type' => 'application/xml'})
|
|
38
|
+
expect(indexer.execute[0].test).to eq(1)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "builds an error message with the namespace name if the status is not a 200" do
|
|
42
|
+
stub_request(:get, "http://test:password@default.base/calls.xml").to_return(:status => 404, :body => xml, :headers => {})
|
|
43
|
+
expect do
|
|
44
|
+
indexer.execute
|
|
45
|
+
end.to raise_error(StreamSend::Api::Exception, "Could not find any calls. (404)")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe AudienceIndex do
|
|
51
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
52
|
+
let(:indexer){ AudienceIndex.new(session) }
|
|
53
|
+
let(:call_xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
|
|
54
|
+
|
|
55
|
+
it "overrides uri to provide an audience index uri" do
|
|
56
|
+
xml = <<-XML
|
|
57
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
58
|
+
<audiences type="array">
|
|
59
|
+
<audience>
|
|
60
|
+
<id type="integer">1</id>
|
|
61
|
+
</audience>
|
|
62
|
+
</audiences>
|
|
63
|
+
XML
|
|
64
|
+
stub_request(:get, "http://test:password@default.base/audiences.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
|
65
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/calls.xml").to_return(:status => 200, :body => call_xml, :headers => {})
|
|
66
|
+
indexer.execute
|
|
67
|
+
expect(indexer.uri).to eq("http://default.base/audiences/1/calls.xml")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe BlastIndex do
|
|
72
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
73
|
+
let(:indexer){ BlastIndex.new(session) }
|
|
74
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
|
|
75
|
+
let(:blast_id){ 1432 }
|
|
76
|
+
|
|
77
|
+
it "overrides uri and returns a uri based on the provided blast_id and appends paging" do
|
|
78
|
+
stub_request(:get, "http://test:password@default.base/blasts/1432/calls.xml?page=1&per_page=100").to_return(:status => 200, :body => xml, :headers => {})
|
|
79
|
+
indexer.execute(blast_id)
|
|
80
|
+
expect(indexer.uri).to eq("http://default.base/blasts/1432/calls.xml?page=1&per_page=100")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Call
|
|
6
|
+
describe Show do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
8
|
+
let(:shower){ Show.new(session) }
|
|
9
|
+
let(:id){ 1 }
|
|
10
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><call><test type=\"integer\">1</test></call>" }
|
|
11
|
+
|
|
12
|
+
it "returns a Result object if the object is found" do
|
|
13
|
+
stub_request(:get, "http://test:password@default.base/calls/1.xml").to_return(:status => 200, :body => xml, :headers => {"Content-type" => "text/xml"})
|
|
14
|
+
expect(shower.execute(id).test).to eq(1)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "throws an exception if the object is not found" do
|
|
18
|
+
stub_request(:get, "http://test:password@default.base/calls/1.xml").to_return(:status => 404, :body => xml, :headers => {})
|
|
19
|
+
expect do
|
|
20
|
+
shower.execute(id)
|
|
21
|
+
end.to raise_error(StreamSend::Api::Exception, "Could not find any calls with the specified id. (404)")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "creates a uri including the specified id" do
|
|
25
|
+
stub_request(:get, "http://test:password@default.base/calls/1.xml").to_return(:status => 200, :body => xml, :headers => {})
|
|
26
|
+
shower.execute(id)
|
|
27
|
+
expect(shower.uri).to eq("http://default.base/calls/1.xml")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe AudienceShow do
|
|
32
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
33
|
+
let(:shower){ AudienceShow.new(session) }
|
|
34
|
+
let(:id){ 1 }
|
|
35
|
+
let(:call_xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><call><test type=\"integer\">1</test></call>" }
|
|
36
|
+
|
|
37
|
+
it "overrides uri to provide an audience index uri" do
|
|
38
|
+
xml = <<-XML
|
|
39
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
40
|
+
<audiences type="array">
|
|
41
|
+
<audience>
|
|
42
|
+
<id type="integer">1</id>
|
|
43
|
+
</audience>
|
|
44
|
+
</audiences>
|
|
45
|
+
XML
|
|
46
|
+
stub_request(:get, "http://test:password@default.base/audiences.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
|
47
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/calls/1.xml").to_return(:status => 200, :body => call_xml, :headers => {})
|
|
48
|
+
shower.execute(id)
|
|
49
|
+
expect(shower.uri).to eq("http://default.base/audiences/1/calls/1.xml")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe BlastShow do
|
|
54
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
55
|
+
let(:shower){ BlastShow.new(session) }
|
|
56
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
|
|
57
|
+
let(:id){ 4321 }
|
|
58
|
+
let(:blast_id){ 55 }
|
|
59
|
+
|
|
60
|
+
it "creates a uri using the blast id provided" do
|
|
61
|
+
stub_request(:get, "http://test:password@default.base/blasts/55/calls/4321.xml").to_return(:status => 200, :body => xml, :headers => {})
|
|
62
|
+
shower.execute(blast_id, id)
|
|
63
|
+
expect(shower.uri).to eq("http://default.base/blasts/55/calls/4321.xml")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Call
|
|
6
|
+
describe Update do
|
|
7
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
8
|
+
let(:id){ 123 }
|
|
9
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
10
|
+
let(:updater){ Update.new(session) }
|
|
11
|
+
|
|
12
|
+
it "returns true when the object is updated successfully" do
|
|
13
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").
|
|
14
|
+
with(:body => "name=testing&id=123").
|
|
15
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
16
|
+
expect(updater.execute(id, obj_hash)).to eq(true)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "returns true when the object is updated successfully" do
|
|
20
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").
|
|
21
|
+
with(:body => "name=testing&id=123").
|
|
22
|
+
to_return(:status => 404, :body => "", :headers => {})
|
|
23
|
+
expect(updater.execute(id, obj_hash)).to eq(false)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "creates a uri for updating using the id" do
|
|
27
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").
|
|
28
|
+
with(:body => "name=testing&id=123").
|
|
29
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
30
|
+
updater.execute(id, obj_hash)
|
|
31
|
+
expect(updater.uri).to eq("http://default.base/calls/123.xml")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe AudienceUpdate do
|
|
36
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
37
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
38
|
+
let(:updater){ AudienceUpdate.new(session) }
|
|
39
|
+
let(:id){ 123 }
|
|
40
|
+
|
|
41
|
+
it "overrides uri and provides an audience uri" do
|
|
42
|
+
xml = <<-XML
|
|
43
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
44
|
+
<audiences type="array">
|
|
45
|
+
<audience>
|
|
46
|
+
<id type="integer">1</id>
|
|
47
|
+
</audience>
|
|
48
|
+
</audiences>
|
|
49
|
+
XML
|
|
50
|
+
stub_request(:get, "http://test:password@default.base/audiences.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
|
51
|
+
stub_request(:put, "http://test:password@default.base/audiences/1/calls/123.xml").
|
|
52
|
+
with(:body => "name=testing&id=123").
|
|
53
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
54
|
+
updater.execute(id, obj_hash)
|
|
55
|
+
expect(updater.uri).to eq("http://default.base/audiences/1/calls/123.xml")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe BlastUpdate do
|
|
60
|
+
let(:blast_id){ 1234 }
|
|
61
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
62
|
+
let(:id){ 123 }
|
|
63
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
64
|
+
let(:updater){ BlastUpdate.new(session) }
|
|
65
|
+
|
|
66
|
+
it "overrides uri and provides a blast uri" do
|
|
67
|
+
stub_request(:put, "http://test:password@default.base/blasts/1234/calls/123.xml").
|
|
68
|
+
with(:body => "name=testing&id=123").
|
|
69
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
70
|
+
updater.execute(blast_id, id, obj_hash)
|
|
71
|
+
expect(updater.uri).to eq("http://default.base/blasts/1234/calls/123.xml")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Blast
|
|
6
|
+
describe "Blast calls" do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
8
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><blasts type=\"array\"><blast><test type=\"integer\">1</test></blast></blasts>" }
|
|
9
|
+
|
|
10
|
+
describe Index do
|
|
11
|
+
let(:indexer){ Index.new(session) }
|
|
12
|
+
|
|
13
|
+
it "returns the scheduled blast uri" do
|
|
14
|
+
session.stub(:audience_id).and_return(1)
|
|
15
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts.xml?page=1&per_page=100").
|
|
16
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
17
|
+
indexer.execute
|
|
18
|
+
expect(indexer.uri).to eq("http://default.base/audiences/1/blasts.xml?page=1&per_page=100")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe Scheduled do
|
|
23
|
+
let(:scheduler){ Scheduled.new(session) }
|
|
24
|
+
|
|
25
|
+
before do
|
|
26
|
+
session.stub(:audience_id).and_return(1)
|
|
27
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/scheduled.xml?page=1&per_page=100").
|
|
28
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
29
|
+
scheduler.execute
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "returns the scheduled blast uri" do
|
|
33
|
+
expect(scheduler.uri).to eq("http://default.base/audiences/1/blasts/scheduled.xml?page=1&per_page=100")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe Sent do
|
|
38
|
+
let(:scheduler){ Sent.new(session) }
|
|
39
|
+
|
|
40
|
+
before do
|
|
41
|
+
session.stub(:audience_id).and_return(1)
|
|
42
|
+
stub_request(:get, "http://test:password@default.base/audiences/1/blasts/sent.xml?page=1&per_page=100").
|
|
43
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
44
|
+
scheduler.execute
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "returns the sent blast uri" do
|
|
48
|
+
expect(scheduler.uri).to eq("http://default.base/audiences/1/blasts/sent.xml?page=1&per_page=100")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe Test do
|
|
53
|
+
let(:scheduler){ Test.new(session) }
|
|
54
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
55
|
+
|
|
56
|
+
before do
|
|
57
|
+
session.stub(:audience_id).and_return(1)
|
|
58
|
+
stub_request(:post, "http://test:password@default.base/audiences/1/blasts/test.xml").
|
|
59
|
+
with(:body => "name=testing&id=123").
|
|
60
|
+
to_return(:status => 200, :body => "", :headers => {'Location' => 'something/something/101'})
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "returns the test blast uri" do
|
|
64
|
+
scheduler.execute(obj_hash)
|
|
65
|
+
expect(scheduler.uri).to eq("http://default.base/audiences/1/blasts/test.xml")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "raises a Semantic error if the reposne is a 422" do
|
|
69
|
+
stub_request(:post, "http://test:password@default.base/audiences/1/blasts/test.xml").
|
|
70
|
+
to_return(:status => 422, :body => "<errors><error>what's going on here?</error></errors>", :headers => {'Location' => 'something/something/101'})
|
|
71
|
+
expect do
|
|
72
|
+
scheduler.execute(obj_hash)
|
|
73
|
+
end.to raise_exception StreamSend::Api::SemanticException
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Bounce
|
|
6
|
+
describe "Bounce calls" do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
|
8
|
+
let(:blast_id){ 15 }
|
|
9
|
+
let(:soft_bounce){ Soft.new(session) }
|
|
10
|
+
let(:hard_bounce){ Hard.new(session) }
|
|
11
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bounces type=\"array\"><bounce><test type=\"integer\">1<bounce></bounces>" }
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
stub_request(:get, "http://test:password@default.base/blasts/15/bounces/soft.xml?page=1&per_page=100").
|
|
15
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
16
|
+
stub_request(:get, "http://test:password@default.base/blasts/15/bounces/hard.xml?page=1&per_page=100").
|
|
17
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
18
|
+
soft_bounce.execute(blast_id)
|
|
19
|
+
hard_bounce.execute(blast_id)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe Soft do
|
|
23
|
+
it "returns a uri for soft bounces" do
|
|
24
|
+
expect(soft_bounce.uri).to eq("http://default.base/blasts/15/bounces/soft.xml?page=1&per_page=100")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe Hard do
|
|
29
|
+
it "returns a url for hard bounces" do
|
|
30
|
+
expect(hard_bounce.uri).to eq("http://default.base/blasts/15/bounces/hard.xml?page=1&per_page=100")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Click
|
|
6
|
+
describe "Click calls" do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "pass", "https://default.base") }
|
|
8
|
+
let(:indexer){ Index.new(session) }
|
|
9
|
+
let(:blast_id){ 1 }
|
|
10
|
+
let(:link_id){ 1 }
|
|
11
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><clicks type=\"array\"><click><test type=\"integer\">1</test></click></clicks>" }
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
stub_request(:get, "https://test:pass@default.base/blasts/1/links/1/clicks.xml?page=1&per_page=100").
|
|
15
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
16
|
+
stub_request(:get, "https://test:pass@default.base/blasts/1/clicks.xml?page=1&per_page=100").
|
|
17
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe Index do
|
|
21
|
+
it "creates a uri for blast clicks" do
|
|
22
|
+
indexer.execute(blast_id)
|
|
23
|
+
expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/clicks.xml?page=1&per_page=100")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "creates a uri for a link click if link id is provided" do
|
|
27
|
+
indexer.execute(blast_id, link_id)
|
|
28
|
+
expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/links/#{link_id}/clicks.xml?page=1&per_page=100")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Option
|
|
6
|
+
describe "Field Option calls" do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "pass", "https://default.base") }
|
|
8
|
+
let(:indexer){ Index.new(session) }
|
|
9
|
+
let(:shower){ Show.new(session) }
|
|
10
|
+
let(:obj_hash){ { :id => 123, :name => "testing" } }
|
|
11
|
+
let(:updater){ Update.new(session) }
|
|
12
|
+
let(:creator){ Create.new(session) }
|
|
13
|
+
let(:destroyer){ Destroy.new(session) }
|
|
14
|
+
let(:field_id){ 221 }
|
|
15
|
+
let(:option_id){ 1 }
|
|
16
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><options type=\"array\"><option><test type=\"integer\">1</test></option></options>" }
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
stub_request(:get, "https://test:pass@default.base/audiences/1/fields/221/options.xml").
|
|
20
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
21
|
+
session.stub(:audience_id).and_return(1)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe Index do
|
|
25
|
+
it "returns a uri for field option index" do
|
|
26
|
+
indexer.execute(field_id)
|
|
27
|
+
expect(indexer.uri).to eq("https://default.base/audiences/1/fields/221/options.xml")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe Show do
|
|
32
|
+
it "returns a uri for field option show" do
|
|
33
|
+
stub_request(:get, "https://test:pass@default.base/audiences/1/fields/221/options/1.xml").
|
|
34
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
35
|
+
shower.execute(field_id, option_id)
|
|
36
|
+
expect(shower.uri).to eq("https://default.base/audiences/1/fields/221/options/1.xml")
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe Update do
|
|
41
|
+
it "returns a uri for field option update" do
|
|
42
|
+
stub_request(:put, "https://test:pass@default.base/audiences/1/fields/221/options/1.xml").
|
|
43
|
+
with(:body => "name=testing&id=123").
|
|
44
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
45
|
+
updater.execute(field_id, option_id, obj_hash)
|
|
46
|
+
expect(updater.uri).to eq("https://default.base/audiences/1/fields/221/options/1.xml")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe Create do
|
|
51
|
+
it "returns a uri for field option create" do
|
|
52
|
+
stub_request(:post, "https://test:pass@default.base/audiences/1/fields/221/options.xml").
|
|
53
|
+
with(:body => "name=testing&id=123").
|
|
54
|
+
to_return(:status => 201, :body => "", :headers => {'Location' => 'something/something/101'})
|
|
55
|
+
creator.execute(field_id, obj_hash)
|
|
56
|
+
expect(creator.uri).to eq("https://default.base/audiences/1/fields/221/options.xml")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe Destroy do
|
|
61
|
+
it "returns a uri for field option destroy" do
|
|
62
|
+
stub_request(:delete, "https://test:pass@default.base/audiences/1/fields/221/options/1.xml").
|
|
63
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
64
|
+
destroyer.execute(field_id, option_id)
|
|
65
|
+
expect(destroyer.uri).to eq("https://default.base/audiences/1/fields/221/options/1.xml")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module FromEmailAddress
|
|
6
|
+
describe ResendActivationEmail do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "pass", "https://default.base") }
|
|
8
|
+
let(:resender){ ResendActivationEmail.new(session) }
|
|
9
|
+
let(:email_id){ 123 }
|
|
10
|
+
|
|
11
|
+
it "returns a uri for resending the activation email" do
|
|
12
|
+
stub_request(:post, "https://test:pass@default.base/from_email_addresses/123/resend_activation_email.xml").
|
|
13
|
+
to_return(:status => 200, :body => "", :headers => {})
|
|
14
|
+
resender.execute(email_id)
|
|
15
|
+
expect(resender.uri(email_id)).to eq("https://default.base/from_email_addresses/123/resend_activation_email.xml")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
module StreamSend
|
|
4
|
+
module Api
|
|
5
|
+
module Link
|
|
6
|
+
describe "Link calls" do
|
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "https://default.base") }
|
|
8
|
+
let(:indexer){ Index.new(session) }
|
|
9
|
+
let(:shower){ Show.new(session) }
|
|
10
|
+
let(:blast_id){ 1 }
|
|
11
|
+
let(:link_id){ 1 }
|
|
12
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><links type=\"array\"><link><test type=\"integer\">1</test></link></links>" }
|
|
13
|
+
|
|
14
|
+
describe Index do
|
|
15
|
+
it "creates a uri for blast links" do
|
|
16
|
+
stub_request(:get, "https://test:password@default.base/blasts/1/links.xml?page=1&per_page=100").
|
|
17
|
+
to_return(:status => 200, :body => xml, :headers => {})
|
|
18
|
+
indexer.execute(blast_id)
|
|
19
|
+
expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/links.xml?page=1&per_page=100")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe Show do
|
|
24
|
+
it "creates a uri for a specific blast link" do
|
|
25
|
+
stub_request(:get, "https://test:password@default.base/blasts/1/links/1.xml").to_return(:status => 200, :body => xml, :headers => {})
|
|
26
|
+
shower.execute(blast_id, link_id)
|
|
27
|
+
expect(shower.uri).to eq("https://default.base/blasts/#{blast_id}/links/#{link_id}.xml")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|