sendicate 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +20 -0
- data/README.md +74 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/lib/sendicate.rb +25 -0
- data/lib/sendicate/import.rb +52 -0
- data/lib/sendicate/list.rb +87 -0
- data/lib/sendicate/request.rb +52 -0
- data/sendicate.gemspec +70 -0
- data/spec/sendicate/import_spec.rb +39 -0
- data/spec/sendicate/list_spec.rb +74 -0
- data/spec/sendicate_spec.rb +16 -0
- data/spec/spec_helper.rb +15 -0
- metadata +163 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.2.2)
|
5
|
+
git (1.2.5)
|
6
|
+
httparty (0.10.2)
|
7
|
+
multi_json (~> 1.0)
|
8
|
+
multi_xml (>= 0.5.2)
|
9
|
+
jeweler (1.8.4)
|
10
|
+
bundler (~> 1.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
rdoc
|
14
|
+
json (1.7.7)
|
15
|
+
multi_json (1.7.2)
|
16
|
+
multi_xml (0.5.3)
|
17
|
+
rake (10.0.4)
|
18
|
+
rdoc (4.0.1)
|
19
|
+
json (~> 1.4)
|
20
|
+
rspec (2.13.0)
|
21
|
+
rspec-core (~> 2.13.0)
|
22
|
+
rspec-expectations (~> 2.13.0)
|
23
|
+
rspec-mocks (~> 2.13.0)
|
24
|
+
rspec-core (2.13.1)
|
25
|
+
rspec-expectations (2.13.0)
|
26
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
27
|
+
rspec-mocks (2.13.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler
|
34
|
+
httparty
|
35
|
+
jeweler
|
36
|
+
multi_json
|
37
|
+
rake
|
38
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Evan Whalen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Sendicate
|
2
|
+
|
3
|
+
This gem is a wrapper for the [Sendicate API](https://github.com/Sendicate/sendicate-docs/tree/master/api).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
gem install sendicate
|
9
|
+
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
You will need a Sendicate account and [API token](https://www.sendicate.net/account/edit).
|
14
|
+
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Configure your API token. You can either set the environment variable SENDICATE_API_TOKEN to your api token or hardcode it.
|
19
|
+
|
20
|
+
export SENDICATE_API_TOKEN='YOUR_API_TOKEN'
|
21
|
+
# or
|
22
|
+
Sendicate.api_token = 'YOUR_API_TOKEN'
|
23
|
+
|
24
|
+
Create a new list:
|
25
|
+
|
26
|
+
list = Sendicate::List.new(title: 'Life-changing newsletter')
|
27
|
+
list.save
|
28
|
+
|
29
|
+
View all lists:
|
30
|
+
|
31
|
+
lists = Sendicate::List.all
|
32
|
+
|
33
|
+
Update a list:
|
34
|
+
|
35
|
+
list.title = 'not spam'
|
36
|
+
list.save
|
37
|
+
|
38
|
+
Destroy a list:
|
39
|
+
|
40
|
+
list.destroy
|
41
|
+
|
42
|
+
Add a subcriber to a list:
|
43
|
+
|
44
|
+
import = Sendicate::Import.new(
|
45
|
+
list_id: LIST_ID,
|
46
|
+
data: {
|
47
|
+
email: 'user@example.com',
|
48
|
+
name: 'New User'
|
49
|
+
}
|
50
|
+
)
|
51
|
+
|
52
|
+
if import.save
|
53
|
+
puts 'success'
|
54
|
+
else
|
55
|
+
puts import.error_messages
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
## Contributing to sendicate-ruby
|
60
|
+
|
61
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
62
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
63
|
+
* Fork the project.
|
64
|
+
* Start a feature/bugfix branch.
|
65
|
+
* Commit and push until you are happy with your contribution.
|
66
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
67
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
68
|
+
|
69
|
+
|
70
|
+
## Copyright
|
71
|
+
|
72
|
+
Copyright (c) 2013 Evan Whalen. See LICENSE.txt for
|
73
|
+
further details.
|
74
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "sendicate"
|
18
|
+
gem.homepage = "http://github.com/evanwhalen/sendicate-ruby"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Sendicate API Wrapper}
|
21
|
+
gem.description = %Q{Use this Sendicate API wrapper to subscribe your users to your Sendicate mailing lists.}
|
22
|
+
gem.email = "evanwhalendev@gmail.com"
|
23
|
+
gem.authors = ["Evan Whalen"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/sendicate.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Sendicate
|
5
|
+
extend self
|
6
|
+
|
7
|
+
autoload :Import, 'sendicate/import'
|
8
|
+
autoload :List, 'sendicate/list'
|
9
|
+
autoload :Request, 'sendicate/request'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :api_token
|
13
|
+
end
|
14
|
+
|
15
|
+
class BadRequest < StandardError
|
16
|
+
end
|
17
|
+
|
18
|
+
class ResourceNotFound < StandardError
|
19
|
+
end
|
20
|
+
|
21
|
+
class Unauthorized < StandardError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Sendicate.api_token = ENV['SENDICATE_API_TOKEN']
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Sendicate
|
2
|
+
|
3
|
+
class Import
|
4
|
+
include HTTParty
|
5
|
+
base_uri 'https://api.sendicate.net/v1'
|
6
|
+
headers 'Accept' => 'application/json', 'Content-Type' => 'application/json', "Authorization" => "token #{Sendicate.api_token}"
|
7
|
+
|
8
|
+
attr_reader :list_id, :data, :response, :errors
|
9
|
+
|
10
|
+
def initialize(attributes)
|
11
|
+
@list_id = attributes[:list_id]
|
12
|
+
@data = attributes[:data]
|
13
|
+
end
|
14
|
+
|
15
|
+
def save
|
16
|
+
@response = Sendicate::Request.post("/lists/#{list_id}/subscribers", body: MultiJson.dump(data))
|
17
|
+
success?
|
18
|
+
end
|
19
|
+
|
20
|
+
def success?
|
21
|
+
response && response.success?
|
22
|
+
end
|
23
|
+
|
24
|
+
def imported
|
25
|
+
parsed_response["imported"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def updated
|
29
|
+
parsed_response["updated"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def failed
|
33
|
+
parsed_response["failed"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def parsed_response
|
37
|
+
response && response.parsed_response
|
38
|
+
end
|
39
|
+
|
40
|
+
def errors
|
41
|
+
parsed_response['errors']
|
42
|
+
end
|
43
|
+
|
44
|
+
def error_messages
|
45
|
+
errors.map do |error|
|
46
|
+
error['errors'].map do |e|
|
47
|
+
e['message']
|
48
|
+
end
|
49
|
+
end.flatten
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Sendicate
|
2
|
+
|
3
|
+
class List
|
4
|
+
|
5
|
+
attr_reader :attributes, :errors
|
6
|
+
|
7
|
+
def initialize(attributes={})
|
8
|
+
@attributes = attributes
|
9
|
+
@errors = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method, *args)
|
13
|
+
method_string = method.to_s
|
14
|
+
is_setter_method = method_string[-1, 1] == '='
|
15
|
+
key = method_string.gsub(/\=/, '')
|
16
|
+
|
17
|
+
if attributes.include?(key)
|
18
|
+
if is_setter_method
|
19
|
+
attributes[key] = args.first
|
20
|
+
else
|
21
|
+
attributes[key]
|
22
|
+
end
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
|
30
|
+
def all
|
31
|
+
response = Sendicate::Request.get("/lists")
|
32
|
+
response.parsed_response.map do |attributes|
|
33
|
+
new(attributes)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def find(id)
|
38
|
+
if id.nil?
|
39
|
+
raise Sendicate::ResourceNotFound
|
40
|
+
else
|
41
|
+
response = Sendicate::Request.get("/lists/#{id}")
|
42
|
+
new(response.parsed_response)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_response_options
|
47
|
+
{
|
48
|
+
query: {
|
49
|
+
token: Sendicate.api_token
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def save
|
56
|
+
response = if persisted?
|
57
|
+
Sendicate::Request.post("/lists", body: to_json)
|
58
|
+
else
|
59
|
+
Sendicate::Request.post("/lists/#{id}", body: to_json)
|
60
|
+
end
|
61
|
+
|
62
|
+
if response.success?
|
63
|
+
@attributes = response.parsed_response
|
64
|
+
true
|
65
|
+
else
|
66
|
+
@errors = response.parsed_response
|
67
|
+
false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def destroy
|
72
|
+
response = Sendicate::Request.delete("/lists/#{id}")
|
73
|
+
end
|
74
|
+
|
75
|
+
def persisted?
|
76
|
+
id
|
77
|
+
end
|
78
|
+
|
79
|
+
def id
|
80
|
+
attributes['id'] || attributes[:id]
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_json
|
84
|
+
MultiJson.dump(attributes)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Sendicate
|
2
|
+
|
3
|
+
class Request
|
4
|
+
include HTTParty
|
5
|
+
base_uri 'https://api.sendicate.net/v1'
|
6
|
+
headers 'Accept' => 'application/json', 'Content-Type' => 'application/json', "Authorization" => "token #{Sendicate.api_token}"
|
7
|
+
|
8
|
+
attr_accessor :response
|
9
|
+
|
10
|
+
def self.get(path, options={}, &block)
|
11
|
+
new(super)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.post(path, options={}, &block)
|
15
|
+
new(super)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.patch(path, options={}, &block)
|
19
|
+
new(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.put(path, options={}, &block)
|
23
|
+
new(super)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.delete(path, options={}, &block)
|
27
|
+
new(super)
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(response)
|
31
|
+
@response = response
|
32
|
+
unless success?
|
33
|
+
case response.code
|
34
|
+
when 400
|
35
|
+
raise Sendicate::BadRequest
|
36
|
+
when 401
|
37
|
+
raise Sendicate::Unauthorized
|
38
|
+
when 404
|
39
|
+
raise Sendicate::ResourceNotFound
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def parsed_response
|
45
|
+
response.parsed_response
|
46
|
+
end
|
47
|
+
|
48
|
+
def success?
|
49
|
+
[200, 201].include?(response.code)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/sendicate.gemspec
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "sendicate"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Evan Whalen"]
|
12
|
+
s.date = "2013-04-02"
|
13
|
+
s.description = "Use this Sendicate API wrapper to subscribe your users to your Sendicate mailing lists."
|
14
|
+
s.email = "evanwhalendev@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/sendicate.rb",
|
28
|
+
"lib/sendicate/import.rb",
|
29
|
+
"lib/sendicate/list.rb",
|
30
|
+
"lib/sendicate/request.rb",
|
31
|
+
"sendicate.gemspec",
|
32
|
+
"spec/sendicate/import_spec.rb",
|
33
|
+
"spec/sendicate/list_spec.rb",
|
34
|
+
"spec/sendicate_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/evanwhalen/sendicate-ruby"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = "1.8.23"
|
41
|
+
s.summary = "Sendicate API Wrapper"
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
48
|
+
s.add_runtime_dependency(%q<multi_json>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
55
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
56
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
59
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
63
|
+
s.add_dependency(%q<multi_json>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
66
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
67
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendicate::Import do
|
4
|
+
|
5
|
+
describe "save" do
|
6
|
+
|
7
|
+
it "should import subscriber" do
|
8
|
+
list = Sendicate::List.new(title: "Test list")
|
9
|
+
list.save
|
10
|
+
import = Sendicate::Import.new(
|
11
|
+
list_id: list.id,
|
12
|
+
data: {
|
13
|
+
email: 'test@mailinator.com',
|
14
|
+
name: 'Test subscriber'
|
15
|
+
}
|
16
|
+
)
|
17
|
+
import.save.should == true
|
18
|
+
import.failed.should == 0
|
19
|
+
import.error_messages.should be_empty
|
20
|
+
list.destroy
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not import invalid subscriber" do
|
24
|
+
list = Sendicate::List.new(title: "Test list")
|
25
|
+
list.save
|
26
|
+
import = Sendicate::Import.new(
|
27
|
+
list_id: list.id,
|
28
|
+
data: {
|
29
|
+
email: 'test@mailinator',
|
30
|
+
name: 'Test subscriber'
|
31
|
+
}
|
32
|
+
)
|
33
|
+
import.save.should == false
|
34
|
+
import.failed.should == 1
|
35
|
+
import.error_messages.should == ["Invalid email address"]
|
36
|
+
list.destroy
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendicate::List do
|
4
|
+
|
5
|
+
describe "new" do
|
6
|
+
|
7
|
+
it "should create list" do
|
8
|
+
list = Sendicate::List.new(title: "Test list")
|
9
|
+
list.save.should be_true
|
10
|
+
list.id.should_not be_nil
|
11
|
+
@list_id = list.id
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should not create list if invalid" do
|
15
|
+
list = Sendicate::List.new
|
16
|
+
list.save.should be_false
|
17
|
+
list.id.should be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have errors if invalid" do
|
21
|
+
list = Sendicate::List.new
|
22
|
+
list.save.should be_false
|
23
|
+
list.errors.should == {"title"=>["can't be blank"]}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "all" do
|
28
|
+
|
29
|
+
it "should return all lists" do
|
30
|
+
lists = Sendicate::List.all
|
31
|
+
lists.size.should_not == 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "find" do
|
36
|
+
let(:list_id) { Sendicate::List.all.first.id }
|
37
|
+
|
38
|
+
it "should find list" do
|
39
|
+
list = Sendicate::List.find(list_id)
|
40
|
+
list.id.should == list_id
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should not find invalid list" do
|
44
|
+
lambda { Sendicate::List.find(@list_id) }.should raise_error(Sendicate::ResourceNotFound)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "save" do
|
49
|
+
let(:list_id) { Sendicate::List.all.select{|l| l.title == 'Test list'}.first.id }
|
50
|
+
|
51
|
+
it "should update list" do
|
52
|
+
list = Sendicate::List.find(list_id)
|
53
|
+
list.title = "Test list updated"
|
54
|
+
list.save.should be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should not update list if invalid" do
|
58
|
+
list = Sendicate::List.find(list_id)
|
59
|
+
list.title = ""
|
60
|
+
list.save.should be_false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "destroy" do
|
65
|
+
|
66
|
+
it "should destroy list" do
|
67
|
+
list = Sendicate::List.all.each do |list|
|
68
|
+
if list.title == 'Test list' || list.title == 'Test list updated'
|
69
|
+
list.destroy.should be_true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendicate do
|
4
|
+
|
5
|
+
describe "api_token" do
|
6
|
+
|
7
|
+
it "should set token to env var" do
|
8
|
+
Sendicate.api_token.should == ENV['SENDICATE_API_TOKEN']
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should set token" do
|
12
|
+
Sendicate.api_token = 'test'
|
13
|
+
Sendicate.api_token.should == 'test'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
|
11
|
+
ENV['RACK_ENV'] ||= 'test'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'sendicate'
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sendicate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Evan Whalen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
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: multi_json
|
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
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Use this Sendicate API wrapper to subscribe your users to your Sendicate
|
111
|
+
mailing lists.
|
112
|
+
email: evanwhalendev@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- LICENSE.txt
|
117
|
+
- README.md
|
118
|
+
files:
|
119
|
+
- .document
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- VERSION
|
126
|
+
- lib/sendicate.rb
|
127
|
+
- lib/sendicate/import.rb
|
128
|
+
- lib/sendicate/list.rb
|
129
|
+
- lib/sendicate/request.rb
|
130
|
+
- sendicate.gemspec
|
131
|
+
- spec/sendicate/import_spec.rb
|
132
|
+
- spec/sendicate/list_spec.rb
|
133
|
+
- spec/sendicate_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
homepage: http://github.com/evanwhalen/sendicate-ruby
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
hash: -2513087585823548954
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 1.8.23
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: Sendicate API Wrapper
|
163
|
+
test_files: []
|