streamsend 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.pair +10 -0
- data/Gemfile.lock +10 -6
- data/lib/streamsend/api/exception.rb +14 -1
- data/lib/streamsend/api/subscriber.rb +28 -2
- data/spec/lib/streamsend/api/subscriber_spec.rb +34 -6
- data/streamsend.gemspec +4 -2
- metadata +32 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 570a759259227d544ce683da82e01e9de3fcf02f
|
4
|
+
data.tar.gz: 3fab2452d29f3e1cb9246958482860a5610d9cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731dd7a05dc12b5cf17b923b3dba981703ff96838cf94abe44d7306270a89d5aa270e65e2ea2d5655f89f063c93951445e433e568494a8fc36555173cae46f2f
|
7
|
+
data.tar.gz: ff1ece90306b86ff2ebe904309f0782a4c0f0ea81fef98fbeb9bd8397a51eeaf3a84d0df40b76cc80c6cb495c918c7d26569d504a6d27a27659489cd3518770d
|
data/.gitignore
CHANGED
data/.pair
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
streamsend (0.2.
|
4
|
+
streamsend (0.2.2)
|
5
5
|
activesupport (~> 3.2)
|
6
6
|
builder
|
7
7
|
httparty
|
@@ -9,20 +9,22 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (3.2.
|
13
|
-
i18n (
|
12
|
+
activesupport (3.2.14)
|
13
|
+
i18n (~> 0.6, >= 0.6.4)
|
14
14
|
multi_json (~> 1.0)
|
15
15
|
addressable (2.3.5)
|
16
16
|
builder (3.2.2)
|
17
17
|
crack (0.4.0)
|
18
18
|
safe_yaml (~> 0.9.0)
|
19
19
|
diff-lcs (1.2.4)
|
20
|
+
git-commit-story (0.1.5)
|
20
21
|
httparty (0.11.0)
|
21
22
|
multi_json (~> 1.0)
|
22
23
|
multi_xml (>= 0.5.2)
|
23
|
-
i18n (0.6.
|
24
|
-
multi_json (1.
|
25
|
-
multi_xml (0.5.
|
24
|
+
i18n (0.6.5)
|
25
|
+
multi_json (1.8.0)
|
26
|
+
multi_xml (0.5.5)
|
27
|
+
pair-salad (0.1.1)
|
26
28
|
rspec (2.13.0)
|
27
29
|
rspec-core (~> 2.13.0)
|
28
30
|
rspec-expectations (~> 2.13.0)
|
@@ -43,6 +45,8 @@ PLATFORMS
|
|
43
45
|
ruby
|
44
46
|
|
45
47
|
DEPENDENCIES
|
48
|
+
git-commit-story
|
49
|
+
pair-salad
|
46
50
|
rspec
|
47
51
|
ruby-fsevent
|
48
52
|
streamsend!
|
@@ -1,2 +1,15 @@
|
|
1
|
-
|
1
|
+
module StreamSend
|
2
|
+
module Api
|
3
|
+
class Exception < StandardError
|
4
|
+
end
|
5
|
+
|
6
|
+
class ApiException < Exception
|
7
|
+
end
|
8
|
+
|
9
|
+
class LockedError < ApiException
|
10
|
+
end
|
11
|
+
|
12
|
+
class UnexpectedResponse < ApiException
|
13
|
+
end
|
14
|
+
end
|
2
15
|
end
|
@@ -4,13 +4,27 @@ module StreamSend
|
|
4
4
|
module Api
|
5
5
|
class Subscriber < Resource
|
6
6
|
def self.all
|
7
|
-
|
7
|
+
options = { :per_page => 1_000, :page => 0 }
|
8
|
+
last_gathered_count = 1
|
9
|
+
sbuscribers = []
|
10
|
+
|
11
|
+
until last_gathered_count == 0
|
12
|
+
gathered = self.index( options )
|
13
|
+
subscribers.concat( gathered )
|
14
|
+
options[:page] = options[:page]+1
|
15
|
+
last_gathered_count = gatehred.count
|
16
|
+
end
|
17
|
+
subscribers
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.index(options = {})
|
21
|
+
response = StreamSend::Api.get("/audiences/#{audience_id}/people.xml", :query => options)
|
8
22
|
|
9
23
|
case response.code
|
10
24
|
when 200
|
11
25
|
response["people"].collect { |data| new(data) }
|
12
26
|
else
|
13
|
-
raise StreamSend::Api::
|
27
|
+
raise StreamSend::Api::ApiException.new("Error response (#{response.code}), Make sure your audience ID is correct. (audience_id => #{audience_id})")
|
14
28
|
end
|
15
29
|
end
|
16
30
|
|
@@ -80,6 +94,18 @@ module StreamSend
|
|
80
94
|
raise StreamSend::Api::Exception("Could not subscribe the subscriber. (#{response.code})")
|
81
95
|
end
|
82
96
|
end
|
97
|
+
|
98
|
+
def destroy
|
99
|
+
response = StreamSend::Api.delete("/audiences/#{audience_id}/people/#{id}.xml")
|
100
|
+
case response.code
|
101
|
+
when 200
|
102
|
+
true
|
103
|
+
when 423
|
104
|
+
raise LockedError, "Can not delete"
|
105
|
+
else
|
106
|
+
raise UnexpectedResponse, response.code
|
107
|
+
end
|
108
|
+
end
|
83
109
|
end
|
84
110
|
end
|
85
111
|
end
|
@@ -56,7 +56,7 @@ module StreamSend
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe ".
|
59
|
+
describe ".index" do
|
60
60
|
describe "with subscribers" do
|
61
61
|
before(:each) do
|
62
62
|
xml = <<-XML
|
@@ -70,11 +70,11 @@ module StreamSend
|
|
70
70
|
</people>
|
71
71
|
XML
|
72
72
|
|
73
|
-
stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml").to_return(:body => xml)
|
73
|
+
stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml?").to_return(:body => xml)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should return array of one subscriber object" do
|
77
|
-
subscribers = StreamSend::Api::Subscriber.
|
77
|
+
subscribers = StreamSend::Api::Subscriber.index
|
78
78
|
subscribers.size.should == 1
|
79
79
|
|
80
80
|
subscribers.first.should be_instance_of(StreamSend::Api::Subscriber)
|
@@ -91,11 +91,11 @@ module StreamSend
|
|
91
91
|
<people type="array"/>
|
92
92
|
XML
|
93
93
|
|
94
|
-
stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml").to_return(:body => xml)
|
94
|
+
stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml?").to_return(:body => xml)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should return an empty array" do
|
98
|
-
StreamSend::Api::Subscriber.
|
98
|
+
StreamSend::Api::Subscriber.index.should == []
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -110,7 +110,9 @@ module StreamSend
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should raise an exception" do
|
113
|
-
|
113
|
+
expect do
|
114
|
+
StreamSend::Api::Subscriber.index
|
115
|
+
end.to raise_error(ApiException)
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -278,6 +280,32 @@ module StreamSend
|
|
278
280
|
end
|
279
281
|
end
|
280
282
|
end
|
283
|
+
|
284
|
+
describe "#destory" do
|
285
|
+
let( :subscriber ){
|
286
|
+
StreamSend::Api::Subscriber.new({"id"=> 2, "audience_id" => 1})
|
287
|
+
}
|
288
|
+
let( :uri ){ "http://#{@username}:#{@password}@#{@host}/audiences/1/people/2.xml" }
|
289
|
+
|
290
|
+
it "returns true when destroyed" do
|
291
|
+
stub_http_request(:delete, uri ).to_return(:body => nil)
|
292
|
+
expect(subscriber.destroy).to be_true
|
293
|
+
end
|
294
|
+
|
295
|
+
it "throws a LockedError when locked" do
|
296
|
+
stub_http_request(:delete, uri ).to_return(:status => 423, :body => nil)
|
297
|
+
expect do
|
298
|
+
subscriber.destroy
|
299
|
+
end.to raise_error( LockedError )
|
300
|
+
end
|
301
|
+
|
302
|
+
it "throws unexpected response with any other exception" do
|
303
|
+
stub_http_request(:delete, uri ).to_return(:status => 500, :body => "Error text meant for HCI")
|
304
|
+
expect do
|
305
|
+
subscriber.destroy
|
306
|
+
end.to raise_error( UnexpectedResponse )
|
307
|
+
end
|
308
|
+
end
|
281
309
|
end
|
282
310
|
end
|
283
311
|
end
|
data/streamsend.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
|
-
gem.authors = ["Scott Albertson", "Jeff Roush"]
|
4
|
+
gem.authors = ["Scott Albertson", "Jeff Roush", "Mark Eschbach", "Bob Yeo"]
|
5
5
|
gem.email = %q{jroush@ezpublishing.com}
|
6
6
|
gem.summary = %q{Ruby wrapper for the StreamSend API.}
|
7
7
|
gem.description = %q{Ruby wrapper for the StreamSend API.}
|
@@ -12,15 +12,17 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.add_dependency "activesupport", "~>3.2"
|
13
13
|
gem.add_dependency "builder"
|
14
14
|
gem.add_development_dependency "rspec"
|
15
|
+
gem.add_development_dependency "git-commit-story"
|
15
16
|
gem.add_development_dependency "webmock", "~> 1.6"
|
16
17
|
gem.add_development_dependency "vcr"
|
17
18
|
gem.add_development_dependency "watchr"
|
18
19
|
gem.add_development_dependency "ruby-fsevent"
|
20
|
+
gem.add_development_dependency "pair-salad"
|
19
21
|
|
20
22
|
gem.files = `git ls-files`.split($\)
|
21
23
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
24
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
25
|
gem.name = "streamsend"
|
24
26
|
gem.require_paths = ["lib"]
|
25
|
-
gem.version = "0.2.
|
27
|
+
gem.version = "0.2.2"
|
26
28
|
end
|
metadata
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamsend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Albertson
|
8
8
|
- Jeff Roush
|
9
|
+
- Mark Eschbach
|
10
|
+
- Bob Yeo
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
@@ -67,6 +69,20 @@ dependencies:
|
|
67
69
|
- - '>='
|
68
70
|
- !ruby/object:Gem::Version
|
69
71
|
version: '0'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: git-commit-story
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
70
86
|
- !ruby/object:Gem::Dependency
|
71
87
|
name: webmock
|
72
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +139,20 @@ dependencies:
|
|
123
139
|
- - '>='
|
124
140
|
- !ruby/object:Gem::Version
|
125
141
|
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: pair-salad
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
type: :development
|
150
|
+
prerelease: false
|
151
|
+
version_requirements: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
126
156
|
description: Ruby wrapper for the StreamSend API.
|
127
157
|
email: jroush@ezpublishing.com
|
128
158
|
executables: []
|
@@ -130,6 +160,7 @@ extensions: []
|
|
130
160
|
extra_rdoc_files: []
|
131
161
|
files:
|
132
162
|
- .gitignore
|
163
|
+
- .pair
|
133
164
|
- .rspec
|
134
165
|
- Gemfile
|
135
166
|
- Gemfile.lock
|