streamsend 1.0.0.rc4 → 1.0.0.rc5
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.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/streamsend/api/base/base_call.rb +13 -0
- data/lib/streamsend/api/base/create.rb +0 -11
- data/lib/streamsend/api/base/update.rb +4 -3
- data/lib/streamsend/version.rb +1 -1
- data/spec/lib/streamsend/api/integration/person_spec.rb +1 -1
- data/spec/lib/streamsend/api/integration/user_spec.rb +1 -1
- data/spec/lib/streamsend/api/unit/base/update_spec.rb +42 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2EyMzFiNThlZWQ1YjRjNDQxMjE3YWNmOTIxZGEyMmY1M2E1ZGYxNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGI4ODQ4NTkyNjc2MWMyZGNlNjdjYWQ5OTEzZmY4ZGFkYmM5OTdkNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzU2ZDM1Zjk4NDI5YjM2YTUwYWQyOWRiMWFiY2M5YmQ0ZTY3YjQyZmM5Zjk3
|
10
|
+
NjY0OTg1NGI0N2Q4MjRiNjhjZWI3OTc2MGFkNTMwZTljNTc3MmM0YWU4NzY2
|
11
|
+
NTRmNjk5OGU4ODlhMDEwMDA2OTU3ZmFkZTVjMzY3NzVkN2FkOGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzEzYWVlYmZhNWJiZTgxMmRlNjNhYWVjNDYyYzEwZjA0ODhiNzdkZmUzNmY5
|
14
|
+
MTRjNzEzYjJiM2M1NGYzYjNkOTg0MjYxODUxNTdlNmJlYTZkY2Y0ZGE5NDJl
|
15
|
+
NDNiNDU1ZTUxNjI1NTlmZTNmYmYyZmJjYWM4ZjZjMTY4MTIzMzE=
|
data/Gemfile.lock
CHANGED
@@ -54,6 +54,19 @@ module StreamSend
|
|
54
54
|
def audiences_uri
|
55
55
|
"#{base_audience_uri}.xml"
|
56
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def get_error_from response
|
61
|
+
message = "Unprocessable Entity"
|
62
|
+
if response.parsed_response["request"]
|
63
|
+
message = response.parsed_response["request"]["errors"]
|
64
|
+
elsif response.parsed_response["errors"]
|
65
|
+
message = response.parsed_response["errors"]["error"]
|
66
|
+
elsif response["errors"]
|
67
|
+
message = response["errors"]
|
68
|
+
end
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
59
72
|
end
|
@@ -21,17 +21,6 @@ module StreamSend
|
|
21
21
|
def uri
|
22
22
|
"#{base_uri}.xml"
|
23
23
|
end
|
24
|
-
|
25
|
-
def get_error_from response
|
26
|
-
message = "Unprocessable Entity"
|
27
|
-
if response.parsed_response["request"]
|
28
|
-
message = response.parsed_response["request"]["errors"]
|
29
|
-
elsif response.parsed_response["errors"]
|
30
|
-
message = response.parsed_response["errors"]["error"]
|
31
|
-
elsif response["errors"]
|
32
|
-
message = response["errors"]
|
33
|
-
end
|
34
|
-
end
|
35
24
|
end
|
36
25
|
|
37
26
|
class AudienceCreate < StreamSend::Api::Call::Create
|
@@ -6,10 +6,11 @@ module StreamSend
|
|
6
6
|
@id = object_id
|
7
7
|
response = session.put(uri, :body => object_hash)
|
8
8
|
case response.code
|
9
|
-
when 200
|
10
|
-
|
9
|
+
when 200 then true
|
10
|
+
when 401 then raise StreamSend::Api::UnauthorizedException
|
11
|
+
when 422 then raise StreamSend::Api::SemanticException.new(get_error_from(response))
|
11
12
|
else
|
12
|
-
|
13
|
+
raise StreamSend::Api::Exception.new("Could not create the #{namespace}. (#{response.code})")
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
data/lib/streamsend/version.rb
CHANGED
@@ -150,7 +150,7 @@ module StreamSend
|
|
150
150
|
person = shower.execute(id)
|
151
151
|
person.email_address = "me+#{randomish}@you.too"
|
152
152
|
updater = Update.new(session)
|
153
|
-
updater.execute(id, person.marshal_dump)
|
153
|
+
updater.execute(id, :person => person.marshal_dump)
|
154
154
|
person_updated = shower.execute(id)
|
155
155
|
expect(person_updated.email_address).to eq(person_hash[:person][:email_address])
|
156
156
|
expect(person_updated.id).to eq(id)
|
@@ -54,7 +54,7 @@ module StreamSend
|
|
54
54
|
user = shower.execute(id)
|
55
55
|
user.first_name = "newer namers!"
|
56
56
|
updater = Update.new(session)
|
57
|
-
updater.execute(id, user.marshal_dump)
|
57
|
+
updater.execute(id, :user => user.marshal_dump)
|
58
58
|
user_updated = shower.execute(id)
|
59
59
|
expect(user_updated.name).to eq(user_hash[:user][:name])
|
60
60
|
expect(user_updated.id).to eq(id)
|
@@ -9,16 +9,50 @@ module StreamSend
|
|
9
9
|
let(:session){ StreamSend::Api::Session.new("test", "password", "http://default.base") }
|
10
10
|
let(:updater){ Update.new(session) }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
context "when the update is successful" do
|
13
|
+
it "returns true" do
|
14
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").
|
15
|
+
to_return(:status => 200, :body => "", :headers => {})
|
16
|
+
expect(updater.execute(id, obj_hash)).to be_true
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
to_return(:status =>
|
21
|
-
|
20
|
+
context "when invalid credentials are provided" do
|
21
|
+
it "returns an unathorized exception" do
|
22
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").to_return(:status => 401, :body => "" )
|
23
|
+
expect do
|
24
|
+
updater.execute(id, {})
|
25
|
+
end.to raise_error(UnauthorizedException)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the request is invalid" do
|
30
|
+
let(:non_existent_person_id) { 42 }
|
31
|
+
let(:error_response) do
|
32
|
+
response_xml = <<-XML
|
33
|
+
<request>
|
34
|
+
<errors type='array'>
|
35
|
+
<message>Invalid Owner ID</message>
|
36
|
+
</errors>
|
37
|
+
</request>
|
38
|
+
XML
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns a semantic error with a meaningful error message" do
|
42
|
+
stub_request(:put, "http://test:password@default.base/calls/#{non_existent_person_id}.xml").to_return(:status => 422, :body => error_response, :headers => { :content_type => "application/xml" })
|
43
|
+
expect do
|
44
|
+
updater.execute(non_existent_person_id, {})
|
45
|
+
end.to raise_error(StreamSend::Api::SemanticException, /Invalid Owner ID/)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when the status is a 404" do
|
50
|
+
it "builds an error message with the namespace name" do
|
51
|
+
stub_request(:put, "http://test:password@default.base/calls/123.xml").to_return(:status => 404, :body => "")
|
52
|
+
expect do
|
53
|
+
updater.execute(id, {})
|
54
|
+
end.to raise_error(StreamSend::Api::Exception, "Could not create the calls. (404)")
|
55
|
+
end
|
22
56
|
end
|
23
57
|
|
24
58
|
it "creates a uri for updating using the id" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamsend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Yeo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: 1.3.1
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.1.
|
249
|
+
rubygems_version: 2.1.10
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Ruby wrapper for the StreamSend API.
|