streamsend 1.0.0.rc3 → 1.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/streamsend/api/base/create.rb +12 -5
- data/lib/streamsend/api/base/show.rb +2 -2
- data/lib/streamsend/api/trigger.rb +20 -0
- data/lib/streamsend/version.rb +1 -1
- data/lib/streamsend.rb +1 -0
- data/spec/lib/streamsend/api/integration/trigger_spec.rb +89 -0
- data/spec/lib/streamsend/api/unit/base/create_spec.rb +7 -3
- data/spec/lib/streamsend/api/unit/trigger_spec.rb +66 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWQwZjQyNTdiY2E1OThiYWExZGRmOGUzNzQ0ODFmZGM4MmY3ZDNjNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTk3MTc1NzM2NDFlMGZiYjM2MTEwYmQ3ZjAwZjkxYzFlZGNiZmM2NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yjc2OWMzZDQ0NjA1ZDg3ZGMyNTFmZmU3NTE4MDAwODhkZWQwMWVkZTEyYjg3
|
10
|
+
NDY4ZjEwYjI0ZmY0YjFhM2VhYjM3ZGE2ZTRhY2ZiNDUyNjNjNWRjYmE5ODQ0
|
11
|
+
NjA1M2E0YjA4NzFlZDNjZWQ1ZTRiMzMxMzI5OGE2OGIwY2FkOWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWIzOTAzN2VlYjI3YmFkZTU5ZDAzMGE2OTA1NWY4MGZkNTBiMDM2OTJhM2Jl
|
14
|
+
ODlkMTUxZTYwMzkyMjM0YTk5ZmI1MGFjYzQzN2QyOWEwNWU4MDk2NzdjYzYz
|
15
|
+
NzlkZDRiYzYzZjYzOTQ1Yjc1ZTJkZThjMGQ5ZDYwMjhmZDI1MjA=
|
@@ -11,11 +11,7 @@ module StreamSend
|
|
11
11
|
when 401
|
12
12
|
raise StreamSend::Api::UnauthorizedException
|
13
13
|
when 422
|
14
|
-
|
15
|
-
message = response["errors"]
|
16
|
-
else
|
17
|
-
message = "Unprocessable Entity"
|
18
|
-
end
|
14
|
+
message = get_error_from response
|
19
15
|
raise StreamSend::Api::SemanticException.new(message)
|
20
16
|
else
|
21
17
|
raise StreamSend::Api::Exception.new("Could not create the #{namespace}. (#{response.code})")
|
@@ -25,6 +21,17 @@ module StreamSend
|
|
25
21
|
def uri
|
26
22
|
"#{base_uri}.xml"
|
27
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
|
28
35
|
end
|
29
36
|
|
30
37
|
class AudienceCreate < StreamSend::Api::Call::Create
|
@@ -2,9 +2,9 @@ module StreamSend
|
|
2
2
|
module Api
|
3
3
|
module Call
|
4
4
|
class Show < StreamSend::Api::Call::BaseCall
|
5
|
-
def execute(object_id)
|
5
|
+
def execute(object_id, show_options = {})
|
6
6
|
@id = object_id
|
7
|
-
response = session.get(uri)
|
7
|
+
response = session.get(uri, show_options)
|
8
8
|
case response.code
|
9
9
|
when 200
|
10
10
|
StreamSend::Api::Result.new(response.parsed_response[namespace.singularize])
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module StreamSend
|
2
|
+
module Api
|
3
|
+
module Trigger
|
4
|
+
class Index < StreamSend::Api::Call::Index
|
5
|
+
end
|
6
|
+
|
7
|
+
class Show < StreamSend::Api::Call::Show
|
8
|
+
end
|
9
|
+
|
10
|
+
class Update < StreamSend::Api::Call::Update
|
11
|
+
end
|
12
|
+
|
13
|
+
class Create < StreamSend::Api::Call::Create
|
14
|
+
end
|
15
|
+
|
16
|
+
class Destroy < StreamSend::Api::Call::Destroy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/streamsend/version.rb
CHANGED
data/lib/streamsend.rb
CHANGED
@@ -31,6 +31,7 @@ require "streamsend/api/list"
|
|
31
31
|
require "streamsend/api/import"
|
32
32
|
require "streamsend/api/membership"
|
33
33
|
require "streamsend/api/person"
|
34
|
+
require "streamsend/api/trigger"
|
34
35
|
require "streamsend/api/unsubscribe"
|
35
36
|
require "streamsend/api/upload"
|
36
37
|
require "streamsend/api/view"
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module StreamSend
|
4
|
+
module Api
|
5
|
+
module Trigger
|
6
|
+
describe "Trigger calls" do
|
7
|
+
let(:session){ StreamSend::Api::Session.new() }
|
8
|
+
let(:create_request){ Create.new(session) }
|
9
|
+
let(:destroy_request){ Destroy.new(session) }
|
10
|
+
let(:from_addy){ "jo@yo.yoyo" }
|
11
|
+
|
12
|
+
before do
|
13
|
+
WebMock.disable!
|
14
|
+
emails = StreamSend::Api::Email::Index.new(session).execute
|
15
|
+
email_id = emails[0].id
|
16
|
+
from_emails = StreamSend::Api::FromEmailAddress::Index.new(session).execute
|
17
|
+
@from_email = from_emails.select{|email| email.activated == true}.first
|
18
|
+
@trigger = { :trigger => { :name => "test trigs",
|
19
|
+
:enabled => true,
|
20
|
+
:subject => "testing this yo!",
|
21
|
+
:email_id => email_id,
|
22
|
+
:start_date => "2013-05-27",
|
23
|
+
:time => "T03:44:55Z",
|
24
|
+
:frequency => "weekly",
|
25
|
+
:interval => 2,
|
26
|
+
:days => 1,
|
27
|
+
:from => {:name => "jo", :email_address => @from_email.email_address },
|
28
|
+
:reply_to => {:name => "jack", :email_address => @from_email.email_address },
|
29
|
+
:to => {:audience_id => 1 },
|
30
|
+
:options => {:track_views => true}}}
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
after do
|
35
|
+
WebMock.enable!
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Index do
|
39
|
+
it "returns an array of triggers" do
|
40
|
+
pending "No activated from email addresses for this account" if !@from_email
|
41
|
+
id = create_request.execute(@trigger)
|
42
|
+
|
43
|
+
index_request = Index.new(session)
|
44
|
+
triggers = index_request.execute
|
45
|
+
expect(triggers.count).to be > 0
|
46
|
+
|
47
|
+
destroy_request.execute(id)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe Show do
|
52
|
+
it "returns a specific trigger by id" do
|
53
|
+
pending "No activated from email addresses for this account" if !@from_email
|
54
|
+
id = create_request.execute(@trigger)
|
55
|
+
|
56
|
+
show_request = Show.new(session)
|
57
|
+
trigger = show_request.execute(id)
|
58
|
+
expect(trigger.name).to eq(@trigger[:trigger][:name])
|
59
|
+
|
60
|
+
destroy_request.execute(id)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe Create do
|
65
|
+
it "creates a trigger" do
|
66
|
+
pending "No activated from email addresses for this account" if !@from_email
|
67
|
+
id = create_request.execute(@trigger)
|
68
|
+
|
69
|
+
expect(id).to_not be nil
|
70
|
+
destroy_request.execute(id)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe Destroy do
|
75
|
+
it "destroys a trigger" do
|
76
|
+
pending "No activated from email addresses for this account" if !@from_email
|
77
|
+
id = create_request.execute(@trigger)
|
78
|
+
expect(id).to_not be nil
|
79
|
+
destroy_request.execute(id)
|
80
|
+
expect do
|
81
|
+
show_request = Show.new(session)
|
82
|
+
user = show_request.execute(id)
|
83
|
+
end.to raise_exception(StreamSend::Api::Exception, "Could not find any triggers with the specified id. (404)")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -31,9 +31,11 @@ module StreamSend
|
|
31
31
|
|
32
32
|
it "raises a SemanticException when encountering 422 with a singular error message" do
|
33
33
|
response_xml = <<-XML
|
34
|
+
<request>
|
34
35
|
<errors type='array'>
|
35
|
-
<
|
36
|
+
<message>Error B</message>
|
36
37
|
</errors>
|
38
|
+
</request>
|
37
39
|
XML
|
38
40
|
stub_request(:post, "http://test:password@default.base/calls.xml").
|
39
41
|
to_return(:status => 422, :body => response_xml, :headers => { :content_type => "application/xml" })
|
@@ -44,10 +46,12 @@ module StreamSend
|
|
44
46
|
|
45
47
|
it "raises a SemanticException when encountering 422 with multiple errors" do
|
46
48
|
response_xml = <<-XML
|
49
|
+
<request>
|
47
50
|
<errors type='array'>
|
48
|
-
<
|
49
|
-
<
|
51
|
+
<message>Error A</message>
|
52
|
+
<message>Error B</message>
|
50
53
|
</errors>
|
54
|
+
</request>
|
51
55
|
XML
|
52
56
|
stub_request(:post, "http://test:password@default.base/calls.xml").
|
53
57
|
to_return(:status => 422, :body => response_xml, :headers => { :content_type => "application/xml" })
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module StreamSend
|
4
|
+
module Api
|
5
|
+
module Trigger
|
6
|
+
describe "Trigger calls" do
|
7
|
+
let(:session){ StreamSend::Api::Session.new("test", "password", "https://default.base") }
|
8
|
+
let(:index_request){ Index.new(session) }
|
9
|
+
let(:show_request){ Show.new(session) }
|
10
|
+
let(:create_request){ Create.new(session) }
|
11
|
+
let(:update_request){ Update.new(session) }
|
12
|
+
let(:trigger_hash){ {:trigger => { :name => "test trigs",
|
13
|
+
:enabled => true,
|
14
|
+
:subject => "testing this yo!",
|
15
|
+
:email_id => 1,
|
16
|
+
:start_date => "2013-05-27",
|
17
|
+
:time => "T03:44:55Z",
|
18
|
+
:frequency => "weekly",
|
19
|
+
:interval => 2,
|
20
|
+
:days => [1,2,3],
|
21
|
+
:from => {:name => "jo", :email_address => "jo@what.not" },
|
22
|
+
:reply_to => {:name => "jack", :email_address => "jack@the.box" },
|
23
|
+
:to => {:audience_id => 1 },
|
24
|
+
:options => {:track_views => true}}}}
|
25
|
+
let(:trigger_id){ 1234 }
|
26
|
+
let(:xml){ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><triggers type=\"array\"><trigger><test type=\"integer\">1</test></trigger></triggers>" }
|
27
|
+
|
28
|
+
describe Index do
|
29
|
+
it "creates a uri for getting an index of triggers" do
|
30
|
+
stub_request(:get, "https://test:password@default.base/triggers.xml").
|
31
|
+
to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
32
|
+
index_request.execute
|
33
|
+
expect(index_request.uri).to eq("https://default.base/triggers.xml")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe Show do
|
38
|
+
it "creates a uri for getting a specific trigger" do
|
39
|
+
stub_request(:get, "https://test:password@default.base/triggers/#{trigger_id}.xml").
|
40
|
+
to_return(:status => 200, :body => xml, :headers => {'Content-Type' => 'text/xml'})
|
41
|
+
show_request.execute(trigger_id)
|
42
|
+
expect(show_request.uri).to eq("https://default.base/triggers/#{trigger_id}.xml")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe Create do
|
47
|
+
it "creates a uri for creating a trigger" do
|
48
|
+
stub_request(:post, "https://test:password@default.base/triggers.xml").
|
49
|
+
to_return(:status => 201, :body => "", :headers => {'Location' => 'something/something/101'})
|
50
|
+
create_request.execute(trigger_hash)
|
51
|
+
expect(create_request.uri).to eq("https://default.base/triggers.xml")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe Update do
|
56
|
+
it "creates a uri for updating a trigger" do
|
57
|
+
stub_request(:put, "https://test:password@default.base/triggers/#{trigger_id}.xml").
|
58
|
+
to_return(:status => 200, :body => "")
|
59
|
+
update_request.execute(trigger_id, trigger_hash)
|
60
|
+
expect(update_request.uri).to eq("https://default.base/triggers/#{trigger_id}.xml")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
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.rc4
|
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-10-
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/streamsend/api/person.rb
|
179
179
|
- lib/streamsend/api/result.rb
|
180
180
|
- lib/streamsend/api/session.rb
|
181
|
+
- lib/streamsend/api/trigger.rb
|
181
182
|
- lib/streamsend/api/unsubscribe.rb
|
182
183
|
- lib/streamsend/api/upload.rb
|
183
184
|
- lib/streamsend/api/user.rb
|
@@ -199,6 +200,7 @@ files:
|
|
199
200
|
- spec/lib/streamsend/api/integration/list_spec.rb
|
200
201
|
- spec/lib/streamsend/api/integration/membership_spec.rb
|
201
202
|
- spec/lib/streamsend/api/integration/person_spec.rb
|
203
|
+
- spec/lib/streamsend/api/integration/trigger_spec.rb
|
202
204
|
- spec/lib/streamsend/api/integration/unsubscribe_spec.rb
|
203
205
|
- spec/lib/streamsend/api/integration/upload_spec.rb
|
204
206
|
- spec/lib/streamsend/api/integration/user_spec.rb
|
@@ -220,6 +222,7 @@ files:
|
|
220
222
|
- spec/lib/streamsend/api/unit/person_spec.rb
|
221
223
|
- spec/lib/streamsend/api/unit/result_spec.rb
|
222
224
|
- spec/lib/streamsend/api/unit/session_spec.rb
|
225
|
+
- spec/lib/streamsend/api/unit/trigger_spec.rb
|
223
226
|
- spec/lib/streamsend/api/unit/unsubscribe_spec.rb
|
224
227
|
- spec/lib/streamsend/api/unit/user_spec.rb
|
225
228
|
- spec/spec_helper.rb
|
@@ -264,6 +267,7 @@ test_files:
|
|
264
267
|
- spec/lib/streamsend/api/integration/list_spec.rb
|
265
268
|
- spec/lib/streamsend/api/integration/membership_spec.rb
|
266
269
|
- spec/lib/streamsend/api/integration/person_spec.rb
|
270
|
+
- spec/lib/streamsend/api/integration/trigger_spec.rb
|
267
271
|
- spec/lib/streamsend/api/integration/unsubscribe_spec.rb
|
268
272
|
- spec/lib/streamsend/api/integration/upload_spec.rb
|
269
273
|
- spec/lib/streamsend/api/integration/user_spec.rb
|
@@ -285,6 +289,7 @@ test_files:
|
|
285
289
|
- spec/lib/streamsend/api/unit/person_spec.rb
|
286
290
|
- spec/lib/streamsend/api/unit/result_spec.rb
|
287
291
|
- spec/lib/streamsend/api/unit/session_spec.rb
|
292
|
+
- spec/lib/streamsend/api/unit/trigger_spec.rb
|
288
293
|
- spec/lib/streamsend/api/unit/unsubscribe_spec.rb
|
289
294
|
- spec/lib/streamsend/api/unit/user_spec.rb
|
290
295
|
- spec/spec_helper.rb
|