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.
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
@@ -1,5 +0,0 @@
1
- root_account:
2
- api_username: "rootapiuser"
3
- api_password: <%= ENV['STREAMSEND_PASSWORD'] %>
4
- app_host: "localhost:3000"
5
- account_id: 1
@@ -1,68 +0,0 @@
1
- require "spec_helper"
2
- require File.join(Dir.pwd, "lib/streamsend")
3
- require "integration/spec_helper"
4
- require File.expand_path(__FILE__, "../../exception")
5
-
6
- describe "List API" do
7
- let( :test_list_prefix ) { "Ruby Gem Client API List #" }
8
- let( :test_list_name ) { test_list_prefix }
9
-
10
- before do
11
- account = StreamSend::Api::IntegrationConfiguration.root_account
12
- StreamSend::Api.configure(account.api_username, account.api_password, account.app_host)
13
- end
14
-
15
- after do
16
- VCR.use_cassette('streamsend') do
17
- StreamSend::Api::List.all.select do | list |
18
- list.name == test_list_name
19
- end.each do | list |
20
- list.destroy
21
- end
22
- end
23
- end
24
-
25
- context "#create" do
26
- it "creates a list when given a unique name" do
27
- VCR.use_cassette('streamsend') do
28
- expect {
29
- StreamSend::Api::List.create test_list_name
30
- }.not_to raise_error
31
- end
32
- end
33
-
34
- it "returns the list id" do
35
- VCR.use_cassette('streamsend') do
36
- id = StreamSend::Api::List.create test_list_name
37
- id.should_not be_nil
38
- end
39
- end
40
-
41
- it "creating a new list with an existing name raises an error" do
42
- VCR.use_cassette('streamsend') do
43
- StreamSend::Api::List.create test_list_name
44
- expect {
45
- StreamSend::Api::List.create test_list_name
46
- }.to raise_error
47
- end
48
- end
49
-
50
- it "name is properly set on the list" do
51
- VCR.use_cassette('streamsend') do
52
- id = StreamSend::Api::List.create test_list_name
53
- list = StreamSend::Api::List.find id
54
- list.name.should == test_list_name
55
- end
56
- end
57
- end
58
-
59
- context "#delete" do
60
- it "removes the list" do
61
- VCR.use_cassette('streamsend') do
62
- list_id = StreamSend::Api::List.create test_list_name
63
- list = StreamSend::Api::List.find list_id
64
- list.destroy.should be_true
65
- end
66
- end
67
- end
68
- end
@@ -1,16 +0,0 @@
1
- require "yaml"
2
- require "ostruct"
3
-
4
- module StreamSend
5
- module Api
6
- class IntegrationConfiguration
7
- def self.config
8
- @config ||= YAML.load(ERB.new(IO.read("spec/integration/integration.yml")).result)
9
- end
10
-
11
- def self.root_account
12
- OpenStruct.new(config["root_account"])
13
- end
14
- end
15
- end
16
- end
@@ -1,24 +0,0 @@
1
- require "spec_helper"
2
-
3
- require File.join(Dir.pwd, "lib/streamsend")
4
- require "integration/spec_helper"
5
- require File.expand_path(__FILE__, "../../exception")
6
-
7
- module StreamSend
8
- module Api
9
- describe "Subscriber" do
10
- before do
11
- @account = StreamSend::Api::IntegrationConfiguration.root_account
12
- StreamSend::Api.configure(@account.api_username, @account.api_password, @account.app_host)
13
- end
14
-
15
- describe "with no matching subscriber" do
16
- it "returns nil" do
17
- VCR.use_cassette('streamsend') do
18
- expect(StreamSend::Api::Subscriber.find("bad.email@gmail.com")).to be_nil
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,58 +0,0 @@
1
- require "spec_helper"
2
- require File.join(Dir.pwd, "lib/streamsend")
3
- require "integration/spec_helper.rb"
4
-
5
- describe "user via api" do
6
- before do
7
- account = StreamSend::Api::IntegrationConfiguration.root_account
8
- StreamSend::Api.configure(account.api_username, account.api_password, account.app_host)
9
- end
10
-
11
- it "exists" do
12
- VCR.use_cassette('streamsend') do
13
- the_user = StreamSend::Api::User.all.first
14
- the_user.first_name.should == "Admin"
15
- end
16
- end
17
-
18
- it "gets created" do
19
- VCR.use_cassette('streamsend') do
20
- the_user = StreamSend::Api::User.create(
21
- "password" => "password2",
22
- "password_confirmation" => "password2",
23
- "email_address" => "joe#{Time.now.to_i}@gmail.com",
24
- "first_name" => "Joe",
25
- "last_name" => "user",
26
- "account_id" => 1,
27
- "may_export" => true,
28
- "administrator" => true
29
- )
30
-
31
- saved_user = find_by_email_address("joe@gmail.com")
32
- saved_user.first.id.should > 0
33
- end
34
- end
35
-
36
- it "can be found" do
37
- VCR.use_cassette('streamsend') do
38
- user = StreamSend::Api::User.show(1)
39
- expect(user.class).to eq(StreamSend::Api::User)
40
- end
41
- end
42
-
43
- it "allows us to change the last name" do
44
- VCR.use_cassette('streamsend') do
45
- the_user = StreamSend::Api::User.all.last
46
- expect(the_user.last_name).to eq("user")
47
- response = StreamSend::Api::User.update("account_id" => StreamSend::Api::IntegrationConfiguration.root_account.account_id, "last-name" => "smithy", "user_id" => the_user.id)
48
- new_user = StreamSend::Api::User.show(the_user.id)
49
- expect(new_user.last_name).to eq("smithy")
50
- end
51
- end
52
-
53
- def find_by_email_address(email_address)
54
- the_user = StreamSend::Api::User.all.each do |user|
55
- return user if user.email_address == email_address
56
- end
57
- end
58
- end
@@ -1,179 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
-
3
- module StreamSend
4
- module Api
5
- describe "List" do
6
- let(:app_host) { "http://test.host" }
7
- before do
8
- WebMock.enable!
9
- stub_http_request(:any, //).to_return(:body => "Page not found.", :status => 404)
10
-
11
- @username = "scott"
12
- @password = "topsecret"
13
- @host = "test.host"
14
-
15
- xml = <<-XML
16
- <?xml version="1.0" encoding="UTF-8"?>
17
- <audiences type="array">
18
- <audience>
19
- <id type="integer">2</id>
20
- </audience>
21
- </audiences>
22
- XML
23
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences.xml").to_return(:body => xml)
24
- StreamSend::Api::List.stub(:audience_id).and_return(2)
25
-
26
- StreamSend::Api.configure(@username, @password, @host)
27
- end
28
-
29
- after do
30
- WebMock.disable!
31
- end
32
-
33
- describe ".audience_id" do
34
- it "returns the id of the first audience" do
35
- StreamSend::Api::List.audience_id.should == 2
36
- end
37
- end
38
-
39
- describe ".all" do
40
- describe "with lists" do
41
- before(:each) do
42
- xml = <<-XML
43
- <?xml version="1.0" encoding="UTF-8"?>
44
- <lists type="array">
45
- <list>
46
- <active-people-count type="integer">11</active-people-count>
47
- <checked-by-default type="boolean" nil="true"></checked-by-default>
48
- <created-at type="datetime">2012-01-14T18:11:50Z</created-at>
49
- <deleted-at type="datetime" nil="true"></deleted-at>
50
- <description nil="true"></description>
51
- <id type="integer">42</id>
52
- <inactive-people-count type="integer">0</inactive-people-count>
53
- <name>First list</name>
54
- <pending-people-count type="integer">0</pending-people-count>
55
- <public type="boolean" nil="true"></public>
56
- <status type="enum">idle</status>
57
- <unsubscribed-people-count type="integer">0</unsubscribed-people-count>
58
- <updated-at type="datetime">2012-01-14T18:11:50Z</updated-at>
59
- <audience-id type="integer">2</audience-id>
60
- </list>
61
- </lists>
62
- XML
63
-
64
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/lists.xml").to_return(:body => xml)
65
- end
66
-
67
- it "should return array of one list object" do
68
- lists = StreamSend::Api::List.all
69
- lists.size.should == 1
70
-
71
- lists.first.should be_instance_of(StreamSend::Api::List)
72
- lists.first.id.should == 42
73
- lists.first.name.should == "First list"
74
- lists.first.created_at.should == Time.parse("2012-01-14T18:11:50Z")
75
- end
76
- end
77
-
78
- describe "with no lists" do
79
- before(:each) do
80
- xml = <<-XML
81
- <?xml version="1.0" encoding="UTF-8"?>
82
- <lists type="array"/>
83
- XML
84
-
85
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/lists.xml").to_return(:body => xml)
86
- end
87
-
88
- it "should return an empty array" do
89
- StreamSend::Api::List.all.should == []
90
- end
91
- end
92
-
93
- describe "with invalid audience" do
94
- before(:each) do
95
- xml = <<-XML
96
- <?xml version="1.0" encoding="UTF-8"?>
97
- <people type="array"/>
98
- XML
99
-
100
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml").to_return(:body => xml)
101
- end
102
-
103
- it "should raise an exception" do
104
- lambda { StreamSend::Api::List.all }.should raise_error
105
- end
106
- end
107
- end
108
-
109
- describe ".find" do
110
- describe "with matching list" do
111
- before(:each) do
112
- xml = <<-XML
113
- <?xml version="1.0" encoding="UTF-8"?>
114
- <list>
115
- <active-people-count type="integer">11</active-people-count>
116
- <checked-by-default type="boolean" nil="true"></checked-by-default>
117
- <created-at type="datetime">2012-01-14T18:11:50Z</created-at>
118
- <deleted-at type="datetime" nil="true"></deleted-at>
119
- <description nil="true"></description>
120
- <id type="integer">42</id>
121
- <inactive-people-count type="integer">0</inactive-people-count>
122
- <name>First list</name>
123
- <pending-people-count type="integer">0</pending-people-count>
124
- <public type="boolean" nil="true"></public>
125
- <status type="enum">idle</status>
126
- <unsubscribed-people-count type="integer">0</unsubscribed-people-count>
127
- <updated-at type="datetime">2012-01-14T18:11:50Z</updated-at>
128
- <audience-id type="integer">2</audience-id>
129
- </list>
130
- XML
131
-
132
- stub_http_request(:get, /audiences\/2\/lists\/42.xml/).with(:id => "42").to_return(:body => xml)
133
- end
134
-
135
- it "should return list" do
136
- list = StreamSend::Api::List.find(42)
137
-
138
- list.should be_instance_of(StreamSend::Api::List)
139
- list.id.should == 42
140
- list.name.should == "First list"
141
- list.created_at.should == Time.parse("2012-01-14T18:11:50Z")
142
- end
143
- end
144
-
145
- describe "with no matching list" do
146
- before(:each) do
147
- xml = <<-XML
148
- <?xml version="1.0" encoding="UTF-8"?>
149
- <lists type="array"\>
150
- XML
151
-
152
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml?email_address=bad.email@gmail.com").to_return(:status => 404)
153
- end
154
-
155
- it "should return throw an exception" do
156
- lambda {
157
- StreamSend::Api::List.find(-1)
158
- }.should raise_error
159
- end
160
- end
161
-
162
- describe "with invalid audience" do
163
- before(:each) do
164
- xml = <<-XML
165
- <?xml version="1.0" encoding="UTF-8"?>
166
- <people type="array"\>
167
- XML
168
-
169
- stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml?email_address=bad.email@gmail.com").to_return(:body => xml)
170
- end
171
-
172
- it "should raise an exception" do
173
- lambda { StreamSend::Api::List.find("scott@gmail.com") }.should raise_error
174
- end
175
- end
176
- end
177
- end
178
- end
179
- end
@@ -1,24 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
-
3
- module StreamSend
4
- module Api
5
- describe "Resource" do
6
- describe "with missing method" do
7
- before(:each) do
8
- @resource = StreamSend::Api::Resource.new({"name" => "scott"})
9
- end
10
-
11
- it "should return value" do
12
- @resource.name.should == "scott"
13
- end
14
- end
15
-
16
- describe "#id" do
17
- it "should return id" do
18
- StreamSend::Api::Resource.new({"id" => 99}).id.should == 99
19
- end
20
- end
21
-
22
- end
23
- end
24
- end