streamsend 1.0.0.rc16 → 1.0.0.rc19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +9 -7
  4. data/lib/streamsend/api/base/count.rb +27 -0
  5. data/lib/streamsend/api/base/index.rb +13 -15
  6. data/lib/streamsend/api/blast.rb +6 -6
  7. data/lib/streamsend/api/bounce.rb +2 -2
  8. data/lib/streamsend/api/click.rb +2 -2
  9. data/lib/streamsend/api/configuration.rb +4 -0
  10. data/lib/streamsend/api/hash_xml_serializer.rb +58 -0
  11. data/lib/streamsend/api/list.rb +1 -1
  12. data/lib/streamsend/api/membership.rb +16 -3
  13. data/lib/streamsend/api/person.rb +4 -8
  14. data/lib/streamsend/api/result.rb +32 -1
  15. data/lib/streamsend/api/session.rb +22 -1
  16. data/lib/streamsend/api/unsubscribe.rb +2 -2
  17. data/lib/streamsend/version.rb +1 -1
  18. data/lib/streamsend.rb +3 -4
  19. data/spec/lib/streamsend/api/integration/blast_spec.rb +4 -4
  20. data/spec/lib/streamsend/api/integration/bounce_spec.rb +3 -0
  21. data/spec/lib/streamsend/api/integration/click_spec.rb +2 -0
  22. data/spec/lib/streamsend/api/integration/link_spec.rb +2 -0
  23. data/spec/lib/streamsend/api/integration/membership_spec.rb +27 -1
  24. data/spec/lib/streamsend/api/integration/owner_spec.rb +25 -18
  25. data/spec/lib/streamsend/api/integration/person_spec.rb +12 -2
  26. data/spec/lib/streamsend/api/integration/unsubscribe_spec.rb +2 -0
  27. data/spec/lib/streamsend/api/integration/view_spec.rb +1 -0
  28. data/spec/lib/streamsend/api/unit/base/count_spec.rb +57 -0
  29. data/spec/lib/streamsend/api/unit/base/index_spec.rb +42 -18
  30. data/spec/lib/streamsend/api/unit/blast_spec.rb +6 -9
  31. data/spec/lib/streamsend/api/unit/bounce_spec.rb +5 -7
  32. data/spec/lib/streamsend/api/unit/click_spec.rb +4 -4
  33. data/spec/lib/streamsend/api/unit/hash_xml_serializer_spec.rb +63 -0
  34. data/spec/lib/streamsend/api/unit/link_spec.rb +2 -2
  35. data/spec/lib/streamsend/api/unit/membership_spec.rb +23 -9
  36. data/spec/lib/streamsend/api/unit/person_spec.rb +10 -11
  37. data/spec/lib/streamsend/api/unit/result_spec.rb +32 -3
  38. data/spec/lib/streamsend/api/unit/unsubscribe_spec.rb +4 -6
  39. metadata +9 -3
@@ -27,36 +27,43 @@ module StreamSend
27
27
  after do
28
28
  WebMock.enable!
29
29
  end
30
+ let(:owner_id_1) do
31
+ creator = StreamSend::Api::Owner::Create.new(session)
32
+ id = creator.execute({:owner => owner_hash})
33
+ end
30
34
 
31
- def create_owners
35
+ let(:owner_id_2) do
32
36
  creator = StreamSend::Api::Owner::Create.new(session)
33
37
  owner_hash2 = owner_hash.clone
34
38
  owner_hash2[:owner_name] = franchise_code2
35
39
  owner_hash2[:owner_id] = franchise_code2
40
+ creator.execute({:owner => owner_hash2})
41
+ end
36
42
 
43
+ let(:owner_id_3) do
44
+ creator = StreamSend::Api::Owner::Create.new(session)
37
45
  owner_hash3 = owner_hash.clone
38
46
  owner_hash3[:owner_name] = franchise_code3
39
47
  owner_hash3[:owner_id] = franchise_code3
40
-
41
- creator.execute({:owner => owner_hash})
42
- creator.execute({:owner => owner_hash2})
43
48
  creator.execute({:owner => owner_hash3})
44
49
  end
45
50
 
46
- def delete_owners
51
+ def create_owners
52
+ [owner_id_1, owner_id_2, owner_id_3]
53
+ end
54
+
55
+ def delete_owners(owner_ids)
47
56
  destroyer = StreamSend::Api::Owner::Destroy.new(session)
48
- destroyer.execute(franchise_code)
49
- destroyer.execute(franchise_code2)
50
- destroyer.execute(franchise_code3)
57
+ owner_ids.each{ |id| destroyer.execute(id) }
51
58
  end
52
59
 
53
60
  describe Index do
54
61
  context "without pagination" do
55
62
  it "creates, display, then destroy the owner(s)" do
56
- create_owners
63
+ ids = create_owners
57
64
  owners = StreamSend::Api::Owner::Index.new(session).execute
58
65
  expect(owners.count).to be > 0
59
- delete_owners
66
+ delete_owners(ids)
60
67
  end
61
68
  end
62
69
 
@@ -64,29 +71,29 @@ module StreamSend
64
71
  let(:per_page) { 2 }
65
72
 
66
73
  it "creates, display, then destroy the owner(s)" do
67
- create_owners
74
+ ids = create_owners
68
75
  owners = StreamSend::Api::Owner::Index.new(session).execute(:page =>1, :per_page => per_page)
69
76
  expect(owners.count).to be per_page
70
- delete_owners
77
+ delete_owners(ids)
71
78
  end
72
79
  end
73
80
  end
74
81
 
75
82
  describe Show do
76
83
  it "shows a owner by id" do
77
- create_owners
78
- owner = StreamSend::Api::Owner::Show.new(session).execute(franchise_code)
84
+ ids = create_owners
85
+ owner = StreamSend::Api::Owner::Show.new(session).execute(ids.first)
79
86
  expect(owner.owner_id).to eq(franchise_code)
80
- delete_owners
87
+ delete_owners(ids)
81
88
  end
82
89
  end
83
90
 
84
91
  describe Destroy do
85
92
  it "deletes an owner by owner id" do
86
- StreamSend::Api::Owner::Create.new(session).execute({:owner => owner_hash})
87
- StreamSend::Api::Owner::Destroy.new(session).execute(franchise_code)
93
+ id = StreamSend::Api::Owner::Create.new(session).execute({:owner => owner_hash})
94
+ StreamSend::Api::Owner::Destroy.new(session).execute(id)
88
95
  expect do
89
- StreamSend::Api::Owner::Show.new(session).execute(franchise_code)
96
+ StreamSend::Api::Owner::Show.new(session).execute(id)
90
97
  end.to raise_error(StreamSend::Api::Exception, "Could not find any owners with the specified id. (404)")
91
98
  end
92
99
  end
@@ -54,10 +54,13 @@ module StreamSend
54
54
  emailer = EmailAddress.new(session)
55
55
  results = emailer.execute(person_hash[:person][:email_address])
56
56
  expect(results.count).to be > 0
57
+
58
+ destroyer = Destroy.new(session)
59
+ destroyer.execute(id)
57
60
  end
58
61
 
59
62
  it "returns an index by email address and owner id" do
60
- # pending "Owner is not accessible via API -- relies on owner fixture in account"
63
+ pending "Owner is not accessible via API -- relies on owner fixture in account"
61
64
  owner_id = "ID 1373999841"
62
65
  person_hash[:person][:owner_id] = owner_id
63
66
  id = creator.execute(person_hash)
@@ -73,10 +76,13 @@ module StreamSend
73
76
  tracker = TrackingHash.new(session)
74
77
  results = tracker.execute(person.tracking_hash)
75
78
  expect(results.count).to be > 0
79
+
80
+ destroyer = Destroy.new(session)
81
+ destroyer.execute(id)
76
82
  end
77
83
 
78
84
  it "returns an index by owner id" do
79
- # pending "Owner is not accessible via API -- relies on owner fixture in account"
85
+ pending "Owner is not accessible via API -- relies on owner fixture in account"
80
86
  owner_id = "ID 1373999841"
81
87
  person_hash[:person][:owner_id] = owner_id
82
88
  id = creator.execute(person_hash)
@@ -92,20 +98,24 @@ module StreamSend
92
98
  let(:blast_id) { 70361 }
93
99
  let(:link_id) { 27581 }
94
100
  it "returns an array of people" do
101
+ pending "Can't create a click through API"
95
102
  people = peopler.execute(blast_id)
96
103
  expect(people.count).to be > 0
97
104
  end
98
105
 
99
106
  it "returns an array of people for a link click by link id" do
107
+ pending "Can't create view through API"
100
108
  people = peopler.execute(blast_id, link_id)
101
109
  expect(people.count).to be > 0
102
110
  end
103
111
  end
104
112
 
105
113
  describe View do
114
+ pending "Can't create a view through API"
106
115
  let(:viewer){ View.new(session) }
107
116
  let(:blast_id) { 72761 }
108
117
  it "returns an array of people" do
118
+ pending "Can't create view through API"
109
119
  people = viewer.execute(blast_id)
110
120
  expect(people.count).to be > 0
111
121
  end
@@ -17,6 +17,7 @@ module StreamSend
17
17
 
18
18
  describe Index do
19
19
  it "returns an array of unsubscribes" do
20
+ pending "Can't create unsubsscribes through api"
20
21
  indexer = Index.new(session)
21
22
  unsubs = indexer.execute(blast_id)
22
23
  expect(unsubs.count).to be > 0
@@ -25,6 +26,7 @@ module StreamSend
25
26
 
26
27
  describe Manual do
27
28
  it "returns an array of manual unsubscribes" do
29
+ pending "Can't create unsubsscribes through api"
28
30
  manualer = Manual.new(session)
29
31
  unsubs = manualer.execute(blast_id)
30
32
  expect(unsubs.count).to be > 0
@@ -17,6 +17,7 @@ module StreamSend
17
17
 
18
18
  describe Index do
19
19
  it "returns an array of views" do
20
+ pending "Can't create view from API"
20
21
  indexer = Index.new(session)
21
22
  expect(indexer.execute(blast_id).count).to be > 0
22
23
  end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Call
6
+ describe Count do
7
+ let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
8
+ let(:count_request){ Count.new(session) }
9
+ let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><count type=\"integer\">10</count>" }
10
+
11
+ describe "#uris" do
12
+ before do
13
+ stub_request(:get, "http://test:password@default.base/calls/count.xml").
14
+ to_return(:status => 200, :body => xml, headers: { 'Accept' => 'text/xml', 'Content-type' => 'text/xml' })
15
+ end
16
+
17
+ it "builds a count uri" do
18
+ count_request.execute
19
+ expect(count_request.uri).to eq("http://default.base/calls/count.xml")
20
+ end
21
+ end
22
+
23
+ describe "#execute" do
24
+ it "returns a count integer" do
25
+ stub_request(:get, "http://test:password@default.base/calls/count.xml").
26
+ to_return(:status => 200, :body => xml, :headers => {'Content-type' => 'application/xml'})
27
+ expect(count_request.execute).to eq(10)
28
+ end
29
+
30
+ it "throws a ApiException for 400 errors" do
31
+ stub_request(:get, "http://test:password@default.base/calls/count.xml").
32
+ to_return(:status => 400, :body => xml, :headers => {'Content-type' => 'application/xml'})
33
+ expect do
34
+ count_request.execute
35
+ end.to raise_error ::StreamSend::Api::ApiException
36
+ end
37
+
38
+ it "throws a UnauthorizedException for 401 errors" do
39
+ stub_request(:get, "http://test:password@default.base/calls/count.xml").
40
+ to_return(:status => 401, :body => xml, :headers => {'Content-type' => 'application/xml'})
41
+ expect do
42
+ count_request.execute
43
+ end.to raise_error ::StreamSend::Api::UnauthorizedException
44
+ end
45
+
46
+ it "throws a Exception for all other errors" do
47
+ stub_request(:get, "http://test:password@default.base/calls/count.xml").
48
+ to_return(:status => 500, :body => xml, :headers => {'Content-type' => 'application/xml'})
49
+ expect do
50
+ count_request.execute
51
+ end.to raise_error ::StreamSend::Api::Exception
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -9,7 +9,7 @@ module StreamSend
9
9
  let(:options){ {:page => 2, :per_page => 10} }
10
10
  let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><calls type=\"array\"><call><test type=\"integer\">1</test></call></calls>" }
11
11
 
12
- describe "Uris" do
12
+ describe "#uris" do
13
13
  before do
14
14
  stub_request(:get, "http://test:password@default.base/calls.xml").
15
15
  to_return(:status => 200, :body => xml, headers: { 'Accept' => 'text/xml', 'Content-type' => 'text/xml' })
@@ -19,20 +19,6 @@ module StreamSend
19
19
  indexer.execute
20
20
  expect(indexer.uri).to eq("http://default.base/calls.xml")
21
21
  end
22
-
23
- describe "#paging_query_string" do
24
- it "returns paging parameters with the options provided" do
25
- stub_request(:get, "http://test:password@default.base/calls.xml?page=2&per_page=10").
26
- to_return(:status => 200, :body => xml, headers: { 'Accept' => 'text/xml', 'Content-type' => 'text/xml' })
27
- indexer.execute(options)
28
- expect(indexer.paging_query_string).to eq("?page=2&per_page=10")
29
- end
30
-
31
- it "returns default paging parameters if no options are provided." do
32
- indexer.execute
33
- expect(indexer.paging_query_string).to eq("?page=1&per_page=100")
34
- end
35
- end
36
22
  end
37
23
 
38
24
  describe "#execute" do
@@ -48,6 +34,45 @@ module StreamSend
48
34
  indexer.execute
49
35
  end.to raise_error(StreamSend::Api::Exception, "Could not find any calls. (404)")
50
36
  end
37
+
38
+ context "with options" do
39
+ let(:session) { double(:get => double(:code => 200, :parsed_response => { "calls" => [] } ), :base_uri => "http://boohoo.com") }
40
+ context "with headers attribute" do
41
+ let(:options) { {:headers =>{:location => "http://me.com"}, :owner_id => 99 } }
42
+
43
+ it "makes get request with options" do
44
+ session.should_receive(:get).with("http://boohoo.com/calls.xml", options)
45
+ indexer.execute(options)
46
+ end
47
+ end
48
+
49
+ context "with query attributes" do
50
+ let(:options) { {:query => {:page => 5, :per_page => 66}, :owner_id => 99 } }
51
+
52
+ it "makes get request with options" do
53
+ session.should_receive(:get).with("http://boohoo.com/calls.xml", options)
54
+ indexer.execute(options)
55
+ end
56
+ end
57
+
58
+ context "with attributes only" do
59
+ let(:options) { {:page => 3, :per_page => 33, :owner_id => 99} }
60
+
61
+ it "makes get request with options in a query hash" do
62
+ session.should_receive(:get).with("http://boohoo.com/calls.xml", {:query => options})
63
+ indexer.execute(options)
64
+ end
65
+ end
66
+ end
67
+
68
+ context "with no options" do
69
+ let(:session) { double(:get => double(:code => 200, :parsed_response => { "calls" => [] } ), :base_uri => "http://boohoo.com") }
70
+ let(:options) { {} }
71
+ it "makes get request with options that is an empty hash" do
72
+ session.should_receive(:get).with("http://boohoo.com/calls.xml", {})
73
+ indexer.execute(options)
74
+ end
75
+ end
51
76
  end
52
77
  end
53
78
 
@@ -81,10 +106,9 @@ module StreamSend
81
106
  let(:blast_id){ 1432 }
82
107
 
83
108
  it "overrides uri and returns a uri based on the provided blast_id and appends paging" do
84
- stub_request(:get, "http://test:password@default.base/blasts/1432/calls.xml?page=1&per_page=100").
85
- to_return(:status => 200, :body => xml, headers: { 'Accept' => 'text/xml', 'Content-type' => 'text/xml' })
109
+ stub_request(:get, "http://test:password@default.base/blasts/1432/calls.xml").to_return(:status => 200, :body => xml, headers: { 'Accept' => 'text/xml', 'Content-type' => 'text/xml' })
86
110
  indexer.execute(blast_id)
87
- expect(indexer.uri).to eq("http://default.base/blasts/1432/calls.xml?page=1&per_page=100")
111
+ expect(indexer.uri).to eq("http://default.base/blasts/1432/calls.xml")
88
112
  end
89
113
  end
90
114
  end
@@ -12,10 +12,9 @@ module StreamSend
12
12
 
13
13
  it "returns the scheduled blast uri" do
14
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 => {'Content-Type' => 'text/xml'})
15
+ stub_request(:get, "http://test:password@default.base/audiences/1/blasts.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
17
16
  indexer.execute
18
- expect(indexer.uri).to eq("http://default.base/audiences/1/blasts.xml?page=1&per_page=100")
17
+ expect(indexer.uri).to eq("http://default.base/audiences/1/blasts.xml")
19
18
  end
20
19
  end
21
20
 
@@ -24,13 +23,12 @@ module StreamSend
24
23
 
25
24
  before do
26
25
  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 => {'Content-Type' => 'text/xml'})
26
+ stub_request(:get, "http://test:password@default.base/audiences/1/blasts/scheduled.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
29
27
  scheduler.execute
30
28
  end
31
29
 
32
30
  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")
31
+ expect(scheduler.uri).to eq("http://default.base/audiences/1/blasts/scheduled.xml")
34
32
  end
35
33
  end
36
34
 
@@ -39,13 +37,12 @@ module StreamSend
39
37
 
40
38
  before do
41
39
  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 => {'Content-Type' => 'text/xml'})
40
+ stub_request(:get, "http://test:password@default.base/audiences/1/blasts/sent.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
44
41
  scheduler.execute
45
42
  end
46
43
 
47
44
  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")
45
+ expect(scheduler.uri).to eq("http://default.base/audiences/1/blasts/sent.xml")
49
46
  end
50
47
  end
51
48
 
@@ -11,23 +11,21 @@ module StreamSend
11
11
  let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bounces type=\"array\"><bounce><test type=\"integer\">1</test></bounce></bounces>" }
12
12
 
13
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 => {'Content-Type' => 'text/xml'})
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 => {'Content-Type' => 'text/xml'})
18
- soft_bounce.execute(blast_id)
14
+ stub_request(:get, "http://test:password@default.base/blasts/15/bounces/soft.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
15
+ stub_request(:get, "http://test:password@default.base/blasts/15/bounces/hard.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
19
16
  hard_bounce.execute(blast_id)
17
+ soft_bounce.execute(blast_id)
20
18
  end
21
19
 
22
20
  describe Soft do
23
21
  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")
22
+ expect(soft_bounce.uri).to eq("http://default.base/blasts/15/bounces/soft.xml")
25
23
  end
26
24
  end
27
25
 
28
26
  describe Hard do
29
27
  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")
28
+ expect(hard_bounce.uri).to eq("http://default.base/blasts/15/bounces/hard.xml")
31
29
  end
32
30
  end
33
31
  end
@@ -11,21 +11,21 @@ module StreamSend
11
11
  let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><clicks type=\"array\"><click><test type=\"integer\">1</test></click></clicks>" }
12
12
 
13
13
  before do
14
- stub_request(:get, "https://test:pass@default.base/blasts/1/links/1/clicks.xml?page=1&per_page=100").
14
+ stub_request(:get, "https://test:pass@default.base/blasts/1/links/1/clicks.xml").
15
15
  to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
16
- stub_request(:get, "https://test:pass@default.base/blasts/1/clicks.xml?page=1&per_page=100").
16
+ stub_request(:get, "https://test:pass@default.base/blasts/1/clicks.xml").
17
17
  to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
18
18
  end
19
19
 
20
20
  describe Index do
21
21
  it "creates a uri for blast clicks" do
22
22
  indexer.execute(blast_id)
23
- expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/clicks.xml?page=1&per_page=100")
23
+ expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/clicks.xml")
24
24
  end
25
25
 
26
26
  it "creates a uri for a link click if link id is provided" do
27
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")
28
+ expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/links/#{link_id}/clicks.xml")
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,63 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ describe HashXmlSerializer do
6
+ describe "#serialize" do
7
+ let(:hash_serializer) { HashXmlSerializer.new }
8
+ let(:simple_hash) { { :simple_hash => { :id => 101, :name => "test" } } }
9
+ let(:nested_hash) { { :nested_hash => { :parent_hash => { :child_hash => { :child_value => "Valuable!" }, :child_array => [1,2,3] } } } }
10
+
11
+ before do
12
+ @simple_xml =<<-XML
13
+ <?xml version="1.0" encoding="UTF-8"?>
14
+ <simple-hash>
15
+ <id>101</id>
16
+ <name>test</name>
17
+ </simple-hash>
18
+ XML
19
+
20
+ @nested_xml =<<-XML
21
+ <?xml version="1.0" encoding="UTF-8"?>
22
+ <nested-hash>
23
+ <parent-hash>
24
+ <child-hash>
25
+ <child-value>Valuable!</child-value>
26
+ </child-hash>
27
+ <child-array>1, 2, 3</child-array>
28
+ </parent-hash>
29
+ </nested-hash>
30
+ XML
31
+ end
32
+
33
+
34
+ it "serializes a simple hash" do
35
+ xml = hash_serializer.serialize(simple_hash)
36
+ xml.should == @simple_xml
37
+ end
38
+
39
+ it "serializes a nested hash" do
40
+ xml = hash_serializer.serialize(nested_hash)
41
+ xml.should == @nested_xml
42
+ end
43
+
44
+ it "adds an attribute for nil valued tags" do
45
+ simple_hash[:simple_hash][:something_nilly] = nil
46
+ xml = hash_serializer.serialize(simple_hash)
47
+ xml.should include("<something-nilly nil=\"true\"/>")
48
+ end
49
+
50
+ it "uses the root option value for naming the root tag" do
51
+ xml = hash_serializer.serialize(simple_hash, {:root => "crazy"})
52
+ xml.should include("<crazy>")
53
+ xml.should include("</crazy>")
54
+ end
55
+
56
+ it "doesn't add a instruct tag before the xml result if instruct! set to false" do
57
+ xml = hash_serializer.serialize(simple_hash, {:skip_instruct => true})
58
+ xml.should_not include("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -13,10 +13,10 @@ module StreamSend
13
13
 
14
14
  describe Index do
15
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").
16
+ stub_request(:get, "https://test:password@default.base/blasts/1/links.xml").
17
17
  to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
18
18
  indexer.execute(blast_id)
19
- expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/links.xml?page=1&per_page=100")
19
+ expect(indexer.uri).to eq("https://default.base/blasts/#{blast_id}/links.xml")
20
20
  end
21
21
  end
22
22
 
@@ -17,27 +17,41 @@ module StreamSend
17
17
 
18
18
  describe Index do
19
19
  it "returns a uri for an index of memberships" do
20
- stub_request(:get, "https://test:password@default.base/audiences/1/people/123/memberships.xml?page=1&per_page=100").
21
- to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
20
+ stub_request(:get, "https://test:password@default.base/audiences/1/people/123/memberships.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
22
21
  indexer = Index.new(session)
23
22
  indexer.execute(person_id)
24
- expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/memberships.xml?page=1&per_page=100")
23
+ expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/memberships.xml")
25
24
  end
26
25
 
27
26
  it "returns a uri for an index of memberships with custom paging" do
28
- stub_request(:get, "https://test:password@default.base/audiences/1/people/123/memberships.xml?page=12&per_page=200").
29
- to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
27
+ stub_request(:get, "https://test:password@default.base/audiences/1/people/123/memberships.xml?page=12&per_page=200").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
30
28
  indexer = Index.new(session)
31
29
  indexer.execute(person_id, nil, options)
32
- expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/memberships.xml?page=12&per_page=200")
30
+ expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/memberships.xml")
33
31
  end
34
32
 
35
33
  it "returns a uri for an index of memberships by list id" do
36
- stub_request(:get, "https://test:password@default.base/audiences/1/people/123/lists/456/memberships.xml?page=1&per_page=100").
37
- to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
34
+ stub_request(:get, "https://test:password@default.base/audiences/1/people/123/lists/456/memberships.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
38
35
  indexer = Index.new(session)
39
36
  indexer.execute(person_id, list_id)
40
- expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/lists/#{list_id}/memberships.xml?page=1&per_page=100")
37
+ expect(indexer.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/lists/#{list_id}/memberships.xml")
38
+ end
39
+ end
40
+
41
+ describe Count do
42
+ it "builds a people count URI" do
43
+ stub_request(:get, "https://test:password@default.base/audiences/1/people/123/memberships/count.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
44
+ counter = Count.new(session)
45
+ counter.execute(person_id)
46
+ expect(counter.uri).to eq("https://default.base/audiences/#{audience_id}/people/#{person_id}/memberships/count.xml")
47
+ end
48
+
49
+ it "builds a lists count URI" do
50
+ stub_request(:get, "https://test:password@default.base/audiences/1/lists/456/memberships/count.xml").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
51
+ counter = Count.new(session)
52
+ counter.execute(nil, list_id)
53
+ expect(counter.uri).to eq("https://default.base/audiences/#{audience_id}/lists/#{list_id}/memberships/count.xml")
54
+
41
55
  end
42
56
  end
43
57
  end
@@ -22,17 +22,16 @@ module StreamSend
22
22
 
23
23
  describe Index do
24
24
  it "returns a uri for a person index" do
25
- stub_request(:get, "https://test:password@default.base/audiences/1/people.xml?page=1&per_page=100").
25
+ stub_request(:get, "https://test:password@default.base/audiences/1/people.xml").
26
26
  to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
27
27
  indexer.execute
28
- expect(indexer.uri).to eq("https://default.base/audiences/1/people.xml?page=1&per_page=100")
28
+ expect(indexer.uri).to eq("https://default.base/audiences/1/people.xml")
29
29
  end
30
30
 
31
31
  it "returns a uri with custom paging" do
32
- stub_request(:get, "https://test:password@default.base/audiences/1/people.xml?page=12&per_page=222").
33
- to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
32
+ stub_request(:get, "https://test:password@default.base/audiences/1/people.xml?page=12&per_page=222").to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
34
33
  indexer.execute(nil, options)
35
- expect(indexer.uri).to eq("https://default.base/audiences/1/people.xml?page=12&per_page=222")
34
+ expect(indexer.uri).to eq("https://default.base/audiences/1/people.xml")
36
35
  end
37
36
 
38
37
  it "returns a uri with a scoping by list" do
@@ -46,17 +45,17 @@ module StreamSend
46
45
  describe Click do
47
46
  let(:clicker){ StreamSend::Api::Person::Click.new(session) }
48
47
  it "creates a uri for blast click people" do
49
- stub_request(:get, "https://test:password@default.base/blasts/1/clicks/people.xml?page=1&per_page=100").
48
+ stub_request(:get, "https://test:password@default.base/blasts/1/clicks/people.xml").
50
49
  to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
51
50
  clicker.execute(blast_id)
52
- expect(clicker.uri).to eq("https://default.base/blasts/#{blast_id}/clicks/people.xml?page=1&per_page=100")
51
+ expect(clicker.uri).to eq("https://default.base/blasts/#{blast_id}/clicks/people.xml")
53
52
  end
54
53
 
55
54
  it "creates uri for specific link click people" do
56
- stub_request(:get, "https://test:password@default.base/blasts/1/links/1/clicks/people.xml?page=1&per_page=100").
55
+ stub_request(:get, "https://test:password@default.base/blasts/1/links/1/clicks/people.xml").
57
56
  to_return(:status => 200, :body => xml, :headers => {"Content-type" => "text/xml"})
58
57
  clicker.execute(blast_id, link_id)
59
- expect(clicker.uri).to eq("https://default.base/blasts/#{blast_id}/links/#{link_id}/clicks/people.xml?page=1&per_page=100")
58
+ expect(clicker.uri).to eq("https://default.base/blasts/#{blast_id}/links/#{link_id}/clicks/people.xml")
60
59
  end
61
60
  end
62
61
 
@@ -67,10 +66,10 @@ module StreamSend
67
66
  let(:blast_id){ 1 }
68
67
 
69
68
  it "creates a uri for blast view people" do
70
- stub_request(:get, "https://test:password@default.base/blasts/1/views/people.xml?page=1&per_page=100").
69
+ stub_request(:get, "https://test:password@default.base/blasts/1/views/people.xml").
71
70
  to_return(:status => 200, :body => xml, :headers => {"Content-type" => "text/xml"})
72
71
  peopler.execute(blast_id)
73
- expect(peopler.uri).to eq("https://default.base/blasts/#{blast_id}/views/people.xml?page=1&per_page=100")
72
+ expect(peopler.uri).to eq("https://default.base/blasts/#{blast_id}/views/people.xml")
74
73
  end
75
74
  end
76
75