tokyo_api 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +99 -0
- data/LICENSE.txt +20 -0
- data/README.md +18 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/example.rb +9 -0
- data/lib/tokyo_api/actionkit.rb +15 -0
- data/lib/tokyo_api/base.rb +7 -0
- data/lib/tokyo_api/bluestatedigital.rb +15 -0
- data/lib/tokyo_api/client.rb +65 -0
- data/lib/tokyo_api/expire.rb +11 -0
- data/lib/tokyo_api/krautbuster.rb +15 -0
- data/lib/tokyo_api.rb +17 -0
- data/spec/actionkit_spec.rb +44 -0
- data/spec/bluestatedigital_spec.rb +44 -0
- data/spec/client_spec.rb +16 -0
- data/spec/expire_spec.rb +23 -0
- data/spec/fixtures/expire/success +1 -0
- data/spec/fixtures/responses/full_user_error +1 -0
- data/spec/fixtures/responses/full_user_success +0 -0
- data/spec/krautbuster_spec.rb +44 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/tokyo_api_spec.rb +11 -0
- data/tokyo_api.gemspec +85 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2d49dfc5ca312454d549f0bad31a5bdef464e28
|
4
|
+
data.tar.gz: d1f33f973c70861d2e02c38af1e58a5a3ef7df38
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a3ae2dc38875e54b67e903aa84bdfe678de8eba833c4d710d6d796f89480d07e000a15d54741cfe42b6938d57b1e8361e93ef65770bf9d6a0b8c3879c7087c5
|
7
|
+
data.tar.gz: ea89f0bc1c1dc847e5147f35942192169367ee55f431af544db8c7e1bafbf73262029095040308c290f5f7bb7cbe445adfbabc563ed01e933d53bddffd7d4ce0
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tokyo_api
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.4
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'vertebrae'
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
group :development do
|
8
|
+
gem "rspec"
|
9
|
+
gem 'webmock'
|
10
|
+
gem 'byebug'
|
11
|
+
gem "bundler"
|
12
|
+
gem "juwelier", "~> 2.1.0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (5.0.0)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (~> 0.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
tzinfo (~> 1.1)
|
9
|
+
addressable (2.3.5)
|
10
|
+
builder (3.2.2)
|
11
|
+
byebug (9.0.5)
|
12
|
+
concurrent-ruby (1.0.2)
|
13
|
+
crack (0.4.1)
|
14
|
+
safe_yaml (~> 0.9.0)
|
15
|
+
descendants_tracker (0.0.4)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
17
|
+
diff-lcs (1.2.4)
|
18
|
+
faraday (0.9.2)
|
19
|
+
multipart-post (>= 1.2, < 3)
|
20
|
+
faraday_middleware (0.10.0)
|
21
|
+
faraday (>= 0.7.4, < 0.10)
|
22
|
+
git (1.3.0)
|
23
|
+
github_api (0.13.0)
|
24
|
+
addressable (~> 2.3)
|
25
|
+
descendants_tracker (~> 0.0.4)
|
26
|
+
faraday (~> 0.8, < 0.10)
|
27
|
+
hashie (>= 3.4)
|
28
|
+
multi_json (>= 1.7.5, < 2.0)
|
29
|
+
nokogiri (~> 1.6.6)
|
30
|
+
oauth2
|
31
|
+
hashie (3.4.4)
|
32
|
+
highline (1.7.8)
|
33
|
+
i18n (0.7.0)
|
34
|
+
json (1.8.3)
|
35
|
+
juwelier (2.1.2)
|
36
|
+
builder
|
37
|
+
bundler (>= 1.0)
|
38
|
+
git (>= 1.2.5)
|
39
|
+
github_api
|
40
|
+
highline (>= 1.6.15)
|
41
|
+
nokogiri (>= 1.5.10)
|
42
|
+
rake
|
43
|
+
rdoc
|
44
|
+
semver
|
45
|
+
jwt (1.5.4)
|
46
|
+
mini_portile2 (2.1.0)
|
47
|
+
minitest (5.9.0)
|
48
|
+
multi_json (1.12.1)
|
49
|
+
multi_xml (0.5.5)
|
50
|
+
multipart-post (2.0.0)
|
51
|
+
nokogiri (1.6.8)
|
52
|
+
mini_portile2 (~> 2.1.0)
|
53
|
+
pkg-config (~> 1.1.7)
|
54
|
+
oauth2 (1.2.0)
|
55
|
+
faraday (>= 0.8, < 0.10)
|
56
|
+
jwt (~> 1.0)
|
57
|
+
multi_json (~> 1.3)
|
58
|
+
multi_xml (~> 0.5)
|
59
|
+
rack (>= 1.2, < 3)
|
60
|
+
pkg-config (1.1.7)
|
61
|
+
rack (2.0.1)
|
62
|
+
rake (11.2.2)
|
63
|
+
rdoc (4.2.2)
|
64
|
+
json (~> 1.4)
|
65
|
+
rspec (2.14.1)
|
66
|
+
rspec-core (~> 2.14.0)
|
67
|
+
rspec-expectations (~> 2.14.0)
|
68
|
+
rspec-mocks (~> 2.14.0)
|
69
|
+
rspec-core (2.14.6)
|
70
|
+
rspec-expectations (2.14.3)
|
71
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
72
|
+
rspec-mocks (2.14.4)
|
73
|
+
safe_yaml (0.9.7)
|
74
|
+
semver (1.0.1)
|
75
|
+
thread_safe (0.3.5)
|
76
|
+
tzinfo (1.2.2)
|
77
|
+
thread_safe (~> 0.1)
|
78
|
+
vertebrae (0.3.1)
|
79
|
+
activesupport
|
80
|
+
faraday (>= 0.9.2)
|
81
|
+
faraday_middleware
|
82
|
+
hashie
|
83
|
+
webmock (1.15.0)
|
84
|
+
addressable (>= 2.2.7)
|
85
|
+
crack (>= 0.3.2)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
ruby
|
89
|
+
|
90
|
+
DEPENDENCIES
|
91
|
+
bundler
|
92
|
+
byebug
|
93
|
+
juwelier (~> 2.1.0)
|
94
|
+
rspec
|
95
|
+
vertebrae
|
96
|
+
webmock
|
97
|
+
|
98
|
+
BUNDLED WITH
|
99
|
+
1.12.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 ControlShift Ltd.
|
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,18 @@
|
|
1
|
+
# tokyo_api
|
2
|
+
|
3
|
+
A ruby gem for communicating with ControlShift's Tokyo API.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/controlshift/tokyo_api.svg)](https://travis-ci.org/controlshift/tokyo_api)
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
ta = TokyoApi.new(host: 'localhost:9000', username: 'tokyo', password: 'Passw0rd!', scheme: 'http')
|
11
|
+
ta.organisation.expire('foo.com')
|
12
|
+
```
|
13
|
+
|
14
|
+
## Copyright
|
15
|
+
|
16
|
+
Copyright (c) 2013 Nathan Woodhull. See LICENSE.txt for
|
17
|
+
further details.
|
18
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
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 'juwelier'
|
15
|
+
Juwelier::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "tokyo_api"
|
18
|
+
gem.homepage = "http://github.com/controlshift/tokyo_api"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Ruby API Wrapper for Tokyo CRM service"
|
21
|
+
gem.description = "Tokyo is a CRM middleware, this gem helps apps talk to it."
|
22
|
+
gem.email = "nathan@controlshiftlabs.com"
|
23
|
+
gem.authors = ["Nathan Woodhull"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "tokyo_api #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/example.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module TokyoApi
|
2
|
+
class Actionkit < Base
|
3
|
+
def base_path
|
4
|
+
'actionkit'
|
5
|
+
end
|
6
|
+
|
7
|
+
def full_user(id)
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{id}").body
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_path(id)
|
12
|
+
"/#{normalized_base_path}user/#{id}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TokyoApi
|
2
|
+
class Bluestatedigital < Base
|
3
|
+
def base_path
|
4
|
+
'bluestatedigital'
|
5
|
+
end
|
6
|
+
|
7
|
+
def full_user(id)
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{id}").body
|
9
|
+
end
|
10
|
+
|
11
|
+
def tokyo_blue_state_digital_user_path(id)
|
12
|
+
"/#{normalized_base_path}constituent/#{id}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module TokyoApi
|
2
|
+
class Client < Vertebrae::API
|
3
|
+
def actionkit
|
4
|
+
@actionkit ||= TokyoApi::Actionkit.new(client: self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def bluestatedigital
|
8
|
+
@bluestatedigital ||= TokyoApi::Bluestatedigital.new(client: self)
|
9
|
+
end
|
10
|
+
|
11
|
+
def krautbuster
|
12
|
+
@krautbuster ||= TokyoApi::Krautbuster.new(client: self)
|
13
|
+
end
|
14
|
+
|
15
|
+
def expire
|
16
|
+
@expire ||= TokyoApi::Expire.new(client: self)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def default_options
|
21
|
+
{
|
22
|
+
user_agent: 'TokyoApi Gem',
|
23
|
+
prefix: '',
|
24
|
+
content_type: 'application/json'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def request(method, path, params, options) # :nodoc:
|
29
|
+
if !::Vertebrae::Request::METHODS.include?(method)
|
30
|
+
raise ArgumentError, "unknown http method: #{method}"
|
31
|
+
end
|
32
|
+
|
33
|
+
path = connection.configuration.prefix + '/' + path
|
34
|
+
|
35
|
+
::Vertebrae::Base.logger.debug "EXECUTED: #{method} - #{path} with #{params} and #{options}"
|
36
|
+
|
37
|
+
connection.connection.send(method) do |request|
|
38
|
+
|
39
|
+
case method.to_sym
|
40
|
+
when *(::Vertebrae::Request::METHODS - ::Vertebrae::Request::METHODS_WITH_BODIES)
|
41
|
+
request.url(path, params)
|
42
|
+
when *::Vertebrae::Request::METHODS_WITH_BODIES
|
43
|
+
request.path = path
|
44
|
+
request.body = extract_data_from_params(params) unless params.empty?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def setup
|
50
|
+
connection.stack do |builder|
|
51
|
+
builder.use Faraday::Request::Multipart
|
52
|
+
builder.use Faraday::Request::UrlEncoded
|
53
|
+
builder.use Vertebrae::Request::BasicAuth, connection.configuration.authentication if connection.configuration.authenticated?
|
54
|
+
|
55
|
+
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
56
|
+
|
57
|
+
builder.use FaradayMiddleware::Mashify
|
58
|
+
builder.use FaradayMiddleware::ParseJson
|
59
|
+
|
60
|
+
builder.use Vertebrae::Response::RaiseError
|
61
|
+
builder.adapter connection.configuration.adapter
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TokyoApi
|
2
|
+
class Krautbuster < Base
|
3
|
+
def base_path
|
4
|
+
'krautbuster'
|
5
|
+
end
|
6
|
+
|
7
|
+
def full_user(session_id)
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{session_id}").body
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_path(session_id)
|
12
|
+
"/#{normalized_base_path}user/#{session_id}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/tokyo_api.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'vertebrae'
|
2
|
+
require 'tokyo_api/base'
|
3
|
+
require 'tokyo_api/actionkit'
|
4
|
+
require 'tokyo_api/bluestatedigital'
|
5
|
+
require 'tokyo_api/krautbuster'
|
6
|
+
require 'tokyo_api/expire'
|
7
|
+
require 'tokyo_api/client'
|
8
|
+
|
9
|
+
module TokyoApi
|
10
|
+
extend Vertebrae::Base
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def new(options = {}, &block)
|
14
|
+
TokyoApi::Client.new(options, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi::Actionkit do
|
4
|
+
subject { TokyoApi.new(host: 'test.com') }
|
5
|
+
|
6
|
+
describe 'configuration' do
|
7
|
+
it 'should propagate the host' do
|
8
|
+
subject.actionkit.client.connection.configuration.host.should == 'test.com'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'full_user' do
|
13
|
+
let(:body) { fixture('responses/full_user_success') }
|
14
|
+
let(:request_path) { '/actionkit/full_user/1' }
|
15
|
+
let(:status) { 200 }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
19
|
+
:headers => { content_type: "application/json; charset=utf-8"})
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'error' do
|
23
|
+
let(:body) { fixture('responses/full_user_error') }
|
24
|
+
|
25
|
+
it 'should find an organisation' do
|
26
|
+
subject.actionkit.full_user('1').should == {'error' => 'Connection refused'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'error' do
|
31
|
+
let(:body) { fixture('responses/full_user_success') } #TODO: actually figure out what this returns.
|
32
|
+
|
33
|
+
it 'should find an organisation' do
|
34
|
+
subject.actionkit.full_user('1').should == nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'user_path' do
|
39
|
+
it "should return relative path to user API endpoint" do
|
40
|
+
subject.actionkit.user_path('abc.123.xyz').should == '/actionkit/user/abc.123.xyz'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi::Bluestatedigital do
|
4
|
+
subject { TokyoApi.new(host: 'test.com') }
|
5
|
+
|
6
|
+
describe 'configuration' do
|
7
|
+
it 'should propagate the host' do
|
8
|
+
subject.bluestatedigital.client.connection.configuration.host.should == 'test.com'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'full_user' do
|
13
|
+
let(:body) { fixture('responses/full_user_success') }
|
14
|
+
let(:request_path) { '/bluestatedigital/full_user/1' }
|
15
|
+
let(:status) { 200 }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
19
|
+
:headers => { content_type: "application/json; charset=utf-8"})
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'error' do
|
23
|
+
let(:body) { fixture('responses/full_user_error') }
|
24
|
+
|
25
|
+
it 'should find an organisation' do
|
26
|
+
subject.bluestatedigital.full_user('1').should == {'error' => 'Connection refused'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'error' do
|
31
|
+
let(:body) { fixture('responses/full_user_success') } #TODO: actually figure out what this returns.
|
32
|
+
|
33
|
+
it 'should find an organisation' do
|
34
|
+
subject.bluestatedigital.full_user('1').should == nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'tokyo_blue_state_digital_user_path' do
|
40
|
+
it "should return rooted relative path to tokyo user API endpoint" do
|
41
|
+
subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456').should == '/bluestatedigital/constituent/-123456'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi::Client do
|
4
|
+
|
5
|
+
describe "instantiated" do
|
6
|
+
subject { described_class.new(options) }
|
7
|
+
|
8
|
+
context 'process_basic_auth' do
|
9
|
+
let(:options) { { :basic_auth => 'login:password' } }
|
10
|
+
let(:config) { subject.connection.configuration }
|
11
|
+
specify { config.username.should eq 'login' }
|
12
|
+
specify { config.password.should eq 'password' }
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/spec/expire_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi::Expire do
|
4
|
+
subject { TokyoApi.new(host: 'test.com') }
|
5
|
+
|
6
|
+
describe 'expire organisation' do
|
7
|
+
let(:body) { fixture('expire/success') }
|
8
|
+
let(:request_path) { '/expire/organisation/foo.com' }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
12
|
+
:headers => { content_type: "application/json; charset=utf-8"})
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'success' do
|
16
|
+
let(:status) { 200 }
|
17
|
+
|
18
|
+
it 'should find an organisation' do
|
19
|
+
subject.expire.organisation('foo.com').should == {'status' => 'success'}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status":"success"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"error":"Connection refused"}
|
File without changes
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi::Krautbuster do
|
4
|
+
subject { TokyoApi.new(host: 'test.com') }
|
5
|
+
|
6
|
+
describe 'configuration' do
|
7
|
+
it 'should propagate the host' do
|
8
|
+
expect(subject.krautbuster.client.connection.configuration.host).to eq 'test.com'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'full_user' do
|
13
|
+
let(:body) { fixture('responses/full_user_success') }
|
14
|
+
let(:request_path) { '/krautbuster/full_user/123abc456' }
|
15
|
+
let(:status) { 200 }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
19
|
+
:headers => { content_type: "application/json; charset=utf-8"})
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'error' do
|
23
|
+
let(:body) { fixture('responses/full_user_error') }
|
24
|
+
|
25
|
+
it 'should find an organisation' do
|
26
|
+
expect(subject.krautbuster.full_user('123abc456')).to eq({'error' => 'Connection refused'})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'error' do
|
31
|
+
let(:body) { fixture('responses/full_user_success') }
|
32
|
+
|
33
|
+
it 'should find an organisation' do
|
34
|
+
expect(subject.krautbuster.full_user('123abc456')).to be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'user_path' do
|
40
|
+
it "should return relative path to user API endpoint" do
|
41
|
+
expect(subject.krautbuster.user_path('123abc456')).to eq '/krautbuster/user/123abc456'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'webmock'
|
5
|
+
require 'tokyo_api'
|
6
|
+
|
7
|
+
|
8
|
+
# Requires supporting files with custom matchers and macros, etc,
|
9
|
+
# in ./support/ and its subdirectories.
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
|
+
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.include WebMock::API
|
15
|
+
config.color_enabled = true
|
16
|
+
|
17
|
+
|
18
|
+
config.before(:each) do
|
19
|
+
WebMock.reset!
|
20
|
+
end
|
21
|
+
config.after(:each) do
|
22
|
+
WebMock.reset!
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def stub_get(path)
|
28
|
+
stub_tokyo_request(:get, path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def stub_post(path)
|
32
|
+
stub_tokyo_request(:post, path)
|
33
|
+
end
|
34
|
+
|
35
|
+
def stub_tokyo_request(method, path)
|
36
|
+
prefix = TokyoApi.new.connection.configuration.prefix.to_s
|
37
|
+
scheme = TokyoApi.new.connection.configuration.scheme.to_s
|
38
|
+
stub_request(method, "#{scheme}://test.com" + prefix + path)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
def fixture_path
|
44
|
+
File.expand_path("../fixtures", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def fixture(file)
|
48
|
+
File.new(File.join(fixture_path, '/', file))
|
49
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TokyoApi do
|
4
|
+
before(:each) do
|
5
|
+
TokyoApi::Client.stub(:setup_client)
|
6
|
+
end
|
7
|
+
specify { subject.should respond_to :actionkit }
|
8
|
+
specify { subject.new.should be_a(TokyoApi::Client)}
|
9
|
+
end
|
10
|
+
|
11
|
+
|
data/tokyo_api.gemspec
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: tokyo_api 0.2.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "tokyo_api"
|
9
|
+
s.version = "0.2.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Nathan Woodhull"]
|
14
|
+
s.date = "2016-08-03"
|
15
|
+
s.description = "Tokyo is a CRM middleware, this gem helps apps talk to it."
|
16
|
+
s.email = "nathan@controlshiftlabs.com"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
".ruby-gemset",
|
25
|
+
".ruby-version",
|
26
|
+
".travis.yml",
|
27
|
+
"Gemfile",
|
28
|
+
"Gemfile.lock",
|
29
|
+
"LICENSE.txt",
|
30
|
+
"README.md",
|
31
|
+
"Rakefile",
|
32
|
+
"VERSION",
|
33
|
+
"example.rb",
|
34
|
+
"lib/tokyo_api.rb",
|
35
|
+
"lib/tokyo_api/actionkit.rb",
|
36
|
+
"lib/tokyo_api/base.rb",
|
37
|
+
"lib/tokyo_api/bluestatedigital.rb",
|
38
|
+
"lib/tokyo_api/client.rb",
|
39
|
+
"lib/tokyo_api/expire.rb",
|
40
|
+
"lib/tokyo_api/krautbuster.rb",
|
41
|
+
"spec/actionkit_spec.rb",
|
42
|
+
"spec/bluestatedigital_spec.rb",
|
43
|
+
"spec/client_spec.rb",
|
44
|
+
"spec/expire_spec.rb",
|
45
|
+
"spec/fixtures/expire/success",
|
46
|
+
"spec/fixtures/responses/full_user_error",
|
47
|
+
"spec/fixtures/responses/full_user_success",
|
48
|
+
"spec/krautbuster_spec.rb",
|
49
|
+
"spec/spec_helper.rb",
|
50
|
+
"spec/tokyo_api_spec.rb",
|
51
|
+
"tokyo_api.gemspec"
|
52
|
+
]
|
53
|
+
s.homepage = "http://github.com/controlshift/tokyo_api"
|
54
|
+
s.licenses = ["MIT"]
|
55
|
+
s.rubygems_version = "2.4.8"
|
56
|
+
s.summary = "Ruby API Wrapper for Tokyo CRM service"
|
57
|
+
|
58
|
+
if s.respond_to? :specification_version then
|
59
|
+
s.specification_version = 4
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_runtime_dependency(%q<vertebrae>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<byebug>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<juwelier>, ["~> 2.1.0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<vertebrae>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
71
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
72
|
+
s.add_dependency(%q<byebug>, [">= 0"])
|
73
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
74
|
+
s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<vertebrae>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
79
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
80
|
+
s.add_dependency(%q<byebug>, [">= 0"])
|
81
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
82
|
+
s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tokyo_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Woodhull
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vertebrae
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
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
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: juwelier
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.1.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.1.0
|
97
|
+
description: Tokyo is a CRM middleware, this gem helps apps talk to it.
|
98
|
+
email: nathan@controlshiftlabs.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files:
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.md
|
104
|
+
files:
|
105
|
+
- ".document"
|
106
|
+
- ".rspec"
|
107
|
+
- ".ruby-gemset"
|
108
|
+
- ".ruby-version"
|
109
|
+
- ".travis.yml"
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- VERSION
|
116
|
+
- example.rb
|
117
|
+
- lib/tokyo_api.rb
|
118
|
+
- lib/tokyo_api/actionkit.rb
|
119
|
+
- lib/tokyo_api/base.rb
|
120
|
+
- lib/tokyo_api/bluestatedigital.rb
|
121
|
+
- lib/tokyo_api/client.rb
|
122
|
+
- lib/tokyo_api/expire.rb
|
123
|
+
- lib/tokyo_api/krautbuster.rb
|
124
|
+
- spec/actionkit_spec.rb
|
125
|
+
- spec/bluestatedigital_spec.rb
|
126
|
+
- spec/client_spec.rb
|
127
|
+
- spec/expire_spec.rb
|
128
|
+
- spec/fixtures/expire/success
|
129
|
+
- spec/fixtures/responses/full_user_error
|
130
|
+
- spec/fixtures/responses/full_user_success
|
131
|
+
- spec/krautbuster_spec.rb
|
132
|
+
- spec/spec_helper.rb
|
133
|
+
- spec/tokyo_api_spec.rb
|
134
|
+
- tokyo_api.gemspec
|
135
|
+
homepage: http://github.com/controlshift/tokyo_api
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.4.8
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: Ruby API Wrapper for Tokyo CRM service
|
159
|
+
test_files: []
|