streamsend 1.0.0.rc16 → 1.0.0.rc19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/Gemfile.lock +9 -7
- data/lib/streamsend/api/base/count.rb +27 -0
- data/lib/streamsend/api/base/index.rb +13 -15
- data/lib/streamsend/api/blast.rb +6 -6
- data/lib/streamsend/api/bounce.rb +2 -2
- data/lib/streamsend/api/click.rb +2 -2
- data/lib/streamsend/api/configuration.rb +4 -0
- data/lib/streamsend/api/hash_xml_serializer.rb +58 -0
- data/lib/streamsend/api/list.rb +1 -1
- data/lib/streamsend/api/membership.rb +16 -3
- data/lib/streamsend/api/person.rb +4 -8
- data/lib/streamsend/api/result.rb +32 -1
- data/lib/streamsend/api/session.rb +22 -1
- data/lib/streamsend/api/unsubscribe.rb +2 -2
- data/lib/streamsend/version.rb +1 -1
- data/lib/streamsend.rb +3 -4
- data/spec/lib/streamsend/api/integration/blast_spec.rb +4 -4
- data/spec/lib/streamsend/api/integration/bounce_spec.rb +3 -0
- data/spec/lib/streamsend/api/integration/click_spec.rb +2 -0
- data/spec/lib/streamsend/api/integration/link_spec.rb +2 -0
- data/spec/lib/streamsend/api/integration/membership_spec.rb +27 -1
- data/spec/lib/streamsend/api/integration/owner_spec.rb +25 -18
- data/spec/lib/streamsend/api/integration/person_spec.rb +12 -2
- data/spec/lib/streamsend/api/integration/unsubscribe_spec.rb +2 -0
- data/spec/lib/streamsend/api/integration/view_spec.rb +1 -0
- data/spec/lib/streamsend/api/unit/base/count_spec.rb +57 -0
- data/spec/lib/streamsend/api/unit/base/index_spec.rb +42 -18
- data/spec/lib/streamsend/api/unit/blast_spec.rb +6 -9
- data/spec/lib/streamsend/api/unit/bounce_spec.rb +5 -7
- data/spec/lib/streamsend/api/unit/click_spec.rb +4 -4
- data/spec/lib/streamsend/api/unit/hash_xml_serializer_spec.rb +63 -0
- data/spec/lib/streamsend/api/unit/link_spec.rb +2 -2
- data/spec/lib/streamsend/api/unit/membership_spec.rb +23 -9
- data/spec/lib/streamsend/api/unit/person_spec.rb +10 -11
- data/spec/lib/streamsend/api/unit/result_spec.rb +32 -3
- data/spec/lib/streamsend/api/unit/unsubscribe_spec.rb +4 -6
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjU4NDE1YWQyOWQzNzVhNTA1OTFmNTMwYjU0NGU0MDU3Y2E0Y2UzYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2Q5MWQwNjIxYWRhYWYyYWQzNjQyNWY4MzIwMjU5NjhlNzBhN2RjNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzMwMTI3MjVjMTBmYTM3YTA4OTkxYTBlMzU0MDlkMzg1N2NjODU1ZTYxZDUy
|
10
|
+
NGE2MmMxNDA5Yzg1M2M3M2FmNzkxZmM4ZDVmZTE2MDk3ODM5MzFmYWU1MDgz
|
11
|
+
YjUyYjI2OWFmNTdiZTZlZGViNzA2ZmIyNDQyYjQ1ZjkxNzQ5N2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmRhMmRlNDk0ZThlMjJkZWUyODk4Zjg5ODM2YjMxZmRlNzgzODlkMTU4YzYz
|
14
|
+
MTg5ZDlmNTAyMDJlNzkyNjQwZTgxZTIxMDQ3NjM4ZGZiOGFlZDNlYTFkZGRm
|
15
|
+
ZjYyZmE5YTBlZWI3ODQxY2JkMmJlZjkwMDlhOWRlZWMyYTRkZTA=
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
streamsend (1.0.0.
|
4
|
+
streamsend (1.0.0.rc18)
|
5
5
|
activesupport (~> 3.2)
|
6
6
|
builder
|
7
7
|
httmultiparty
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (3.2.
|
12
|
+
activesupport (3.2.17)
|
13
13
|
i18n (~> 0.6, >= 0.6.4)
|
14
14
|
multi_json (~> 1.0)
|
15
15
|
addressable (2.3.5)
|
@@ -25,17 +25,19 @@ GEM
|
|
25
25
|
debugger-ruby_core_source (1.2.3)
|
26
26
|
diff-lcs (1.2.4)
|
27
27
|
git-commit-story (0.1.5)
|
28
|
-
httmultiparty (0.3.
|
28
|
+
httmultiparty (0.3.14)
|
29
29
|
httparty (>= 0.7.3)
|
30
|
+
mimemagic
|
30
31
|
multipart-post
|
31
|
-
httparty (0.
|
32
|
+
httparty (0.13.1)
|
32
33
|
json (~> 1.8)
|
33
34
|
multi_xml (>= 0.5.2)
|
34
|
-
i18n (0.6.
|
35
|
+
i18n (0.6.9)
|
35
36
|
json (1.8.1)
|
36
|
-
|
37
|
+
mimemagic (0.2.1)
|
38
|
+
multi_json (1.9.2)
|
37
39
|
multi_xml (0.5.5)
|
38
|
-
multipart-post (
|
40
|
+
multipart-post (2.0.0)
|
39
41
|
pair-salad (0.1.1)
|
40
42
|
rake (10.1.0)
|
41
43
|
rspec (2.14.1)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
|
3
|
+
module StreamSend
|
4
|
+
module Api
|
5
|
+
module Call
|
6
|
+
class Count < StreamSend::Api::Call::BaseCall
|
7
|
+
def execute()
|
8
|
+
response = session.get(uri)
|
9
|
+
case response.code
|
10
|
+
when 200
|
11
|
+
response.parsed_response["count"]
|
12
|
+
when 400
|
13
|
+
raise StreamSend::Api::ApiException.new(get_error_from(response))
|
14
|
+
when 401
|
15
|
+
raise StreamSend::Api::UnauthorizedException.new("Please check your credentials and host: " + session.base_uri)
|
16
|
+
else
|
17
|
+
raise StreamSend::Api::Exception.new("Could not return count of #{namespace}. (#{response.code})")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def uri
|
22
|
+
"#{base_uri}/count.xml"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -5,11 +5,13 @@ module StreamSend
|
|
5
5
|
module Call
|
6
6
|
class Index < StreamSend::Api::Call::BaseCall
|
7
7
|
def execute(index_options = {})
|
8
|
-
|
9
|
-
response = session.get(uri,
|
8
|
+
options = build_query_with(index_options)
|
9
|
+
response = session.get(uri, options)
|
10
10
|
case response.code
|
11
11
|
when 200
|
12
12
|
response.parsed_response[namespace].collect { |data| StreamSend::Api::Result.new(data) }
|
13
|
+
when 400
|
14
|
+
raise StreamSend::Api::ApiException.new(get_error_from(response))
|
13
15
|
when 401
|
14
16
|
raise StreamSend::Api::UnauthorizedException.new("Please check your credentials and host: " + session.base_uri)
|
15
17
|
else
|
@@ -17,20 +19,16 @@ module StreamSend
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
def
|
21
|
-
(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def page
|
29
|
-
@options[:page] || 1
|
22
|
+
def build_query_with(options)
|
23
|
+
if (options[:query].nil? && options[:headers].nil? && !options.empty?)
|
24
|
+
{:query => options}
|
25
|
+
else
|
26
|
+
options
|
27
|
+
end
|
30
28
|
end
|
31
29
|
|
32
|
-
def
|
33
|
-
|
30
|
+
def uri
|
31
|
+
"#{base_uri}.xml"
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
@@ -47,7 +45,7 @@ module StreamSend
|
|
47
45
|
end
|
48
46
|
|
49
47
|
def uri
|
50
|
-
"#{blast_uri_for(@blast_id)}
|
48
|
+
"#{blast_uri_for(@blast_id)}"
|
51
49
|
end
|
52
50
|
end
|
53
51
|
end
|
data/lib/streamsend/api/blast.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
module StreamSend
|
2
2
|
module Api
|
3
3
|
module Blast
|
4
|
-
class Index < StreamSend::Api::Call::
|
4
|
+
class Index < StreamSend::Api::Call::Index
|
5
5
|
def uri
|
6
|
-
"#{audiences_uri}
|
6
|
+
"#{audiences_uri}"
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
class Scheduled < StreamSend::Api::Call::
|
10
|
+
class Scheduled < StreamSend::Api::Call::Index
|
11
11
|
def uri
|
12
|
-
"#{base_audience_uri}/scheduled.xml
|
12
|
+
"#{base_audience_uri}/scheduled.xml"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
class Sent < StreamSend::Api::Call::
|
16
|
+
class Sent < StreamSend::Api::Call::Index
|
17
17
|
def uri
|
18
|
-
"#{base_audience_uri}/sent.xml
|
18
|
+
"#{base_audience_uri}/sent.xml"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -6,13 +6,13 @@ module StreamSend
|
|
6
6
|
|
7
7
|
class Soft < StreamSend::Api::Call::BlastIndex
|
8
8
|
def uri
|
9
|
-
"#{base_blast_uri_for(@blast_id)}/soft.xml
|
9
|
+
"#{base_blast_uri_for(@blast_id)}/soft.xml"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Hard < StreamSend::Api::Call::BlastIndex
|
14
14
|
def uri
|
15
|
-
"#{base_blast_uri_for(@blast_id)}/hard.xml
|
15
|
+
"#{base_blast_uri_for(@blast_id)}/hard.xml"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/streamsend/api/click.rb
CHANGED
@@ -9,8 +9,8 @@ module StreamSend
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def uri
|
12
|
-
return "#{base_blast_only_for(@blast_id)}/links/#{@link_id}/clicks.xml
|
13
|
-
"#{base_blast_uri_for(@blast_id)}.xml
|
12
|
+
return "#{base_blast_only_for(@blast_id)}/links/#{@link_id}/clicks.xml" if @link_id
|
13
|
+
"#{base_blast_uri_for(@blast_id)}.xml"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module StreamSend
|
2
|
+
module Api
|
3
|
+
class HashXmlSerializer
|
4
|
+
def serialize(hash, options = {})
|
5
|
+
xml = serialize_hash(hash, options)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def serialize_hash(hash, options)
|
11
|
+
builder = get_builder(options)
|
12
|
+
root_name = get_root_name(hash, options)
|
13
|
+
|
14
|
+
hash.keys.each do |key|
|
15
|
+
value = hash[key]
|
16
|
+
if(value.is_a?(Hash))
|
17
|
+
builder.tag!(root_name) do
|
18
|
+
process_nested_hash(key, value, options)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
build_tag_for(builder, key, value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
builder.target!
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_tag_for(builder, key, value)
|
29
|
+
if value
|
30
|
+
value = value.join(", ") if value.is_a?(Array)
|
31
|
+
builder.tag!(tag_name_for(key), value)
|
32
|
+
else
|
33
|
+
builder.tag!(tag_name_for(key), {:nil => true}, value)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def process_nested_hash(key, value, options)
|
38
|
+
options[:skip_instruct] = true
|
39
|
+
options[:root] = tag_name_for(value.keys[0])
|
40
|
+
serialize_hash(value, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_root_name(hash, options)
|
44
|
+
options[:root] || tag_name_for(hash.keys[0])
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_builder(options)
|
48
|
+
xml = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => 2)
|
49
|
+
xml.instruct! unless options[:skip_instruct]
|
50
|
+
xml
|
51
|
+
end
|
52
|
+
|
53
|
+
def tag_name_for(key)
|
54
|
+
key.to_s.dasherize
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/streamsend/api/list.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module StreamSend
|
2
2
|
module Api
|
3
3
|
module Membership
|
4
|
-
class Index < StreamSend::Api::Call::
|
4
|
+
class Index < StreamSend::Api::Call::Index
|
5
5
|
def execute(person_id, list_id = nil, options = {})
|
6
6
|
@person_id = person_id
|
7
7
|
@list_id = list_id
|
@@ -10,8 +10,21 @@ module StreamSend
|
|
10
10
|
|
11
11
|
def uri
|
12
12
|
base = "#{base_audience_only}/people/#{@person_id}/"
|
13
|
-
|
14
|
-
"#{base}memberships.xml
|
13
|
+
return "#{base}lists/#{@list_id}/memberships.xml" if @list_id
|
14
|
+
"#{base}memberships.xml"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Count < StreamSend::Api::Call::Count
|
19
|
+
def execute(person_id = nil, list_id = nil)
|
20
|
+
@person_id = person_id
|
21
|
+
@list_id = list_id
|
22
|
+
super()
|
23
|
+
end
|
24
|
+
|
25
|
+
def uri
|
26
|
+
return "#{base_audience_only}/people/#{@person_id}/memberships/count.xml" if @person_id
|
27
|
+
"#{base_audience_only}/lists/#{@list_id}/memberships/count.xml"
|
15
28
|
end
|
16
29
|
end
|
17
30
|
|
@@ -21,7 +21,7 @@ module StreamSend
|
|
21
21
|
|
22
22
|
def uri
|
23
23
|
return "#{base_audience_only}/lists/#{@list_id}/people.xml" if @list_id
|
24
|
-
|
24
|
+
super
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -45,10 +45,6 @@ module StreamSend
|
|
45
45
|
index_options.merge!(:query => { :owner_id => owner_id })
|
46
46
|
super(index_options)
|
47
47
|
end
|
48
|
-
|
49
|
-
def uri
|
50
|
-
"#{super}#{paging_query_string}"
|
51
|
-
end
|
52
48
|
end
|
53
49
|
|
54
50
|
class Activate < StreamSend::Api::Call::BaseCall
|
@@ -64,14 +60,14 @@ module StreamSend
|
|
64
60
|
class Click < StreamSend::Api::Click::Index
|
65
61
|
def uri
|
66
62
|
base = "#{session.base_uri}/blasts/#{@blast_id}"
|
67
|
-
return "#{base_blast_only_for(@blast_id)}/links/#{@link_id}/clicks/people.xml
|
68
|
-
"#{base_blast_only_for(@blast_id)}/clicks/people.xml
|
63
|
+
return "#{base_blast_only_for(@blast_id)}/links/#{@link_id}/clicks/people.xml" if @link_id
|
64
|
+
"#{base_blast_only_for(@blast_id)}/clicks/people.xml"
|
69
65
|
end
|
70
66
|
end
|
71
67
|
|
72
68
|
class View < StreamSend::Api::Call::BlastIndex
|
73
69
|
def uri
|
74
|
-
"#{base_blast_only_for(@blast_id)}/views/people.xml
|
70
|
+
"#{base_blast_only_for(@blast_id)}/views/people.xml"
|
75
71
|
end
|
76
72
|
end
|
77
73
|
|
@@ -6,7 +6,38 @@ module StreamSend
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def to_hash
|
9
|
-
self
|
9
|
+
marshal_nested_result_object(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def attributes
|
13
|
+
result_attributes = self.methods.grep /\w=$/
|
14
|
+
result_attributes.collect {|attribute| attribute.to_s.chomp('=')}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.create_nested_result_object(object_hash)
|
18
|
+
return case object_hash
|
19
|
+
when Hash
|
20
|
+
object_hash = object_hash.clone
|
21
|
+
object_hash.each do |key, value|
|
22
|
+
object_hash[key] = create_nested_result_object(value)
|
23
|
+
end
|
24
|
+
Result.new(object_hash)
|
25
|
+
when Array
|
26
|
+
object_hash = object_hash.clone
|
27
|
+
object_hash.map! { |i| create_nested_result_object(i) }
|
28
|
+
else
|
29
|
+
object_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def marshal_nested_result_object(result)
|
36
|
+
result.attributes.each do |attribute|
|
37
|
+
value = result.send(attribute.to_sym)
|
38
|
+
result.send("#{attribute}=", marshal_nested_result_object(value)) if value.is_a?(StreamSend::Api::Result)
|
39
|
+
end
|
40
|
+
result.marshal_dump
|
10
41
|
end
|
11
42
|
end
|
12
43
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module StreamSend
|
2
2
|
module Api
|
3
3
|
class Session
|
4
|
-
def initialize(username = nil, password = nil, base_uri = nil)
|
4
|
+
def initialize(username = nil, password = nil, base_uri = nil, use_xml = nil)
|
5
5
|
@base_uri = load_base_uri(base_uri)
|
6
6
|
@username = load_username(username)
|
7
7
|
@password = load_password(password)
|
8
|
+
@send_data_as_xml = send_data_as_xml?(use_xml)
|
8
9
|
end
|
9
10
|
|
10
11
|
def load_base_uri base_uri
|
@@ -28,6 +29,13 @@ module StreamSend
|
|
28
29
|
raise StreamSend::Api::Exception.new("Unable to create session: no API password provided.")
|
29
30
|
end
|
30
31
|
|
32
|
+
def send_data_as_xml?(send_as_xml)
|
33
|
+
return send_as_xml if send_as_xml
|
34
|
+
return ENV['STREAMSEND_USE_XML'] if ENV['STREAMSEND_USE_XML']
|
35
|
+
return StreamSend::Api::Configuration.send_data_as_xml
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
31
39
|
def get(uri, options = {})
|
32
40
|
options.merge!(self.basic_auth_credentials)
|
33
41
|
HTTParty.get(uri, options)
|
@@ -35,11 +43,13 @@ module StreamSend
|
|
35
43
|
|
36
44
|
def put(uri, options = {})
|
37
45
|
options.merge!(self.basic_auth_credentials)
|
46
|
+
convert_request_to_xml(options) if send_data_as_xml
|
38
47
|
HTTParty.put(uri, options)
|
39
48
|
end
|
40
49
|
|
41
50
|
def post(uri, options = {})
|
42
51
|
options.merge!(self.basic_auth_credentials)
|
52
|
+
convert_request_to_xml(options) if send_data_as_xml
|
43
53
|
HTTMultiParty.post(uri, options)
|
44
54
|
end
|
45
55
|
|
@@ -48,10 +58,19 @@ module StreamSend
|
|
48
58
|
HTTParty.delete(uri, options)
|
49
59
|
end
|
50
60
|
|
61
|
+
def convert_request_to_xml(options)
|
62
|
+
options[:headers]["Content-Type"] = "text/xml"
|
63
|
+
options[:body] = StreamSend::Api::HashXmlSerializer.new.serialize(options[:body])
|
64
|
+
end
|
65
|
+
|
51
66
|
def base_uri
|
52
67
|
@base_uri
|
53
68
|
end
|
54
69
|
|
70
|
+
def send_data_as_xml
|
71
|
+
@send_data_as_xml
|
72
|
+
end
|
73
|
+
|
55
74
|
def basic_auth_credentials
|
56
75
|
{ :basic_auth => { :username => @username, :password => @password } }
|
57
76
|
end
|
@@ -59,7 +78,9 @@ module StreamSend
|
|
59
78
|
def audience_id
|
60
79
|
@audience_id ||= get_audience_id
|
61
80
|
end
|
81
|
+
|
62
82
|
private
|
83
|
+
|
63
84
|
def get_audience_id
|
64
85
|
audience = StreamSend::Api::Audience::Index.new(self).execute().first
|
65
86
|
if audience
|
@@ -6,13 +6,13 @@ module StreamSend
|
|
6
6
|
|
7
7
|
class Manual < StreamSend::Api::Call::BlastIndex
|
8
8
|
def uri
|
9
|
-
"#{base_blast_uri_for(@blast_id)}/manual.xml
|
9
|
+
"#{base_blast_uri_for(@blast_id)}/manual.xml"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Complaint < StreamSend::Api::Call::BlastIndex
|
14
14
|
def uri
|
15
|
-
"#{base_blast_uri_for(@blast_id)}/complaint.xml
|
15
|
+
"#{base_blast_uri_for(@blast_id)}/complaint.xml"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/streamsend/version.rb
CHANGED
data/lib/streamsend.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "httmultiparty"
|
3
3
|
require "ostruct"
|
4
|
+
require "builder"
|
4
5
|
require "active_support/inflector"
|
5
6
|
require "active_support/core_ext"
|
6
7
|
|
@@ -14,6 +15,7 @@ require "streamsend/api/base/show"
|
|
14
15
|
require "streamsend/api/base/update"
|
15
16
|
require "streamsend/api/base/create"
|
16
17
|
require "streamsend/api/base/destroy"
|
18
|
+
require "streamsend/api/base/count"
|
17
19
|
require "streamsend/api/audience"
|
18
20
|
require "streamsend/api/session"
|
19
21
|
|
@@ -37,7 +39,4 @@ require "streamsend/api/unsubscribe"
|
|
37
39
|
require "streamsend/api/upload"
|
38
40
|
require "streamsend/api/view"
|
39
41
|
require "streamsend/api/user"
|
40
|
-
|
41
|
-
module StreamSend
|
42
|
-
PER_PAGE_DEFAULT = 100
|
43
|
-
end
|
42
|
+
require "streamsend/api/hash_xml_serializer"
|
@@ -25,7 +25,7 @@ module StreamSend
|
|
25
25
|
describe Index do
|
26
26
|
it "returns an index of blasts" do
|
27
27
|
index = Index.new(session)
|
28
|
-
blasts = index.execute
|
28
|
+
blasts = index.execute(:page => 1)
|
29
29
|
expect(blasts.count).to be > 0
|
30
30
|
end
|
31
31
|
end
|
@@ -33,9 +33,9 @@ module StreamSend
|
|
33
33
|
describe Scheduled do
|
34
34
|
it "returns scheduled blasts if there are any" do
|
35
35
|
scheduler = Scheduled.new(session)
|
36
|
-
scheduled = scheduler.execute
|
36
|
+
scheduled = scheduler.execute(:page => 1)
|
37
37
|
if scheduled.count > 0
|
38
|
-
scheduled_values = ["scheduled", "preparing"]
|
38
|
+
scheduled_values = ["scheduled", "preparing", "failed to render", "waiting"]
|
39
39
|
expect(scheduled_values).to include(scheduled[0].status)
|
40
40
|
else
|
41
41
|
pending "No scheduled blasts at this time to inspect or something went wrong."
|
@@ -46,7 +46,7 @@ module StreamSend
|
|
46
46
|
describe Sent do
|
47
47
|
it "returns sent blasts" do
|
48
48
|
senter = Sent.new(session)
|
49
|
-
sent = senter.execute
|
49
|
+
sent = senter.execute({:page => 1})
|
50
50
|
expect(sent.count).to be > 0
|
51
51
|
expect(sent[0].status).to eq("sent")
|
52
52
|
end
|
@@ -21,16 +21,19 @@ module StreamSend
|
|
21
21
|
|
22
22
|
describe "#execute" do
|
23
23
|
it "returns an array of bounces" do
|
24
|
+
pending "Can't create bounces"
|
24
25
|
bounces = indexer.execute(@blast_id)
|
25
26
|
expect(bounces.count).to be <= 1
|
26
27
|
end
|
27
28
|
|
28
29
|
it "returns an array of hard bounces" do
|
30
|
+
pending "Can't create bounces"
|
29
31
|
bounces = harder.execute(@blast_id)
|
30
32
|
expect(bounces.count).to eq(0) #can't create a hard bounce :/
|
31
33
|
end
|
32
34
|
|
33
35
|
it "returns an array of soft bounces" do
|
36
|
+
pending "Can't create bounces"
|
34
37
|
bounces = softer.execute(@blast_id)
|
35
38
|
expect(bounces.count).to eq(1)
|
36
39
|
expect(bounces[0].bounce_type).to eq("soft")
|
@@ -21,11 +21,13 @@ module StreamSend
|
|
21
21
|
|
22
22
|
describe "#execute" do
|
23
23
|
it "returns an array of clicks" do
|
24
|
+
pending "Can't create clicks through api"
|
24
25
|
bounces = indexer.execute(blast_id)
|
25
26
|
expect(bounces.count).to be > 0
|
26
27
|
end
|
27
28
|
|
28
29
|
it "returns an array of clicks by link_id" do
|
30
|
+
pending "Can't create clicks through api"
|
29
31
|
bounces = indexer.execute(blast_id, link_id)
|
30
32
|
expect(bounces.count).to be > 0
|
31
33
|
end
|
@@ -17,6 +17,7 @@ module StreamSend
|
|
17
17
|
|
18
18
|
describe Index do
|
19
19
|
it "returns an array of links" do
|
20
|
+
pending "Create blast, don't expect fixture"
|
20
21
|
indexer = Index.new(session)
|
21
22
|
links = indexer.execute(blast_id)
|
22
23
|
expect(links.count).to be > 0
|
@@ -25,6 +26,7 @@ module StreamSend
|
|
25
26
|
|
26
27
|
describe Show do
|
27
28
|
it "returns a link by id" do
|
29
|
+
pending "Create blast, don't expect fixture"
|
28
30
|
indexer = Index.new(session)
|
29
31
|
links = indexer.execute(blast_id)
|
30
32
|
link = links[0]
|
@@ -27,7 +27,7 @@ module StreamSend
|
|
27
27
|
id = creator.execute(membership_hash)
|
28
28
|
|
29
29
|
indexer = Index.new(session)
|
30
|
-
memberships = indexer.execute(person_id)
|
30
|
+
memberships = indexer.execute(person_id, nil, :page => 1)
|
31
31
|
expect(memberships.count).to be > 0
|
32
32
|
|
33
33
|
destroyer = Destroy.new(session)
|
@@ -63,6 +63,32 @@ module StreamSend
|
|
63
63
|
end.to raise_exception(StreamSend::Api::Exception, "Could not find any memberships with the specified id. (404)")
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
describe Count do
|
68
|
+
it "returns a count of people one a list" do
|
69
|
+
creator = Create.new(session)
|
70
|
+
id = creator.execute(membership_hash)
|
71
|
+
|
72
|
+
counter = Count.new(session)
|
73
|
+
people_count = counter.execute(person_id)
|
74
|
+
expect(people_count).to eq(1)
|
75
|
+
|
76
|
+
destroyer = Destroy.new(session)
|
77
|
+
destroyer.execute(id)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns a count of lists a person is on" do
|
81
|
+
creator = Create.new(session)
|
82
|
+
id = creator.execute(membership_hash)
|
83
|
+
|
84
|
+
counter = Count.new(session)
|
85
|
+
list_count = counter.execute(nil, list_id)
|
86
|
+
expect(list_count).to eq(1)
|
87
|
+
|
88
|
+
destroyer = Destroy.new(session)
|
89
|
+
destroyer.execute(id)
|
90
|
+
end
|
91
|
+
end
|
66
92
|
end
|
67
93
|
end
|
68
94
|
end
|