tokyo_api 0.2.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2d49dfc5ca312454d549f0bad31a5bdef464e28
4
- data.tar.gz: d1f33f973c70861d2e02c38af1e58a5a3ef7df38
3
+ metadata.gz: 12d2d3a99c115528e680c6cad6fac2c2dd016ddf
4
+ data.tar.gz: be23032d01f274d9639af99f419ed35b04e9a74f
5
5
  SHA512:
6
- metadata.gz: 6a3ae2dc38875e54b67e903aa84bdfe678de8eba833c4d710d6d796f89480d07e000a15d54741cfe42b6938d57b1e8361e93ef65770bf9d6a0b8c3879c7087c5
7
- data.tar.gz: ea89f0bc1c1dc847e5147f35942192169367ee55f431af544db8c7e1bafbf73262029095040308c290f5f7bb7cbe445adfbabc563ed01e933d53bddffd7d4ce0
6
+ metadata.gz: 639b6d88d3e5fc1db184da6cd35c1095c48626e207b1f769ce01a8ae44cf54e3cbb245db747b1b5833119a8b427ef96b05769e686bd1bb5d33852990f6e46809
7
+ data.tar.gz: 60bb05952d75302a17e54293e603e316d121d40b8ad124d55254bda7ba75327a0a7c5f8fb5f3ea0d7da4cce76f17177f258d79084bae3424627b8d8fc8499d74
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.4
1
+ 2.3.4
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "2.2.4"
3
+ - "2.3.3"
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ group :development do
9
9
  gem 'webmock'
10
10
  gem 'byebug'
11
11
  gem "bundler"
12
- gem "juwelier", "~> 2.1.0"
12
+ gem "juwelier"
13
13
  end
data/Gemfile.lock CHANGED
@@ -1,88 +1,96 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (5.0.0)
4
+ activesupport (5.1.3)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (~> 0.7)
7
7
  minitest (~> 5.1)
8
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)
9
+ addressable (2.4.0)
10
+ builder (3.2.3)
11
+ byebug (9.0.6)
12
+ concurrent-ruby (1.0.5)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
15
  descendants_tracker (0.0.4)
16
16
  thread_safe (~> 0.3, >= 0.3.1)
17
- diff-lcs (1.2.4)
17
+ diff-lcs (1.3)
18
18
  faraday (0.9.2)
19
19
  multipart-post (>= 1.2, < 3)
20
- faraday_middleware (0.10.0)
21
- faraday (>= 0.7.4, < 0.10)
20
+ faraday_middleware (0.12.2)
21
+ faraday (>= 0.7.4, < 1.0)
22
22
  git (1.3.0)
23
- github_api (0.13.0)
24
- addressable (~> 2.3)
23
+ github_api (0.17.0)
24
+ addressable (~> 2.4.0)
25
25
  descendants_tracker (~> 0.0.4)
26
26
  faraday (~> 0.8, < 0.10)
27
27
  hashie (>= 3.4)
28
- multi_json (>= 1.7.5, < 2.0)
29
- nokogiri (~> 1.6.6)
30
- oauth2
31
- hashie (3.4.4)
28
+ mime-types (>= 1.16, < 3.0)
29
+ oauth2 (~> 1.0)
30
+ hashdiff (0.3.5)
31
+ hashie (3.5.6)
32
32
  highline (1.7.8)
33
- i18n (0.7.0)
34
- json (1.8.3)
35
- juwelier (2.1.2)
33
+ i18n (0.8.6)
34
+ juwelier (2.4.7)
36
35
  builder
37
- bundler (>= 1.0)
38
- git (>= 1.2.5)
36
+ bundler
37
+ git
39
38
  github_api
40
- highline (>= 1.6.15)
41
- nokogiri (>= 1.5.10)
39
+ highline
40
+ kamelcase (~> 0)
41
+ nokogiri
42
+ psych
42
43
  rake
43
44
  rdoc
44
- semver
45
- jwt (1.5.4)
46
- mini_portile2 (2.1.0)
47
- minitest (5.9.0)
45
+ semver2
46
+ jwt (1.5.6)
47
+ kamelcase (0.0.1)
48
+ semver2 (~> 3)
49
+ mime-types (2.99.3)
50
+ mini_portile2 (2.2.0)
51
+ minitest (5.10.3)
48
52
  multi_json (1.12.1)
49
- multi_xml (0.5.5)
53
+ multi_xml (0.6.0)
50
54
  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)
55
+ nokogiri (1.8.0)
56
+ mini_portile2 (~> 2.2.0)
57
+ oauth2 (1.4.0)
58
+ faraday (>= 0.8, < 0.13)
56
59
  jwt (~> 1.0)
57
60
  multi_json (~> 1.3)
58
61
  multi_xml (~> 0.5)
59
62
  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)
63
+ psych (2.2.4)
64
+ rack (2.0.3)
65
+ rake (12.0.0)
66
+ rdoc (5.1.0)
67
+ rspec (3.6.0)
68
+ rspec-core (~> 3.6.0)
69
+ rspec-expectations (~> 3.6.0)
70
+ rspec-mocks (~> 3.6.0)
71
+ rspec-core (3.6.0)
72
+ rspec-support (~> 3.6.0)
73
+ rspec-expectations (3.6.0)
74
+ diff-lcs (>= 1.2.0, < 2.0)
75
+ rspec-support (~> 3.6.0)
76
+ rspec-mocks (3.6.0)
77
+ diff-lcs (>= 1.2.0, < 2.0)
78
+ rspec-support (~> 3.6.0)
79
+ rspec-support (3.6.0)
80
+ safe_yaml (1.0.4)
81
+ semver2 (3.4.2)
82
+ thread_safe (0.3.6)
83
+ tzinfo (1.2.3)
77
84
  thread_safe (~> 0.1)
78
- vertebrae (0.3.1)
85
+ vertebrae (0.4.1)
79
86
  activesupport
80
87
  faraday (>= 0.9.2)
81
88
  faraday_middleware
82
89
  hashie
83
- webmock (1.15.0)
84
- addressable (>= 2.2.7)
90
+ webmock (3.0.1)
91
+ addressable (>= 2.3.6)
85
92
  crack (>= 0.3.2)
93
+ hashdiff
86
94
 
87
95
  PLATFORMS
88
96
  ruby
@@ -90,10 +98,10 @@ PLATFORMS
90
98
  DEPENDENCIES
91
99
  bundler
92
100
  byebug
93
- juwelier (~> 2.1.0)
101
+ juwelier
94
102
  rspec
95
103
  vertebrae
96
104
  webmock
97
105
 
98
106
  BUNDLED WITH
99
- 1.12.5
107
+ 1.15.4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.6.1
@@ -8,8 +8,8 @@ module TokyoApi
8
8
  client.get_request("#{normalized_base_path}full_user/#{id}").body
9
9
  end
10
10
 
11
- def user_path(id)
12
- "/#{normalized_base_path}user/#{id}"
11
+ def user_path(id, phone_required)
12
+ "/#{normalized_base_path}user/#{id}?phone_required=#{phone_required}"
13
13
  end
14
14
  end
15
15
  end
@@ -8,8 +8,8 @@ module TokyoApi
8
8
  client.get_request("#{normalized_base_path}full_user/#{id}").body
9
9
  end
10
10
 
11
- def tokyo_blue_state_digital_user_path(id)
12
- "/#{normalized_base_path}constituent/#{id}"
11
+ def tokyo_blue_state_digital_user_path(id, phone_required)
12
+ "/#{normalized_base_path}constituent/#{id}?phone_required=#{phone_required}"
13
13
  end
14
14
  end
15
15
  end
@@ -12,6 +12,10 @@ module TokyoApi
12
12
  @krautbuster ||= TokyoApi::Krautbuster.new(client: self)
13
13
  end
14
14
 
15
+ def identity
16
+ @identity ||= TokyoApi::Identity.new(client: self)
17
+ end
18
+
15
19
  def expire
16
20
  @expire ||= TokyoApi::Expire.new(client: self)
17
21
  end
@@ -30,7 +34,9 @@ module TokyoApi
30
34
  raise ArgumentError, "unknown http method: #{method}"
31
35
  end
32
36
 
33
- path = connection.configuration.prefix + '/' + path
37
+ unless connection.configuration.prefix.blank?
38
+ path = connection.configuration.prefix + '/' + path
39
+ end
34
40
 
35
41
  ::Vertebrae::Base.logger.debug "EXECUTED: #{method} - #{path} with #{params} and #{options}"
36
42
 
@@ -62,4 +68,4 @@ module TokyoApi
62
68
  end
63
69
  end
64
70
  end
65
- end
71
+ end
@@ -0,0 +1,15 @@
1
+ module TokyoApi
2
+ class Identity < Base
3
+ def base_path
4
+ 'identity'
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_identity_user_path(id, phone_required)
12
+ "/#{normalized_base_path}user/#{id}?phone_required=#{phone_required}"
13
+ end
14
+ end
15
+ end
@@ -8,8 +8,29 @@ module TokyoApi
8
8
  client.get_request("#{normalized_base_path}full_user/#{session_id}").body
9
9
  end
10
10
 
11
- def user_path(session_id)
12
- "/#{normalized_base_path}user/#{session_id}"
11
+ def session_status(session_id)
12
+ client.get_request("#{normalized_base_path}session_status/#{session_id}").body
13
+ end
14
+
15
+ def subscription_status(token)
16
+ begin
17
+ client.get_request(subscription_status_path(token)).body
18
+ rescue Vertebrae::ResponseError => e
19
+ # Status 404 is expected in these calls
20
+ if e.status_code == 404
21
+ return nil
22
+ end
23
+
24
+ raise
25
+ end
26
+ end
27
+
28
+ def user_path(session_id, petition_id)
29
+ "/#{normalized_base_path}user/#{session_id}?petition_id=#{petition_id}"
30
+ end
31
+
32
+ def subscription_status_path(token)
33
+ "/#{normalized_base_path}subscription_status/#{token}"
13
34
  end
14
35
  end
15
36
  end
data/lib/tokyo_api.rb CHANGED
@@ -3,6 +3,7 @@ require 'tokyo_api/base'
3
3
  require 'tokyo_api/actionkit'
4
4
  require 'tokyo_api/bluestatedigital'
5
5
  require 'tokyo_api/krautbuster'
6
+ require 'tokyo_api/identity'
6
7
  require 'tokyo_api/expire'
7
8
  require 'tokyo_api/client'
8
9
 
@@ -14,4 +15,4 @@ module TokyoApi
14
15
  TokyoApi::Client.new(options, &block)
15
16
  end
16
17
  end
17
- end
18
+ end
@@ -5,7 +5,7 @@ describe TokyoApi::Actionkit do
5
5
 
6
6
  describe 'configuration' do
7
7
  it 'should propagate the host' do
8
- subject.actionkit.client.connection.configuration.host.should == 'test.com'
8
+ expect(subject.actionkit.client.connection.configuration.host).to eq('test.com')
9
9
  end
10
10
  end
11
11
 
@@ -22,22 +22,32 @@ describe TokyoApi::Actionkit do
22
22
  describe 'error' do
23
23
  let(:body) { fixture('responses/full_user_error') }
24
24
 
25
- it 'should find an organisation' do
26
- subject.actionkit.full_user('1').should == {'error' => 'Connection refused'}
25
+ it 'should return an error hash' do
26
+ expect(subject.actionkit.full_user('1')).to eq({'error' => 'Connection refused'})
27
27
  end
28
28
  end
29
29
 
30
- describe 'error' do
31
- let(:body) { fixture('responses/full_user_success') } #TODO: actually figure out what this returns.
30
+ describe 'success' do
31
+ let(:body) { fixture('responses/actionkit/full_user_success') }
32
32
 
33
- it 'should find an organisation' do
34
- subject.actionkit.full_user('1').should == nil
33
+ it 'should return a user message' do
34
+ expect(subject.actionkit.full_user('1')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
35
+ 'city' => 'Springfield', 'state' => 'YZ', 'country' => 'US',
36
+ 'extra_field' => 'hidden extra field', 'email' => 'foo@bar.com' })
35
37
  end
36
38
  end
37
39
 
38
40
  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
+ context 'phone not required' do
42
+ it "should return relative path to user API endpoint" do
43
+ expect(subject.actionkit.user_path('abc.123.xyz', false)).to eq('/actionkit/user/abc.123.xyz?phone_required=false')
44
+ end
45
+ end
46
+
47
+ context 'phone required' do
48
+ it "should return relative path to user API endpoint" do
49
+ expect(subject.actionkit.user_path('abc.123.xyz', true)).to eq('/actionkit/user/abc.123.xyz?phone_required=true')
50
+ end
41
51
  end
42
52
  end
43
53
  end
@@ -5,7 +5,7 @@ describe TokyoApi::Bluestatedigital do
5
5
 
6
6
  describe 'configuration' do
7
7
  it 'should propagate the host' do
8
- subject.bluestatedigital.client.connection.configuration.host.should == 'test.com'
8
+ expect(subject.bluestatedigital.client.connection.configuration.host).to eq('test.com')
9
9
  end
10
10
  end
11
11
 
@@ -22,23 +22,33 @@ describe TokyoApi::Bluestatedigital do
22
22
  describe 'error' do
23
23
  let(:body) { fixture('responses/full_user_error') }
24
24
 
25
- it 'should find an organisation' do
26
- subject.bluestatedigital.full_user('1').should == {'error' => 'Connection refused'}
25
+ it 'should return an error message' do
26
+ expect(subject.bluestatedigital.full_user('1')).to eq({'error' => 'Connection refused'})
27
27
  end
28
28
  end
29
29
 
30
- describe 'error' do
31
- let(:body) { fixture('responses/full_user_success') } #TODO: actually figure out what this returns.
30
+ describe 'success' do
31
+ let(:body) { fixture('responses/bluestatedigital/full_user_success') }
32
32
 
33
- it 'should find an organisation' do
34
- subject.bluestatedigital.full_user('1').should == nil
33
+ it 'should return a success hash' do
34
+ expect(subject.bluestatedigital.full_user('1')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
35
+ 'city' => 'Springfield', 'state' => 'YZ', 'country' => 'US',
36
+ 'postal' => '12345', 'email' => 'foo@bar.com' })
35
37
  end
36
38
  end
37
39
  end
38
40
 
39
41
  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
+ context 'phone not required' do
43
+ it "should return rooted relative path to tokyo user API endpoint" do
44
+ expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456', false)).to eq('/bluestatedigital/constituent/-123456?phone_required=false')
45
+ end
46
+ end
47
+
48
+ context 'phone required' do
49
+ it "should return rooted relative path to tokyo user API endpoint" do
50
+ expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456', true)).to eq('/bluestatedigital/constituent/-123456?phone_required=true')
51
+ end
42
52
  end
43
53
  end
44
54
  end
data/spec/client_spec.rb CHANGED
@@ -8,8 +8,8 @@ describe TokyoApi::Client do
8
8
  context 'process_basic_auth' do
9
9
  let(:options) { { :basic_auth => 'login:password' } }
10
10
  let(:config) { subject.connection.configuration }
11
- specify { config.username.should eq 'login' }
12
- specify { config.password.should eq 'password' }
11
+ specify { expect(config.username).to eq 'login' }
12
+ specify { expect(config.password).to eq 'password' }
13
13
  end
14
14
 
15
15
  end
data/spec/expire_spec.rb CHANGED
@@ -16,7 +16,7 @@ describe TokyoApi::Expire do
16
16
  let(:status) { 200 }
17
17
 
18
18
  it 'should find an organisation' do
19
- subject.expire.organisation('foo.com').should == {'status' => 'success'}
19
+ expect(subject.expire.organisation('foo.com')).to eq({'status' => 'success'})
20
20
  end
21
21
  end
22
22
  end
@@ -0,0 +1 @@
1
+ {"first_name":"Homer","last_name":"Simpson","city":"Springfield","state":"YZ","country":"US","extra_field":"hidden extra field","email":"foo@bar.com"}
@@ -0,0 +1 @@
1
+ {"first_name":"Homer","last_name":"Simpson","city":"Springfield","state":"YZ","country":"US","postal":"12345","email":"foo@bar.com"}
@@ -0,0 +1 @@
1
+ {"first_name":"Homer","last_name":"Simpson","country":"GB","postal":"12345","email":"foo@bar.com"}
@@ -0,0 +1 @@
1
+ {"first_name":"Homer","last_name":"Simpson","country":"DE","postal":"12345","email":"foo@bar.com"}
@@ -0,0 +1,53 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe TokyoApi::Identity do
4
+ subject { TokyoApi.new(host: 'test.com') }
5
+
6
+ describe 'configuration' do
7
+ it 'should propagate the host' do
8
+ expect(subject.identity.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) { '/identity/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 return an error hash' do
26
+ expect(subject.identity.full_user('1')).to eq({'error' => 'Connection refused'})
27
+ end
28
+ end
29
+
30
+ describe 'success' do
31
+ let(:body) { fixture('responses/identity/full_user_success') }
32
+
33
+ it 'should return a hash' do
34
+ expect(subject.identity.full_user('1')).to eq({'first_name' => 'Homer', 'last_name' => 'Simpson',
35
+ 'country' => 'GB', 'postal' => '12345', 'email' => 'foo@bar.com' })
36
+ end
37
+ end
38
+ end
39
+
40
+ describe 'tokyo_identity_user_path' do
41
+ context 'phone not required' do
42
+ it 'should return rooted relative path to tokyo user API endpoint' do
43
+ expect(subject.identity.tokyo_identity_user_path('-123456', false)).to eq('/identity/user/-123456?phone_required=false')
44
+ end
45
+ end
46
+
47
+ context 'phone required' do
48
+ it 'should return rooted relative path to tokyo user API endpoint' do
49
+ expect(subject.identity.tokyo_identity_user_path('-123456', true)).to eq('/identity/user/-123456?phone_required=true')
50
+ end
51
+ end
52
+ end
53
+ end
@@ -9,7 +9,7 @@ describe TokyoApi::Krautbuster do
9
9
  end
10
10
  end
11
11
 
12
- describe 'full_user' do
12
+ describe '#full_user' do
13
13
  let(:body) { fixture('responses/full_user_success') }
14
14
  let(:request_path) { '/krautbuster/full_user/123abc456' }
15
15
  let(:status) { 200 }
@@ -22,23 +22,65 @@ describe TokyoApi::Krautbuster do
22
22
  describe 'error' do
23
23
  let(:body) { fixture('responses/full_user_error') }
24
24
 
25
- it 'should find an organisation' do
25
+ it 'should return an error message' do
26
26
  expect(subject.krautbuster.full_user('123abc456')).to eq({'error' => 'Connection refused'})
27
27
  end
28
28
  end
29
29
 
30
- describe 'error' do
31
- let(:body) { fixture('responses/full_user_success') }
30
+ describe 'success' do
31
+ let(:body) { fixture('responses/krautbuster/full_user_success') }
32
32
 
33
33
  it 'should find an organisation' do
34
- expect(subject.krautbuster.full_user('123abc456')).to be_nil
34
+ expect(subject.krautbuster.full_user('123abc456')).to eq({'first_name' => 'Homer', 'last_name' => 'Simpson',
35
+ 'country' => 'DE', 'postal' => '12345', 'email' => 'foo@bar.com' })
35
36
  end
36
37
  end
37
38
  end
38
39
 
39
- describe 'user_path' do
40
+ describe '#subscription_status' do
41
+ let(:client) { double }
42
+ let(:token) { '2134567890abcdef' }
43
+
44
+ subject { TokyoApi::Krautbuster.new(client: client) }
45
+
46
+ before :each do
47
+ expect(subject).to receive(:subscription_status_path).with(token).and_return("/krautbuster/subscription_status?token=#{token}")
48
+ end
49
+
50
+ it 'should perform request on subscription_status_path' do
51
+ expect(client).to receive(:get_request).with("/krautbuster/subscription_status?token=#{token}").and_return(double(body: {subscribed: true}))
52
+
53
+ subs_status = subject.subscription_status(token)
54
+
55
+ expect(subs_status).to eq({subscribed: true})
56
+ end
57
+
58
+ it 'should return nil if tokyo responds with 404' do
59
+ expect(client).to receive(:get_request).with("/krautbuster/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(404, {method: 'get', url: "/krautbuster/subscription_status?token=#{token}", status: '404', body: 'Not Found'}))
60
+
61
+ subs_status = subject.subscription_status(token)
62
+
63
+ expect(subs_status).to be_nil
64
+ end
65
+
66
+ it 'should raise if tokyo responds with other error code' do
67
+ expect(client).to receive(:get_request).with("/krautbuster/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(500, {method: 'get', url: "/krautbuster/subscription_status?token=#{token}", status: '500', body: 'Something bad happened'}))
68
+
69
+ expect { subject.subscription_status(token) }.to raise_error Vertebrae::ResponseError
70
+ end
71
+ end
72
+
73
+ describe '#user_path' do
40
74
  it "should return relative path to user API endpoint" do
41
- expect(subject.krautbuster.user_path('123abc456')).to eq '/krautbuster/user/123abc456'
75
+ expect(subject.krautbuster.user_path('123abc456', 'save-the-trees')).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees'
76
+ end
77
+ end
78
+
79
+ describe '#subscription_status_path' do
80
+ subject { TokyoApi::Krautbuster.new }
81
+
82
+ it 'should return correct path' do
83
+ expect(subject.subscription_status_path('abc123')).to eq '/krautbuster/subscription_status/abc123'
42
84
  end
43
85
  end
44
86
  end
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,17 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
- require 'webmock'
4
+ require 'webmock/rspec'
5
5
  require 'tokyo_api'
6
6
 
7
-
8
7
  # Requires supporting files with custom matchers and macros, etc,
9
8
  # in ./support/ and its subdirectories.
10
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
10
 
12
-
13
11
  RSpec.configure do |config|
14
12
  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
-
13
+ config.color = true
14
+ #config.raise_errors_for_deprecations!
25
15
  end
26
16
 
27
17
  def stub_get(path)
@@ -38,12 +28,10 @@ def stub_tokyo_request(method, path)
38
28
  stub_request(method, "#{scheme}://test.com" + prefix + path)
39
29
  end
40
30
 
41
-
42
-
43
31
  def fixture_path
44
32
  File.expand_path("../fixtures", __FILE__)
45
33
  end
46
34
 
47
35
  def fixture(file)
48
36
  File.new(File.join(fixture_path, '/', file))
49
- end
37
+ end
@@ -2,10 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe TokyoApi do
4
4
  before(:each) do
5
- TokyoApi::Client.stub(:setup_client)
5
+ allow(TokyoApi::Client).to receive(:setup_client)
6
6
  end
7
- specify { subject.should respond_to :actionkit }
8
- specify { subject.new.should be_a(TokyoApi::Client)}
7
+ specify { expect(subject).to respond_to :actionkit }
8
+ specify { expect(subject.new).to be_a(TokyoApi::Client)}
9
9
  end
10
10
 
11
11
 
data/tokyo_api.gemspec CHANGED
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: tokyo_api 0.2.0 ruby lib
5
+ # stub: tokyo_api 0.6.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "tokyo_api"
9
- s.version = "0.2.0"
8
+ s.name = "tokyo_api".freeze
9
+ s.version = "0.6.1"
10
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"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Nathan Woodhull".freeze]
14
+ s.date = "2017-08-21"
15
+ s.description = "Tokyo is a CRM middleware, this gem helps apps talk to it.".freeze
16
+ s.email = "nathan@controlshiftlabs.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.md"
@@ -37,49 +37,55 @@ Gem::Specification.new do |s|
37
37
  "lib/tokyo_api/bluestatedigital.rb",
38
38
  "lib/tokyo_api/client.rb",
39
39
  "lib/tokyo_api/expire.rb",
40
+ "lib/tokyo_api/identity.rb",
40
41
  "lib/tokyo_api/krautbuster.rb",
41
42
  "spec/actionkit_spec.rb",
42
43
  "spec/bluestatedigital_spec.rb",
43
44
  "spec/client_spec.rb",
44
45
  "spec/expire_spec.rb",
45
46
  "spec/fixtures/expire/success",
47
+ "spec/fixtures/responses/actionkit/full_user_success",
48
+ "spec/fixtures/responses/bluestatedigital/full_user_success",
46
49
  "spec/fixtures/responses/full_user_error",
47
50
  "spec/fixtures/responses/full_user_success",
51
+ "spec/fixtures/responses/identity/full_user_success",
52
+ "spec/fixtures/responses/krautbuster/full_user_success",
53
+ "spec/identity_spec.rb",
48
54
  "spec/krautbuster_spec.rb",
49
55
  "spec/spec_helper.rb",
50
56
  "spec/tokyo_api_spec.rb",
51
57
  "tokyo_api.gemspec"
52
58
  ]
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"
59
+ s.homepage = "http://github.com/controlshift/tokyo_api".freeze
60
+ s.licenses = ["MIT".freeze]
61
+ s.rubygems_version = "2.5.2".freeze
62
+ s.summary = "Ruby API Wrapper for Tokyo CRM service".freeze
57
63
 
58
64
  if s.respond_to? :specification_version then
59
65
  s.specification_version = 4
60
66
 
61
67
  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
+ s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0"])
69
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
70
+ s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
71
+ s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
72
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
73
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
68
74
  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
+ s.add_dependency(%q<vertebrae>.freeze, [">= 0"])
76
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
77
+ s.add_dependency(%q<webmock>.freeze, [">= 0"])
78
+ s.add_dependency(%q<byebug>.freeze, [">= 0"])
79
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
80
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
75
81
  end
76
82
  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
+ s.add_dependency(%q<vertebrae>.freeze, [">= 0"])
84
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
85
+ s.add_dependency(%q<webmock>.freeze, [">= 0"])
86
+ s.add_dependency(%q<byebug>.freeze, [">= 0"])
87
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
88
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
83
89
  end
84
90
  end
85
91
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokyo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
11
+ date: 2017-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vertebrae
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: juwelier
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.1.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.1.0
96
+ version: '0'
97
97
  description: Tokyo is a CRM middleware, this gem helps apps talk to it.
98
98
  email: nathan@controlshiftlabs.com
99
99
  executables: []
@@ -120,14 +120,20 @@ files:
120
120
  - lib/tokyo_api/bluestatedigital.rb
121
121
  - lib/tokyo_api/client.rb
122
122
  - lib/tokyo_api/expire.rb
123
+ - lib/tokyo_api/identity.rb
123
124
  - lib/tokyo_api/krautbuster.rb
124
125
  - spec/actionkit_spec.rb
125
126
  - spec/bluestatedigital_spec.rb
126
127
  - spec/client_spec.rb
127
128
  - spec/expire_spec.rb
128
129
  - spec/fixtures/expire/success
130
+ - spec/fixtures/responses/actionkit/full_user_success
131
+ - spec/fixtures/responses/bluestatedigital/full_user_success
129
132
  - spec/fixtures/responses/full_user_error
130
133
  - spec/fixtures/responses/full_user_success
134
+ - spec/fixtures/responses/identity/full_user_success
135
+ - spec/fixtures/responses/krautbuster/full_user_success
136
+ - spec/identity_spec.rb
131
137
  - spec/krautbuster_spec.rb
132
138
  - spec/spec_helper.rb
133
139
  - spec/tokyo_api_spec.rb
@@ -152,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
158
  version: '0'
153
159
  requirements: []
154
160
  rubyforge_project:
155
- rubygems_version: 2.4.8
161
+ rubygems_version: 2.5.2
156
162
  signing_key:
157
163
  specification_version: 4
158
164
  summary: Ruby API Wrapper for Tokyo CRM service