streamsend 0.2.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +18 -5
  2. data/.rspec +1 -0
  3. data/Gemfile +2 -1
  4. data/Gemfile.lock +25 -17
  5. data/README.md +76 -0
  6. data/Rakefile +1 -2
  7. data/lib/streamsend/api/account.rb +6 -48
  8. data/lib/streamsend/api/audience.rb +14 -0
  9. data/lib/streamsend/api/base/base_call.rb +60 -0
  10. data/lib/streamsend/api/base/create.rb +41 -0
  11. data/lib/streamsend/api/base/destroy.rb +43 -0
  12. data/lib/streamsend/api/base/index.rb +51 -0
  13. data/lib/streamsend/api/base/show.rb +42 -0
  14. data/lib/streamsend/api/base/update.rb +43 -0
  15. data/lib/streamsend/api/blast.rb +51 -0
  16. data/lib/streamsend/api/bounce.rb +20 -0
  17. data/lib/streamsend/api/click.rb +18 -0
  18. data/lib/streamsend/api/configuration.rb +26 -0
  19. data/lib/streamsend/api/email.rb +20 -0
  20. data/lib/streamsend/api/exception.rb +4 -4
  21. data/lib/streamsend/api/field.rb +20 -0
  22. data/lib/streamsend/api/field_option.rb +60 -0
  23. data/lib/streamsend/api/filter.rb +20 -0
  24. data/lib/streamsend/api/from_email_address.rb +24 -0
  25. data/lib/streamsend/api/import.rb +11 -0
  26. data/lib/streamsend/api/link.rb +11 -0
  27. data/lib/streamsend/api/list.rb +13 -39
  28. data/lib/streamsend/api/membership.rb +28 -0
  29. data/lib/streamsend/api/person.rb +66 -0
  30. data/lib/streamsend/api/result.rb +13 -0
  31. data/lib/streamsend/api/session.rb +73 -0
  32. data/lib/streamsend/api/unsubscribe.rb +20 -0
  33. data/lib/streamsend/api/upload.rb +13 -0
  34. data/lib/streamsend/api/user.rb +67 -38
  35. data/lib/streamsend/api/view.rb +8 -0
  36. data/lib/streamsend/version.rb +3 -0
  37. data/lib/streamsend.rb +35 -16
  38. data/spec/lib/streamsend/api/integration/account_spec.rb +50 -0
  39. data/spec/lib/streamsend/api/integration/audience_spec.rb +56 -0
  40. data/spec/lib/streamsend/api/integration/blast_spec.rb +110 -0
  41. data/spec/lib/streamsend/api/integration/bounce_spec.rb +43 -0
  42. data/spec/lib/streamsend/api/integration/click_spec.rb +37 -0
  43. data/spec/lib/streamsend/api/integration/email_spec.rb +76 -0
  44. data/spec/lib/streamsend/api/integration/field_option_spec.rb +87 -0
  45. data/spec/lib/streamsend/api/integration/field_spec.rb +75 -0
  46. data/spec/lib/streamsend/api/integration/filter_spec.rb +101 -0
  47. data/spec/lib/streamsend/api/integration/from_email_address_spec.rb +46 -0
  48. data/spec/lib/streamsend/api/integration/helpers.rb +16 -0
  49. data/spec/lib/streamsend/api/integration/import_spec.rb +35 -0
  50. data/spec/lib/streamsend/api/integration/link_spec.rb +39 -0
  51. data/spec/lib/streamsend/api/integration/list_spec.rb +83 -0
  52. data/spec/lib/streamsend/api/integration/membership_spec.rb +69 -0
  53. data/spec/lib/streamsend/api/integration/person_spec.rb +119 -0
  54. data/spec/lib/streamsend/api/integration/unsubscribe_spec.rb +47 -0
  55. data/spec/lib/streamsend/api/integration/upload_spec.rb +29 -0
  56. data/spec/lib/streamsend/api/integration/user_spec.rb +99 -0
  57. data/spec/lib/streamsend/api/integration/view_spec.rb +27 -0
  58. data/spec/lib/streamsend/api/unit/base/base_call_spec.rb +66 -0
  59. data/spec/lib/streamsend/api/unit/base/create_spec.rb +67 -0
  60. data/spec/lib/streamsend/api/unit/base/destroy_spec.rb +59 -0
  61. data/spec/lib/streamsend/api/unit/base/index_spec.rb +85 -0
  62. data/spec/lib/streamsend/api/unit/base/show_spec.rb +68 -0
  63. data/spec/lib/streamsend/api/unit/base/update_spec.rb +76 -0
  64. data/spec/lib/streamsend/api/unit/blast_spec.rb +79 -0
  65. data/spec/lib/streamsend/api/unit/bounce_spec.rb +36 -0
  66. data/spec/lib/streamsend/api/unit/click_spec.rb +34 -0
  67. data/spec/lib/streamsend/api/unit/field_option_spec.rb +71 -0
  68. data/spec/lib/streamsend/api/unit/from_email_address_spec.rb +20 -0
  69. data/spec/lib/streamsend/api/unit/link_spec.rb +33 -0
  70. data/spec/lib/streamsend/api/unit/list_spec.rb +33 -0
  71. data/spec/lib/streamsend/api/unit/membership_spec.rb +46 -0
  72. data/spec/lib/streamsend/api/unit/person_spec.rb +102 -0
  73. data/spec/lib/streamsend/api/unit/result_spec.rb +13 -0
  74. data/spec/lib/streamsend/api/unit/session_spec.rb +62 -0
  75. data/spec/lib/streamsend/api/unit/unsubscribe_spec.rb +33 -0
  76. data/spec/lib/streamsend/api/unit/user_spec.rb +102 -0
  77. data/spec/spec_helper.rb +8 -11
  78. data/streamsend.gemspec +22 -23
  79. metadata +250 -178
  80. checksums.yaml +0 -7
  81. data/.pair +0 -10
  82. data/README.rdoc +0 -1
  83. data/lib/streamsend/api/resource.rb +0 -41
  84. data/lib/streamsend/api/subscriber.rb +0 -113
  85. data/spec/integration/account_spec.rb +0 -69
  86. data/spec/integration/fixtures/vcr_cassettes/streamsend.yml +0 -6831
  87. data/spec/integration/integration.yml +0 -5
  88. data/spec/integration/list_spec.rb +0 -68
  89. data/spec/integration/spec_helper.rb +0 -16
  90. data/spec/integration/subscriber_spec.rb +0 -24
  91. data/spec/integration/user_spec.rb +0 -58
  92. data/spec/lib/streamsend/api/list_spec.rb +0 -179
  93. data/spec/lib/streamsend/api/resource_spec.rb +0 -24
  94. data/spec/lib/streamsend/api/subscriber_spec.rb +0 -345
  95. data/spec/lib/streamsend/api/user_spec.rb +0 -149
  96. data/spec/lib/streamsend/api_spec.rb +0 -31
  97. data/watcher_config.rb +0 -2
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Account
6
+ describe "Account calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:first_user){ StreamSend::Api::User::Index.new(session).execute.first }
9
+ let(:randomish){ DateTime.now.to_i.to_s }
10
+ let(:owner_email){ "me+#{randomish}@testing.this" }
11
+ let(:owner_hash){ { :email_address => owner_email, :password => "passwordyo", :first_name => "Test", :last_name => "User", :administrator => true} }
12
+ let(:company_hash){ {:first_name => "first", :last_name => "last", :company_name => "company",
13
+ :email => "company@email.cocococo", :address_1 => "123 Fourth Street",
14
+ :city => "This one", :state => "CA", :postal_code => "55555", :country => "USA",
15
+ :phone => 5555555555, :industry => "industry", :how_heard => "cow herd"} }
16
+ let(:account_hash) { {:account => { :plan_id => 125, :quota => 100, :owner => owner_hash, :company_information => company_hash } } }
17
+
18
+
19
+ before do
20
+ WebMock.disable!
21
+ end
22
+
23
+ after do
24
+ WebMock.enable!
25
+ end
26
+
27
+ describe Index do
28
+ it "returns the accounts" do
29
+ accounts = StreamSend::Api::Account::Index.new(session).execute
30
+ expect(accounts.count).to be > 0
31
+ end
32
+ end
33
+
34
+ describe Show do
35
+ it "should show a account by id" do
36
+ pending "Billing service could not be setup."
37
+ creator = StreamSend::Api::Account::Create.new(session)
38
+ account_id = creator.execute(account_hash)
39
+ shower = StreamSend::Api::Acocunt.Show(session)
40
+ account = shower.execute(account_id)
41
+ expect(account.id).to eq(account_id)
42
+ expect(account.quota).to eq(account_hash.quota)
43
+ expect(account.owner.email_address).to eq(account_hash.owner.email_address)
44
+ #destroy account
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ class Audience
6
+ describe "Audience calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:shower){ Show.new(session) }
9
+ before do
10
+ WebMock.disable!
11
+ @audience_id = 1
12
+ @audience_hash = { :audience => { :name => "new name #{DateTime.now.to_i.to_s}" } }
13
+ end
14
+
15
+ after do
16
+ WebMock.enable!
17
+ end
18
+
19
+ describe Index do
20
+ let(:indexer){ Index.new(session) }
21
+
22
+ describe "#execute" do
23
+ it "returns an array of audiences" do
24
+ audiences = indexer.execute
25
+ expect(audiences.count).to be == 1
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+ describe Show do
32
+
33
+ describe "#execute" do
34
+ it "returns an audience by id" do
35
+ audience = shower.execute(@audience_id)
36
+ expect(audience.id).to eq(@audience_id)
37
+ end
38
+ end
39
+ end
40
+
41
+
42
+ describe Update do
43
+ let(:updater){ StreamSend::Api::Audience::Update.new(session) }
44
+ describe "#execute" do
45
+ it "updates the name of the audience" do
46
+ updated = updater.execute(@audience_id, @audience_hash)
47
+ expect(updated).to eq(true)
48
+ audience = shower.execute(@audience_id)
49
+ expect(audience.name).to eq(@audience_hash[:audience][:name])
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,110 @@
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() }
8
+ let(:list_hash){ { :list => { :name => "New list #{DateTime.now.to_i.to_s}" } } }
9
+ let(:list_id){ StreamSend::Api::List::Create.new(session).execute(list_hash) }
10
+ let(:future_date){ DateTime.now + 1.day }
11
+
12
+ before do
13
+ WebMock.disable!
14
+ from_addresses = StreamSend::Api::FromEmailAddress::Index.new(session).execute
15
+ from_addy = from_addresses.select{ |address| address.activated == true }.first
16
+ from = {:name => "Mister Tester", :email_address => from_addy.email_address}
17
+ @blast_obj = { :blast => { :subject => "Tesing yo.", :body => { :text_part => "test email" }, :to => { :include_lists => list_id.to_s, :audience_id => 1 }, :scheduled_for => future_date, :from => from } }
18
+ @test_obj = { :blast => { :subject => "Tesing yo.", :body => { :text_part => "test email" }, :to => "testy@testy.mctest" , :scheduled_for => future_date, :from => from } }
19
+ end
20
+
21
+ after do
22
+ WebMock.enable!
23
+ end
24
+
25
+ describe Index do
26
+ it "returns an index of blasts" do
27
+ index = Index.new(session)
28
+ blasts = index.execute
29
+ expect(blasts.count).to be > 0
30
+ end
31
+ end
32
+
33
+ describe Scheduled do
34
+ it "returns scheduled blasts if there are any" do
35
+ scheduler = Scheduled.new(session)
36
+ scheduled = scheduler.execute
37
+ if scheduled.count > 0
38
+ scheduled_values = ["scheduled", "preparing"]
39
+ expect(scheduled_values).to include(scheduled[0].status)
40
+ else
41
+ pending "No scheduled blasts at this time to inspect or something went wrong."
42
+ end
43
+ end
44
+ end
45
+
46
+ describe Sent do
47
+ it "returns sent blasts" do
48
+ senter = Sent.new(session)
49
+ sent = senter.execute
50
+ expect(sent.count).to be > 0
51
+ expect(sent[0].status).to eq("sent")
52
+ end
53
+ end
54
+
55
+ describe Show do
56
+ it "returns a blast by id" do
57
+ creator = Create.new(session)
58
+ id = creator.execute(@blast_obj)
59
+ shower = Show.new(session)
60
+ show = shower.execute(id)
61
+ expect(show.subject).to eq(@blast_obj[:blast][:subject])
62
+ end
63
+ end
64
+
65
+ describe Update do
66
+ it "updates a blast" do
67
+ pending "fails intermittently due to locked blast."
68
+ creator = Create.new(session)
69
+ id = creator.execute(@blast_obj)
70
+ shower = Show.new(session)
71
+ show = shower.execute(id)
72
+ show.scheduled_for = DateTime.now + 10.days
73
+
74
+ updater = Update.new(session)
75
+ updater.execute(id, {:blast => show.to_hash})
76
+
77
+ new_show = shower.execute(id)
78
+ expect(DateTime.parse new_show.scheduled_for).to be > future_date
79
+
80
+ destroyer = Destroy.new(session)
81
+ destroyer.execute(id)
82
+ end
83
+ end
84
+
85
+ describe Destroy do
86
+ it "destroys a blast" do
87
+ pending "fails intermittently due to locked blast."
88
+ creator = Create.new(session)
89
+ id = creator.execute(@blast_obj)
90
+
91
+ destroyer = Destroy.new(session)
92
+ destroyer.execute(id)
93
+
94
+ expect do
95
+ shower = Show.new(session)
96
+ blast = shower.execute(id)
97
+ end.to raise_exception(StreamSend::Api::Exception, "Could not find any blasts with the specified id. (404)")
98
+ end
99
+ end
100
+
101
+ describe Test do
102
+ it "sends a test blast" do
103
+ tester = Test.new(session)
104
+ expect(tester.execute(@test_obj)).to eq(200)
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,43 @@
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() }
8
+ before do
9
+ WebMock.disable!
10
+ @blast_id = 70011
11
+ end
12
+
13
+ after do
14
+ WebMock.enable!
15
+ end
16
+
17
+ describe Index do
18
+ let(:indexer){ Index.new(session) }
19
+ let(:softer){ Soft.new(session) }
20
+ let(:harder){ Hard.new(session) }
21
+
22
+ describe "#execute" do
23
+ it "returns an array of bounces" do
24
+ bounces = indexer.execute(@blast_id)
25
+ expect(bounces.count).to be <= 1
26
+ end
27
+
28
+ it "returns an array of hard bounces" do
29
+ bounces = harder.execute(@blast_id)
30
+ expect(bounces.count).to eq(0) #can't create a hard bounce :/
31
+ end
32
+
33
+ it "returns an array of soft bounces" do
34
+ bounces = softer.execute(@blast_id)
35
+ expect(bounces.count).to eq(1)
36
+ expect(bounces[0].bounce_type).to eq("soft")
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,37 @@
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() }
8
+ let(:blast_id) { 70361 }
9
+ let(:link_id) { 27581 }
10
+
11
+ before do
12
+ WebMock.disable!
13
+ end
14
+
15
+ after do
16
+ WebMock.enable!
17
+ end
18
+
19
+ describe Index do
20
+ let(:indexer){ Index.new(session) }
21
+
22
+ describe "#execute" do
23
+ it "returns an array of clicks" do
24
+ bounces = indexer.execute(blast_id)
25
+ expect(bounces.count).to be > 0
26
+ end
27
+
28
+ it "returns an array of clicks by link_id" do
29
+ bounces = indexer.execute(blast_id, link_id)
30
+ expect(bounces.count).to be > 0
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Email
6
+ describe "Email calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:email_hash){ { :email => { :name => "New Email #{DateTime.now.to_i.to_s}", :text_part => "test part!" } } }
9
+
10
+ before do
11
+ WebMock.disable!
12
+ end
13
+
14
+ after do
15
+ WebMock.enable!
16
+ end
17
+
18
+ describe Index do
19
+ it "returns an array of emails" do
20
+ pending "This is a resource hog right now -- returns everything"
21
+ indexer = Index.new(session)
22
+ emails = indexer.execute
23
+ expect(emails.count).to be > 0
24
+ end
25
+ end
26
+
27
+ describe Show do
28
+ it "returns a email by id" do
29
+ creator = Create.new(session)
30
+ id = creator.execute(email_hash)
31
+ shower = Show.new(session)
32
+ email = shower.execute(id)
33
+ expect(email.name).to eq(email_hash[:email][:name])
34
+ expect(email.id).to eq(id)
35
+
36
+ destroyer = Destroy.new(session)
37
+ destroyer.execute(id)
38
+ end
39
+ end
40
+
41
+ describe Update do
42
+ it "updates an email" do
43
+ creator = Create.new(session)
44
+ id = creator.execute(email_hash)
45
+ shower = Show.new(session)
46
+ email = shower.execute(id)
47
+ email.text_part = "Da new text parts!"
48
+ updater = Update.new(session)
49
+ updater.execute(id, email.marshal_dump)
50
+ email_updated = shower.execute(id)
51
+ expect(email_updated.name).to eq(email_hash[:email][:name])
52
+ expect(email_updated.id).to eq(id)
53
+
54
+ destroyer = Destroy.new(session)
55
+ destroyer.execute(id)
56
+ end
57
+ end
58
+
59
+ describe Destroy do
60
+ it "destroys a email" do
61
+ creator = Create.new(session)
62
+ id = creator.execute(email_hash)
63
+
64
+ destroyer = Destroy.new(session)
65
+ destroyer.execute(id)
66
+
67
+ expect do
68
+ shower = Show.new(session)
69
+ email = shower.execute(id)
70
+ end.to raise_exception(StreamSend::Api::Exception, "Could not find any emails with the specified id. (404)")
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,87 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Option
6
+ describe "Option calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:field_hash){ { :field => { :name => "New field #{DateTime.now.to_i.to_s}", :data_type => "Select" } } }
9
+ let(:option_hash){ { :option => { :name => "New field #{DateTime.now.to_i.to_s}" } } }
10
+
11
+ before do
12
+ WebMock.disable!
13
+ field_creator = StreamSend::Api::Field::Create.new(session)
14
+ @field_id = field_creator.execute(field_hash)
15
+ end
16
+
17
+ after do
18
+ WebMock.enable!
19
+ end
20
+
21
+
22
+ describe Index do
23
+ it "returns an array of options" do
24
+ creator = Create.new(session)
25
+ id = creator.execute(@field_id, option_hash)
26
+
27
+ indexer = Index.new(session)
28
+ options = indexer.execute(@field_id)
29
+ expect(options.count).to be > 0
30
+
31
+ destroyer = Destroy.new(session)
32
+ destroyer.execute(@field_id, id)
33
+ end
34
+ end
35
+
36
+ describe Show do
37
+ it "returns a options by id" do
38
+ creator = Create.new(session)
39
+ id = creator.execute(@field_id, option_hash)
40
+
41
+ shower = Show.new(session)
42
+ option = shower.execute(@field_id, id)
43
+ expect(option.name).to eq(option_hash[:option][:name])
44
+ expect(option.id).to eq(id)
45
+
46
+ destroyer = Destroy.new(session)
47
+ destroyer.execute(@field_id, id)
48
+ end
49
+ end
50
+
51
+ describe Update do
52
+ it "updates an field" do
53
+ creator = Create.new(session)
54
+ id = creator.execute(@field_id, option_hash)
55
+
56
+ shower = Show.new(session)
57
+ option = shower.execute(@field_id, id)
58
+ option.name = "new options."
59
+ updater = Update.new(session)
60
+ updater.execute(@field_id, id, option.marshal_dump)
61
+ option_updated = shower.execute(@field_id, id)
62
+ expect(option_updated.name).to eq(option_hash[:option][:name])
63
+ expect(option_updated.id).to eq(id)
64
+
65
+ destroyer = Destroy.new(session)
66
+ destroyer.execute(@field_id, id)
67
+ end
68
+ end
69
+
70
+ describe Destroy do
71
+ it "destroys a field option" do
72
+ creator = Create.new(session)
73
+ id = creator.execute(@field_id, option_hash)
74
+
75
+ destroyer = Destroy.new(session)
76
+ destroyer.execute(@field_id, id)
77
+
78
+ expect do
79
+ shower = Show.new(session)
80
+ option_hash = shower.execute(@field_id, id)
81
+ end.to raise_exception(StreamSend::Api::Exception, "Could not find any options with the specified id. (404)")
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Field
6
+ describe "Field calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:field_hash){ { :field => { :name => "New field #{DateTime.now.to_i.to_s}", :data_type => "Text Area" } } }
9
+
10
+ before do
11
+ WebMock.disable!
12
+ end
13
+
14
+ after do
15
+ WebMock.enable!
16
+ end
17
+
18
+ describe Index do
19
+ it "returns an array of fields" do
20
+ indexer = Index.new(session)
21
+ fields = indexer.execute
22
+ expect(fields.count).to be > 0
23
+ end
24
+ end
25
+
26
+ describe Show do
27
+ it "returns a field by id" do
28
+ creator = Create.new(session)
29
+ id = creator.execute(field_hash)
30
+ shower = Show.new(session)
31
+ field = shower.execute(id)
32
+ expect(field.name).to eq(field_hash[:field][:name])
33
+ expect(field.id).to eq(id)
34
+
35
+ destroyer = Destroy.new(session)
36
+ destroyer.execute(id)
37
+ end
38
+ end
39
+
40
+ describe Update do
41
+ it "updates an field" do
42
+ creator = Create.new(session)
43
+ id = creator.execute(field_hash)
44
+ shower = Show.new(session)
45
+ field = shower.execute(id)
46
+ field.name = "newer namers!"
47
+ updater = Update.new(session)
48
+ updater.execute(id, field.marshal_dump)
49
+ field_updated = shower.execute(id)
50
+ expect(field_updated.name).to eq(field_hash[:field][:name])
51
+ expect(field_updated.id).to eq(id)
52
+
53
+ destroyer = Destroy.new(session)
54
+ destroyer.execute(id)
55
+ end
56
+ end
57
+
58
+ describe Destroy do
59
+ it "destroys a field" do
60
+ creator = Create.new(session)
61
+ id = creator.execute(field_hash)
62
+
63
+ destroyer = Destroy.new(session)
64
+ destroyer.execute(id)
65
+
66
+ expect do
67
+ shower = Show.new(session)
68
+ field = shower.execute(id)
69
+ end.to raise_exception(StreamSend::Api::Exception, "Could not find any fields with the specified id. (404)")
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,101 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module Filter
6
+ describe "Filter calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:randomish){ DateTime.now.to_i.to_s }
9
+ let(:filter_hash){ { :filter => { :name => "Test Filter #{randomish}", :description => "Filter for testing" } } }
10
+ let(:field_hash){ { :field => { :name => "New field #{randomish}", :data_type => "Text Area" } } }
11
+ let(:field_id){ StreamSend::Api::Field::Create.new(session).execute(field_hash) }
12
+ let(:option_hash){ { :option => { :name => "New field #{randomish}" } } }
13
+ let(:option_id){ StreamSend::Api::Option::Create(session).execute(field_id, option_hash) }
14
+ let(:rule){ { :operator => "==", :field_option_id => option_id } }
15
+ let(:block){ { :field_id => field_id, :rules => :rule } }
16
+ let(:complex_filter_hash){ { :filter => { :name => "Test Filter #{randomish}", :description => "Filter for testing", :blocks => block } } }
17
+
18
+ before do
19
+ WebMock.disable!
20
+ end
21
+
22
+ after do
23
+ WebMock.enable!
24
+ end
25
+
26
+ describe Index do
27
+ it "returns an array of filters" do
28
+ creator = Create.new(session)
29
+ id = creator.execute(filter_hash)
30
+
31
+ indexer = Index.new(session)
32
+ filter = indexer.execute
33
+ expect(filter.count).to be > 0
34
+
35
+ destroyer = Destroy.new(session)
36
+ destroyer.execute(id)
37
+ end
38
+ end
39
+
40
+ describe Show do
41
+ it "returns a filter by id" do
42
+ creator = Create.new(session)
43
+ id = creator.execute(filter_hash)
44
+ shower = Show.new(session)
45
+ filter = shower.execute(id)
46
+ expect(filter.name).to eq(filter_hash[:filter][:name])
47
+ expect(filter.id).to eq(id)
48
+
49
+ destroyer = Destroy.new(session)
50
+ destroyer.execute(id)
51
+ end
52
+
53
+ it "returns a complex filter by id" do
54
+ creator = Create.new(session)
55
+ id = creator.execute(complex_filter_hash)
56
+ shower = Show.new(session)
57
+ filter = shower.execute(id)
58
+ expect(filter.name).to eq(filter_hash[:filter][:name])
59
+ expect(filter.id).to eq(id)
60
+
61
+ destroyer = Destroy.new(session)
62
+ destroyer.execute(id)
63
+ end
64
+ end
65
+
66
+ describe Update do
67
+ it "updates an filter" do
68
+ creator = Create.new(session)
69
+ id = creator.execute(filter_hash)
70
+ shower = Show.new(session)
71
+ filter = shower.execute(id)
72
+ filter.name = "newer namers!"
73
+ updater = Update.new(session)
74
+ updater.execute(id, filter.marshal_dump)
75
+ filter_updated = shower.execute(id)
76
+ expect(filter_updated.name).to eq(filter_hash[:filter][:name])
77
+ expect(filter_updated.id).to eq(id)
78
+
79
+ destroyer = Destroy.new(session)
80
+ destroyer.execute(id)
81
+ end
82
+ end
83
+
84
+ describe Destroy do
85
+ it "destroys a filter" do
86
+ creator = Create.new(session)
87
+ id = creator.execute(filter_hash)
88
+
89
+ destroyer = Destroy.new(session)
90
+ destroyer.execute(id)
91
+
92
+ expect do
93
+ shower = Show.new(session)
94
+ filter = shower.execute(id)
95
+ end.to raise_exception(StreamSend::Api::Exception, "Could not find any filters with the specified id. (404)")
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ module StreamSend
4
+ module Api
5
+ module FromEmailAddress
6
+ describe "FromEmailAddress calls" do
7
+ let(:session){ StreamSend::Api::Session.new() }
8
+ let(:email_hash){ { :from_email_address => { :email_address => "testing+#{DateTime.now.to_i.to_s}@badd.address" } } }
9
+
10
+ before do
11
+ WebMock.disable!
12
+ end
13
+
14
+ after do
15
+ WebMock.enable!
16
+ end
17
+
18
+ describe Index do
19
+ it "returns an index of from email addresses" do
20
+ indexer = Index.new(session)
21
+ expect(indexer.execute.count).to be > 0
22
+ end
23
+ end
24
+
25
+ describe Show do
26
+ it "shows a from email address by id" do
27
+ creator = Create.new(session)
28
+ address_id = creator.execute(email_hash)
29
+ shower = Show.new(session)
30
+ address = shower.execute(address_id)
31
+ expect(address.email_address).to eq(email_hash[:from_email_address][:email_address])
32
+ end
33
+ end
34
+
35
+ describe ResendActivationEmail do
36
+ it "resends the actiation email" do
37
+ creator = Create.new(session)
38
+ address_id = creator.execute(email_hash)
39
+ response = ResendActivationEmail.new(session).execute(address_id)
40
+ expect(response.code).to eq(200)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end