apsis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in apsis.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Henrik Sjökvist
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # APSIS API wrapper for Ruby
2
+
3
+ A simple API wrapper for the APSIS mail marketing service. Currently
4
+ only supports adding subscribers to a mailing list.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'apsis'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install apsis
19
+
20
+ ## Usage
21
+
22
+ Either provide your APSIS API key using the `APSIS_API_KEY` environment
23
+ variable (recommended) or provide it as an argument when you instantiate a new Apsis object
24
+
25
+ apsis = Apsis.new
26
+ # Add two new subscribers to the mailing list with id 123456
27
+ # Note that APSIS is fussy about the capitalization of the keys.
28
+ apsis.create_subscribers(123456, [
29
+ { 'Email' => 'johndoe@example.com', 'Name' => 'John Doe' },
30
+ { 'Email' => 'janedoe@example.com', 'Name' => 'jane.doe@example.com' }
31
+ ])
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'apsis/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "apsis"
8
+ gem.version = Apsis::VERSION
9
+ gem.authors = ["Henrik Sjökvist"]
10
+ gem.email = ["henrik.sjokvist@gmail.com"]
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.}
13
+ gem.homepage = "http://github.com/kollegorna/apsis-ruby"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.rubyforge_project = "apsis"
21
+
22
+ # Dependencies
23
+ # specify any dependencies here; for example:
24
+ gem.add_development_dependency "rspec"
25
+ gem.add_runtime_dependency "faraday"
26
+ end
@@ -0,0 +1,33 @@
1
+ require 'apsis/version'
2
+ require 'faraday'
3
+ require 'json'
4
+
5
+ class Apsis
6
+ ApsisError = Class.new(StandardError)
7
+
8
+ def initialize(api_key = nil, default_parameters = {})
9
+ @api_key = api_key || ENV['APSIS_API_KEY']
10
+
11
+ @conn = Faraday.new(
12
+ url: 'https://se.api.anpdm.com/v1/',
13
+ ssl: { verify: false },
14
+ headers: { accept: 'application/json' })
15
+ @conn.basic_auth(@api_key, '')
16
+ end
17
+
18
+ def call(endpoint, params)
19
+ response = @conn.post do |req|
20
+ req.url endpoint
21
+ req.headers['Content-Type'] = 'application/json'
22
+ req.body = params.to_json
23
+ end
24
+ unless response.status == 200
25
+ raise ApsisError.new("Apsis API Error: #{response.body} (status code #{response.status})")
26
+ end
27
+ response.body
28
+ end
29
+
30
+ def create_subscribers(mailinglist_id, subscribers = [])
31
+ call("subscribers/mailinglist/#{mailinglist_id}/queue", subscribers)
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ class Apsis
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apsis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Henrik Sjökvist
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: faraday
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A simple API wrapper for the APSIS mail marketing service.
47
+ email:
48
+ - henrik.sjokvist@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - apsis.gemspec
59
+ - lib/apsis.rb
60
+ - lib/apsis/version.rb
61
+ homepage: http://github.com/kollegorna/apsis-ruby
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project: apsis
81
+ rubygems_version: 1.8.24
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: A simple API wrapper for the APSIS mail marketing service.
85
+ test_files: []