streamsend 0.2.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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
data/.gitignore CHANGED
@@ -1,5 +1,18 @@
1
- .DS_Store
2
- tags
3
- spec/integration/integration.yml
4
- .git-commit-story.yml
5
- logfile.log
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format progress
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source "https://rubygems.org"
1
+ source "http://rubygems.org"
2
2
 
3
+ # Specify your gem's dependencies in streamsend-ruby.gemspec
3
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,42 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- streamsend (0.2.2)
4
+ streamsend (1.0.0.rc1)
5
5
  activesupport (~> 3.2)
6
6
  builder
7
- httparty
7
+ httmultiparty
8
8
 
9
9
  GEM
10
- remote: https://rubygems.org/
10
+ remote: http://rubygems.org/
11
11
  specs:
12
12
  activesupport (3.2.14)
13
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
+ columnize (0.3.6)
17
18
  crack (0.4.0)
18
19
  safe_yaml (~> 0.9.0)
19
20
  diff-lcs (1.2.4)
20
21
  git-commit-story (0.1.5)
22
+ httmultiparty (0.3.10)
23
+ httparty (>= 0.7.3)
24
+ multipart-post
21
25
  httparty (0.11.0)
22
26
  multi_json (~> 1.0)
23
27
  multi_xml (>= 0.5.2)
24
28
  i18n (0.6.5)
25
- multi_json (1.8.0)
29
+ linecache (0.46)
30
+ rbx-require-relative (> 0.0.4)
31
+ multi_json (1.8.1)
26
32
  multi_xml (0.5.5)
33
+ multipart-post (1.2.0)
27
34
  pair-salad (0.1.1)
28
- rspec (2.13.0)
29
- rspec-core (~> 2.13.0)
30
- rspec-expectations (~> 2.13.0)
31
- rspec-mocks (~> 2.13.0)
32
- rspec-core (2.13.1)
33
- rspec-expectations (2.13.0)
35
+ rbx-require-relative (0.0.9)
36
+ rspec (2.14.1)
37
+ rspec-core (~> 2.14.0)
38
+ rspec-expectations (~> 2.14.0)
39
+ rspec-mocks (~> 2.14.0)
40
+ rspec-core (2.14.5)
41
+ rspec-expectations (2.14.3)
34
42
  diff-lcs (>= 1.1.3, < 2.0)
35
- rspec-mocks (2.13.1)
36
- ruby-fsevent (0.2.1)
43
+ rspec-mocks (2.14.3)
44
+ ruby-debug (0.10.4)
45
+ columnize (>= 0.1)
46
+ ruby-debug-base (~> 0.10.4.0)
47
+ ruby-debug-base (0.10.4)
48
+ linecache (>= 0.3)
37
49
  safe_yaml (0.9.3)
38
- vcr (2.5.0)
39
- watchr (0.7)
40
50
  webmock (1.12.3)
41
51
  addressable (>= 2.2.7)
42
52
  crack (>= 0.3.2)
@@ -48,8 +58,6 @@ DEPENDENCIES
48
58
  git-commit-story
49
59
  pair-salad
50
60
  rspec
51
- ruby-fsevent
61
+ ruby-debug
52
62
  streamsend!
53
- vcr
54
- watchr
55
63
  webmock (~> 1.6)
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # streamsend-ruby
2
+
3
+ streamsend-ruby is a thin ruby wrapper for the StreamSend API.
4
+
5
+ ### Getting started
6
+
7
+ **Creating a session**
8
+ Credentials can be passed in when initializing the session:
9
+
10
+ Session::Api::Session.new("my_ss_api_username", "secret_api_password")
11
+
12
+ Set via environment variables:
13
+
14
+ export STREAMSEND_USERNAME="my_ss_api_username"
15
+ export STREAMSEND_PASSWORD="secret_api_password"
16
+
17
+ Set via config file (gem checks for config/streamsend-ruby.yml):
18
+
19
+ root_account:
20
+ username: "my_ss_api_username"
21
+ password: "secret_api_password"
22
+
23
+ The base_uri can also be set in the same ways (e.g. STREAMSEND_BASE_URI="http://my.branded.url", and base_uri:
24
+ "http://my.branded.url"), but is optional and defaults to
25
+ <https://app.streamsend.com>
26
+
27
+ **Making Calls**
28
+
29
+ The show and index calls return a single or array of StreamSend::Api::Result
30
+ objects. The StreamSend::Api::Result object is just an OpenStruct that responds
31
+ to id with the hash value of id rather than the Ruby id. It also has to_hash
32
+ defined as an alias to marshaldump. Create and update take an object hash of
33
+ whatever it is that you're creating/updating. The object values should be nested
34
+ in a hash with a key corresponding to the object type:
35
+
36
+ `{ :list => { :name => "This is my new list!" } }`
37
+
38
+ OR
39
+
40
+ { :list => my_list_result_object.to_hash }
41
+ #working with a result object named my_list_result_object.
42
+
43
+ ### Examples:
44
+
45
+ **Index**
46
+
47
+ #Assuming credentials are set in env variables or in config file...
48
+ session = StreamSend::Api::Session.new()
49
+ index_call = StreamSend::Api::List::Index.new(session)
50
+ #Getting an array of StreamSend::Api::Result objects that respond like lists
51
+ lists =index_call.execute
52
+
53
+ **Create**
54
+
55
+ session = StreamSend::Api::Session.new()
56
+ create_call =StreamSend::Api::List::Create.new(session)
57
+ list_id = create_call.execute(:list => {:name => "new list!"})
58
+
59
+ **Show**
60
+
61
+ session = StreamSend::Api::Session.new("ss_api_username", "ss_api_pasword")
62
+ show_call = StreamSend::Api::List.Show.new(session)
63
+ list = show_call.execute(list_id)
64
+
65
+ **Destroy**
66
+
67
+ session = StreamSend::Api::Session.new("ss_api_username", "ss_api_pasword")
68
+ destroy_call = StreamSend::Api::List.Destroy.new(session)
69
+ destroy_call.execute(list_id)
70
+ #returns a bool indicating if it was destroyed
71
+
72
+ **Update**
73
+
74
+ session = StreamSend::Api::Session.new()
75
+ update_call = StreamSend::Api::List::Update.new(session)
76
+ update_call.execute(list_id, :list => {:name => "updated list!"})
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -1,61 +1,19 @@
1
- require "active_support/core_ext/hash"
2
- require File.expand_path(__FILE__, "exception")
3
-
4
1
  module StreamSend
5
2
  module Api
6
- class Account < Resource
7
- def self.all
8
- response = StreamSend::Api.get("/accounts.xml")
9
-
10
- case response.code
11
- when 200
12
- response["accounts"].collect { |data| new(data) }
13
- else
14
- raise StreamSend::Api::Exception.new("Could not find any accounts. Make sure your api username and password are correct. (#{response.code})")
15
- end
3
+ module Account
4
+ class Index < StreamSend::Api::Call::Index
16
5
  end
17
6
 
18
- def self.show(id)
19
- response = StreamSend::Api.get("/accounts/#{id}.xml")
20
- case response.code
21
- when 200
22
- new(response["account"])
23
- else
24
- raise StreamSend::Api::Exception.new("Could not find the account. Make sure your account ID is correct. (#{response.code})")
25
- end
7
+ class Show < StreamSend::Api::Call::Show
26
8
  end
27
9
 
28
- def self.update(account_hash)
29
- response = StreamSend::Api.put("/accounts/#{account_hash['account_id']}/users/#{account_hash['user_id']}.xml", :body => account_hash.to_xml)
30
- case response.code
31
- when 200
32
- true
33
- else
34
- false
35
- end
10
+ class Update < StreamSend::Api::Call::Update
36
11
  end
37
12
 
38
- def self.create(account_hash)
39
- response = StreamSend::Api.post("/accounts.xml", :body => {:account => account_hash})
40
- case response.code
41
- when 201
42
- response.headers["location"] =~ %r(/accounts/(\d+))
43
- account_id = $1
44
- account_id.to_i
45
- else
46
- raise StreamSend::Api::Exception.new("Could not create the account. (#{response.code})")
47
- end
13
+ class Destory < StreamSend::Api::Call::Destroy
48
14
  end
49
15
 
50
- def self.destroy(id)
51
- id = id.to_i
52
- response = StreamSend::Api.delete("/accounts/#{id}.xml")
53
- case response.code
54
- when 200
55
- true
56
- else
57
- raise StreamSend::Api::Exception.new("Could not delete the account. (#{response.code})")
58
- end
16
+ class Create < StreamSend::Api::Call::Create
59
17
  end
60
18
  end
61
19
  end
@@ -0,0 +1,14 @@
1
+ module StreamSend
2
+ module Api
3
+ class Audience
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
+ end
13
+ end
14
+ end
@@ -0,0 +1,60 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class BaseCall
5
+ def initialize(session)
6
+ @session = session
7
+ end
8
+
9
+ def session
10
+ @session
11
+ end
12
+
13
+ def namespace
14
+ namespaces = self.class.name.split("::")
15
+ namespaces[namespaces.count - 2].tableize.downcase
16
+ end
17
+
18
+ def base_uri
19
+ "#{session.base_uri}/#{namespace}"
20
+ end
21
+
22
+ def base_audience_only
23
+ "#{session.base_uri}/audiences/#{session.audience_id}"
24
+ end
25
+
26
+ def base_blast_only_for blast_id
27
+ "#{session.base_uri}/blasts/#{blast_id}"
28
+ end
29
+
30
+ def base_audience_uri
31
+ "#{session.base_uri}/audiences/#{session.audience_id}/#{namespace}"
32
+ end
33
+
34
+ def base_blast_uri_for blast_id
35
+ "#{session.base_uri}/blasts/#{blast_id}/#{namespace}"
36
+ end
37
+
38
+ def user_uri_for(account_id, user_id)
39
+ "#{session.base_uri}/accounts/#{account_id}/users/#{user_id}.xml"
40
+ end
41
+
42
+ def users_uri account_id
43
+ "#{session.base_uri}/accounts/#{account_id}/users.xml"
44
+ end
45
+
46
+ def blast_uri_for blast_id
47
+ "#{base_blast_uri_for(blast_id)}.xml"
48
+ end
49
+
50
+ def audience_uri_for id
51
+ "#{base_audience_uri}/#{id}.xml"
52
+ end
53
+
54
+ def audiences_uri
55
+ "#{base_audience_uri}.xml"
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,41 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class Create < StreamSend::Api::Call::BaseCall
5
+ def execute(object_hash, options = {})
6
+ options.merge!(:body => object_hash)
7
+ response = session.post(uri, options)
8
+ case response.code
9
+ when 201
10
+ response.headers["location"].split("/").last.to_i
11
+ when 422
12
+ raise StreamSend::Api::SemanticException.new(response["errors"]["error"])
13
+ else
14
+ raise StreamSend::Api::Exception.new("Could not create the #{namespace}. (#{response.code})")
15
+ end
16
+ end
17
+
18
+ def uri
19
+ "#{base_uri}.xml"
20
+ end
21
+ end
22
+
23
+ class AudienceCreate < StreamSend::Api::Call::Create
24
+ def uri
25
+ audiences_uri
26
+ end
27
+ end
28
+
29
+ class BlastCreate < StreamSend::Api::Call::Create
30
+ def execute(blast_id, object_hash)
31
+ @blast_id = blast_id
32
+ super(object_hash)
33
+ end
34
+
35
+ def uri
36
+ blast_uri_for @blast_id
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class Destroy < StreamSend::Api::Call::BaseCall
5
+ def execute(object_id)
6
+ @id = object_id
7
+ response = session.delete(uri)
8
+ case response.code
9
+ when 200
10
+ true
11
+ else
12
+ raise StreamSend::Api::Exception.new "Could not delete #{namespace}. (#{response.code})"
13
+ end
14
+ end
15
+
16
+ def uri
17
+ "#{base_uri}/#{id}.xml"
18
+ end
19
+
20
+ def id
21
+ @id
22
+ end
23
+ end
24
+
25
+ class AudienceDestroy < StreamSend::Api::Call::Destroy
26
+ def uri
27
+ audience_uri_for id
28
+ end
29
+ end
30
+
31
+ class BlastDestroy < StreamSend::Api::Call::Destroy
32
+ def execute(blast_id, object_id)
33
+ @blast_id = blast_id
34
+ super(object_id)
35
+ end
36
+
37
+ def uri
38
+ "#{base_blast_uri_for(@blast_id)}/#{id}.xml"
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class Index < StreamSend::Api::Call::BaseCall
5
+ def execute(index_options = {})
6
+ @options = index_options
7
+ response = session.get(uri, @options)
8
+ case response.code
9
+ when 200
10
+ response.parsed_response[namespace].collect { |data| StreamSend::Api::Result.new(data) }
11
+ else
12
+ raise StreamSend::Api::Exception.new("Could not find any #{namespace}. (#{response.code})")
13
+ end
14
+ end
15
+
16
+ def uri
17
+ "#{base_uri}.xml"
18
+ end
19
+
20
+ def paging_query_string
21
+ "?page=#{page}&per_page=#{per_page}"
22
+ end
23
+
24
+ def page
25
+ @options[:page] || 1
26
+ end
27
+
28
+ def per_page
29
+ @options[:per_page] || StreamSend::PER_PAGE_DEFAULT
30
+ end
31
+ end
32
+
33
+ class AudienceIndex < StreamSend::Api::Call::Index
34
+ def uri
35
+ audiences_uri
36
+ end
37
+ end
38
+
39
+ class BlastIndex < StreamSend::Api::Call::Index
40
+ def execute(blast_id, index_options = {})
41
+ @blast_id = blast_id
42
+ super(index_options)
43
+ end
44
+
45
+ def uri
46
+ "#{blast_uri_for(@blast_id)}#{paging_query_string}"
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,42 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class Show < StreamSend::Api::Call::BaseCall
5
+ def execute(object_id)
6
+ @id = object_id
7
+ response = session.get(uri)
8
+ case response.code
9
+ when 200
10
+ StreamSend::Api::Result.new(response.parsed_response[namespace.singularize])
11
+ else
12
+ raise StreamSend::Api::Exception.new("Could not find any #{namespace} with the specified id. (#{response.code})")
13
+ end
14
+ end
15
+
16
+ def uri
17
+ "#{base_uri}/#{id}.xml"
18
+ end
19
+
20
+ def id
21
+ @id
22
+ end
23
+ end
24
+
25
+ class AudienceShow < StreamSend::Api::Call::Show
26
+ def uri
27
+ audience_uri_for id
28
+ end
29
+ end
30
+
31
+ class BlastShow < StreamSend::Api::Call::Show
32
+ def execute(blast_id, object_id)
33
+ @blast_id = blast_id
34
+ super(object_id)
35
+ end
36
+ def uri
37
+ "#{base_blast_uri_for(@blast_id)}/#{id}.xml"
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ module StreamSend
2
+ module Api
3
+ module Call
4
+ class Update < StreamSend::Api::Call::BaseCall
5
+ def execute(object_id, object_hash)
6
+ @id = object_id
7
+ response = session.put(uri, :body => object_hash)
8
+ case response.code
9
+ when 200
10
+ true
11
+ else
12
+ false
13
+ end
14
+ end
15
+
16
+ def uri
17
+ "#{base_uri}/#{@id}.xml"
18
+ end
19
+
20
+ def id
21
+ @id
22
+ end
23
+ end
24
+
25
+ class AudienceUpdate < StreamSend::Api::Call::Update
26
+ def uri
27
+ audience_uri_for id
28
+ end
29
+ end
30
+
31
+ class BlastUpdate < StreamSend::Api::Call::Update
32
+ def execute(blast_id, object_id, object_hash)
33
+ @blast_id = blast_id
34
+ super(object_id, object_hash)
35
+ end
36
+
37
+ def uri
38
+ "#{base_blast_uri_for(@blast_id)}/#{id}.xml"
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ module StreamSend
2
+ module Api
3
+ module Blast
4
+ class Index < StreamSend::Api::Call::AudienceIndex
5
+ def uri
6
+ "#{audiences_uri}#{paging_query_string}"
7
+ end
8
+ end
9
+
10
+ class Scheduled < StreamSend::Api::Call::AudienceIndex
11
+ def uri
12
+ "#{base_audience_uri}/scheduled.xml#{paging_query_string}"
13
+ end
14
+ end
15
+
16
+ class Sent < StreamSend::Api::Call::AudienceIndex
17
+ def uri
18
+ "#{base_audience_uri}/sent.xml#{paging_query_string}"
19
+ end
20
+ end
21
+
22
+ class Show < StreamSend::Api::Call::AudienceShow
23
+ end
24
+
25
+ class Update < StreamSend::Api::Call::AudienceUpdate
26
+ end
27
+
28
+ class Destroy < StreamSend::Api::Call::AudienceDestroy
29
+ end
30
+
31
+ class Create < StreamSend::Api::Call::AudienceCreate
32
+ end
33
+
34
+ class Test < StreamSend::Api::Call::AudienceCreate
35
+ def execute(blast_hash)
36
+ response = session.post(uri, :body => blast_hash)
37
+ return response.code if response.code == 200
38
+ if response.code == 422
39
+ raise StreamSend::Api::SemanticException.new(response["errors"]["error"])
40
+ else
41
+ raise StreamSend::Api::Exception.new("Could not send test blast. (#{response.code})")
42
+ end
43
+ end
44
+
45
+ def uri
46
+ "#{base_audience_uri}/test.xml"
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,20 @@
1
+ module StreamSend
2
+ module Api
3
+ module Bounce
4
+ class Index < StreamSend::Api::Call::BlastIndex
5
+ end
6
+
7
+ class Soft < StreamSend::Api::Call::BlastIndex
8
+ def uri
9
+ "#{base_blast_uri_for(@blast_id)}/soft.xml#{paging_query_string}"
10
+ end
11
+ end
12
+
13
+ class Hard < StreamSend::Api::Call::BlastIndex
14
+ def uri
15
+ "#{base_blast_uri_for(@blast_id)}/hard.xml#{paging_query_string}"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ module StreamSend
2
+ module Api
3
+ module Click
4
+ class Index < StreamSend::Api::Call::Index
5
+ def execute(blast_id, link_id = nil, options = {})
6
+ @blast_id = blast_id
7
+ @link_id = link_id if link_id
8
+ super(options)
9
+ end
10
+
11
+ def uri
12
+ return "#{base_blast_only_for(@blast_id)}/links/#{@link_id}/clicks.xml#{paging_query_string}" if @link_id
13
+ "#{base_blast_uri_for(@blast_id)}.xml#{paging_query_string}"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module StreamSend
2
+ module Api
3
+ class Configuration
4
+ def self.config
5
+ @config ||= load_config_file
6
+ end
7
+
8
+ def self.load_config_file
9
+ file_path = "config/streamsend-ruby.yml"
10
+ return YAML.load(ERB.new(IO.read(file_path)).result) if File.file?(file_path)
11
+ end
12
+
13
+ def self.username
14
+ config["root_account"]["username"] if config
15
+ end
16
+
17
+ def self.password
18
+ config["root_account"]["password"] if config
19
+ end
20
+
21
+ def self.base_uri
22
+ config["root_account"]["base_uri"] if config
23
+ end
24
+ end
25
+ end
26
+ end