apsis 0.0.1 → 0.1.0
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 +15 -0
- data/.gitignore +3 -0
- data/README.md +1 -1
- data/Rakefile +9 -1
- data/apsis.gemspec +4 -2
- data/lib/apsis.rb +1 -1
- data/lib/apsis/version.rb +1 -1
- data/spec/apsis_spec.rb +38 -0
- data/spec/fixtures/vcr/add_subscriber.yml +41 -0
- data/spec/fixtures/vcr/raise_exception.yml +41 -0
- data/spec/support/vcr.rb +9 -0
- metadata +32 -14
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2FmNmYyMzg0YzA4ZjA2NmZkNTZiNzc5NzU2MDkxMjhhOTg4ODY2Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjM3ZGQ0ZWQwMTA1M2RlNGRlYzYyZWUzZTc4MjgyZWZkYmI4MjhmZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NmZmZWEyYzgyZDcxOTY3YzMyZGJmNDlmOTcwNjcwMTZlYTY4NDY3YmFhNTZi
|
10
|
+
OTQ2NjRhMDA5OThiZWVmZTYxZjA3ODA4ZTI5MjNkMDE5Y2M4Zjc0MTNmMWVl
|
11
|
+
MzI1YTY0MmFmMjQ1NjMzZTgzNGYwY2Y5MDI5NzhjZmE2ZmUxNDc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTQ5Mzg1MDU1NDdjMzZkMjhkZWY3MDA0NDI3MTU1OWJiNjA1MDU3YzIyMWUw
|
14
|
+
M2Y5NzQyODc2ODVhYzdlOWNlYmE4ZTg0NWY0YWJmOWE1YjUxOTliNmFhMTY4
|
15
|
+
ODFkMjgzZDI4YjhhNjE4MDE4OTU5MTI2MDk2MzhiNWNkYzI0ZWI=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ variable (recommended) or provide it as an argument when you instantiate a new A
|
|
27
27
|
# Note that APSIS is fussy about the capitalization of the keys.
|
28
28
|
apsis.create_subscribers(123456, [
|
29
29
|
{ 'Email' => 'johndoe@example.com', 'Name' => 'John Doe' },
|
30
|
-
{ 'Email' => 'janedoe@example.com', 'Name' => '
|
30
|
+
{ 'Email' => 'janedoe@example.com', 'Name' => 'Jane Doe' }
|
31
31
|
])
|
32
32
|
|
33
33
|
## Contributing
|
data/Rakefile
CHANGED
data/apsis.gemspec
CHANGED
@@ -9,8 +9,10 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.authors = ["Henrik Sjökvist"]
|
10
10
|
gem.email = ["henrik.sjokvist@gmail.com"]
|
11
11
|
gem.description = %q{A simple API wrapper for the APSIS mail marketing service.}
|
12
|
-
gem.summary = %q{A simple API wrapper for the APSIS mail marketing service.
|
12
|
+
gem.summary = %q{A simple API wrapper for the APSIS mail marketing service.
|
13
|
+
This gem currently only supports adding subcribers to a mailing list.}
|
13
14
|
gem.homepage = "http://github.com/kollegorna/apsis-ruby"
|
15
|
+
gem.license = 'MIT'
|
14
16
|
|
15
17
|
gem.files = `git ls-files`.split($/)
|
16
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -20,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
20
22
|
gem.rubyforge_project = "apsis"
|
21
23
|
|
22
24
|
# Dependencies
|
23
|
-
# specify any dependencies here; for example:
|
24
25
|
gem.add_development_dependency "rspec"
|
26
|
+
gem.add_development_dependency "vcr"
|
25
27
|
gem.add_runtime_dependency "faraday"
|
26
28
|
end
|
data/lib/apsis.rb
CHANGED
@@ -24,7 +24,7 @@ class Apsis
|
|
24
24
|
unless response.status == 200
|
25
25
|
raise ApsisError.new("Apsis API Error: #{response.body} (status code #{response.status})")
|
26
26
|
end
|
27
|
-
response.body
|
27
|
+
JSON.parse response.body
|
28
28
|
end
|
29
29
|
|
30
30
|
def create_subscribers(mailinglist_id, subscribers = [])
|
data/lib/apsis/version.rb
CHANGED
data/spec/apsis_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'faraday'
|
3
|
+
require_relative 'support/vcr'
|
4
|
+
require_relative '../lib/apsis.rb'
|
5
|
+
|
6
|
+
|
7
|
+
unless ENV['APSIS_API_KEY'] && ENV['APSIS_TEST_MAILING_LIST']
|
8
|
+
warn ["WARNING: You need to set the APSIS_API_KEY and APSIS_TEST_MAILING_LIST",
|
9
|
+
"environment variables or the calls to the APSIS API will be invalid."].join("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "Apsis" do
|
13
|
+
it "adds a subscriber to a list" do
|
14
|
+
VCR.use_cassette('add_subscriber') do
|
15
|
+
api_key = ENV['APSIS_API_KEY']
|
16
|
+
mailing_list = ENV['APSIS_TEST_MAILING_LIST']
|
17
|
+
apsis = Apsis.new(api_key)
|
18
|
+
response = apsis.create_subscribers(mailing_list, [
|
19
|
+
{ 'Email' => 'johndoe@example.com', 'Name' => 'John Doe' },
|
20
|
+
{ 'Email' => 'janedoe@example.com', 'Name' => 'Jane Doe' }
|
21
|
+
])
|
22
|
+
response['Code'].should eql 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "raises an exception when an error HTTP status code is returned" do
|
27
|
+
VCR.use_cassette('raise_exception') do
|
28
|
+
api_key = ENV['APSIS_API_KEY']
|
29
|
+
mailing_list = 'thisisnogood'
|
30
|
+
apsis = Apsis.new(api_key)
|
31
|
+
lambda {
|
32
|
+
apsis.create_subscribers(mailing_list, [
|
33
|
+
{ 'Email' => 'johndoe@example.com', 'Name' => 'John Doe' },
|
34
|
+
{ 'Email' => 'janedoe@example.com', 'Name' => 'Jane Doe' }
|
35
|
+
])}.should raise_error(Apsis::ApsisError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://se.api.anpdm.com/v1/subscribers/mailinglist/<MAILING_LIST>/queue
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '[{"Email":"johndoe@example.com","Name":"John Doe"},{"Email":"janedoe@example.com","Name":"Jane
|
9
|
+
Doe"}]'
|
10
|
+
headers:
|
11
|
+
Accept:
|
12
|
+
- application/json
|
13
|
+
User-Agent:
|
14
|
+
- Faraday v0.8.6
|
15
|
+
Authorization:
|
16
|
+
- <KEY>
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message:
|
23
|
+
headers:
|
24
|
+
cache-control:
|
25
|
+
- private
|
26
|
+
content-length:
|
27
|
+
- '230'
|
28
|
+
content-type:
|
29
|
+
- application/json; charset=utf-8
|
30
|
+
server:
|
31
|
+
- Microsoft-IIS/7.0
|
32
|
+
date:
|
33
|
+
- Tue, 12 Mar 2013 15:10:06 GMT
|
34
|
+
connection:
|
35
|
+
- close
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"Code":1,"Message":"Creating subscribers will be handled shortly...","Result":{"OperationGuid":"9b087599-e26d-47f8-932b-03092fb91fd0","PollURL":"http:\/\/se.api.anpdm.com\/data\/9b087599-e26d-47f8-932b-03092fb91fd0_status.json"}}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Tue, 12 Mar 2013 15:10:01 GMT
|
41
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://se.api.anpdm.com/v1/subscribers/mailinglist/thisisnogood/queue
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '[{"Email":"johndoe@example.com","Name":"John Doe"},{"Email":"janedoe@example.com","Name":"Jane
|
9
|
+
Doe"}]'
|
10
|
+
headers:
|
11
|
+
Accept:
|
12
|
+
- application/json
|
13
|
+
User-Agent:
|
14
|
+
- Faraday v0.8.6
|
15
|
+
Authorization:
|
16
|
+
- <KEY>
|
17
|
+
Content-Type:
|
18
|
+
- application/json
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 400
|
22
|
+
message:
|
23
|
+
headers:
|
24
|
+
cache-control:
|
25
|
+
- private
|
26
|
+
content-length:
|
27
|
+
- '74'
|
28
|
+
content-type:
|
29
|
+
- application/json; charset=utf-8
|
30
|
+
server:
|
31
|
+
- Microsoft-IIS/7.0
|
32
|
+
date:
|
33
|
+
- Tue, 12 Mar 2013 15:10:09 GMT
|
34
|
+
connection:
|
35
|
+
- close
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"Code":-2,"Message":"MailinglistId must be greater than 0","Result":null}'
|
39
|
+
http_version:
|
40
|
+
recorded_at: Tue, 12 Mar 2013 15:10:04 GMT
|
41
|
+
recorded_with: VCR 2.4.0
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
VCR.configure do |c|
|
2
|
+
c.cassette_library_dir = 'spec/fixtures/vcr'
|
3
|
+
c.hook_into :faraday
|
4
|
+
c.filter_sensitive_data('<KEY>') do |interaction|
|
5
|
+
interaction.request.headers['Authorization'].first
|
6
|
+
end
|
7
|
+
c.filter_sensitive_data('<MAILING_LIST>') { ENV['APSIS_TEST_MAILING_LIST'] }
|
8
|
+
end
|
9
|
+
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apsis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Henrik Sjökvist
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,20 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: vcr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
37
|
requirements:
|
27
38
|
- - ! '>='
|
28
39
|
- !ruby/object:Gem::Version
|
@@ -30,7 +41,6 @@ dependencies:
|
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: faraday
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
45
|
- - ! '>='
|
36
46
|
- !ruby/object:Gem::Version
|
@@ -38,7 +48,6 @@ dependencies:
|
|
38
48
|
type: :runtime
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
52
|
- - ! '>='
|
44
53
|
- !ruby/object:Gem::Version
|
@@ -58,28 +67,37 @@ files:
|
|
58
67
|
- apsis.gemspec
|
59
68
|
- lib/apsis.rb
|
60
69
|
- lib/apsis/version.rb
|
70
|
+
- spec/apsis_spec.rb
|
71
|
+
- spec/fixtures/vcr/add_subscriber.yml
|
72
|
+
- spec/fixtures/vcr/raise_exception.yml
|
73
|
+
- spec/support/vcr.rb
|
61
74
|
homepage: http://github.com/kollegorna/apsis-ruby
|
62
|
-
licenses:
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
63
78
|
post_install_message:
|
64
79
|
rdoc_options: []
|
65
80
|
require_paths:
|
66
81
|
- lib
|
67
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
83
|
requirements:
|
70
84
|
- - ! '>='
|
71
85
|
- !ruby/object:Gem::Version
|
72
86
|
version: '0'
|
73
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
88
|
requirements:
|
76
89
|
- - ! '>='
|
77
90
|
- !ruby/object:Gem::Version
|
78
91
|
version: '0'
|
79
92
|
requirements: []
|
80
93
|
rubyforge_project: apsis
|
81
|
-
rubygems_version:
|
94
|
+
rubygems_version: 2.0.3
|
82
95
|
signing_key:
|
83
|
-
specification_version:
|
84
|
-
summary: A simple API wrapper for the APSIS mail marketing service.
|
85
|
-
|
96
|
+
specification_version: 4
|
97
|
+
summary: A simple API wrapper for the APSIS mail marketing service. This gem currently
|
98
|
+
only supports adding subcribers to a mailing list.
|
99
|
+
test_files:
|
100
|
+
- spec/apsis_spec.rb
|
101
|
+
- spec/fixtures/vcr/add_subscriber.yml
|
102
|
+
- spec/fixtures/vcr/raise_exception.yml
|
103
|
+
- spec/support/vcr.rb
|