tokyo_api 0.6.1 → 1.0.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 +4 -4
- data/VERSION +1 -1
- data/lib/tokyo_api/actionkit.rb +8 -4
- data/lib/tokyo_api/base.rb +12 -0
- data/lib/tokyo_api/bluestatedigital.rb +8 -4
- data/lib/tokyo_api/expire.rb +1 -1
- data/lib/tokyo_api/identity.rb +8 -3
- data/lib/tokyo_api/krautbuster.rb +10 -6
- data/spec/actionkit_spec.rb +8 -4
- data/spec/bluestatedigital_spec.rb +8 -4
- data/spec/identity_spec.rb +8 -4
- data/spec/krautbuster_spec.rb +14 -2
- data/tokyo_api.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79401acf7c96745e5ace0e9aee6cde215ab3872a
|
4
|
+
data.tar.gz: c785ce0ee3fe07bdb3797e89c66a858fa9ba88cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dfb6516012f4917d445f6834741b1a404c5f1a594cfe753dd92d0d688c7372a8b444e4a46673e6b70572e5a1f5b8adcd3bf0e3348784e4946968b69d4a7c9ea
|
7
|
+
data.tar.gz: 990d1937b86831cb4b6e78a7cfd6a53ca65e215886ac20fb4d54a989e76c6fa038bc318f84e7cafc521f137bfafb31a5e811b5aaf767711b39ea9ae2f297d02b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.1
|
data/lib/tokyo_api/actionkit.rb
CHANGED
@@ -5,11 +5,15 @@ module TokyoApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def full_user(id)
|
8
|
-
client.get_request("#{normalized_base_path}full_user/#{id}").body
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{url_escape(id)}").body
|
9
9
|
end
|
10
10
|
|
11
|
-
def user_path(id,
|
12
|
-
"/#{normalized_base_path}user/#{id}
|
11
|
+
def user_path(id, required_fields: nil)
|
12
|
+
path = "/#{normalized_base_path}user/#{url_escape(id)}"
|
13
|
+
unless required_fields.nil?
|
14
|
+
path << "?#{required_fields_param(required_fields)}"
|
15
|
+
end
|
16
|
+
path
|
13
17
|
end
|
14
18
|
end
|
15
|
-
end
|
19
|
+
end
|
data/lib/tokyo_api/base.rb
CHANGED
@@ -3,5 +3,17 @@ module TokyoApi
|
|
3
3
|
def normalized_base_path
|
4
4
|
"#{base_path}/"
|
5
5
|
end
|
6
|
+
|
7
|
+
def url_escape(string)
|
8
|
+
CGI.escape(string)
|
9
|
+
end
|
10
|
+
|
11
|
+
def required_fields_param(required_fields)
|
12
|
+
if required_fields.present?
|
13
|
+
"required_fields=#{required_fields.collect{|v| url_escape(v.to_s)}.join(',')}"
|
14
|
+
else
|
15
|
+
''
|
16
|
+
end
|
17
|
+
end
|
6
18
|
end
|
7
19
|
end
|
@@ -5,11 +5,15 @@ module TokyoApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def full_user(id)
|
8
|
-
client.get_request("#{normalized_base_path}full_user/#{id}").body
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{url_escape(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, required_fields: nil)
|
12
|
+
path = "/#{normalized_base_path}constituent/#{url_escape(id)}"
|
13
|
+
unless required_fields.nil?
|
14
|
+
path << "?#{required_fields_param(required_fields)}"
|
15
|
+
end
|
16
|
+
path
|
13
17
|
end
|
14
18
|
end
|
15
|
-
end
|
19
|
+
end
|
data/lib/tokyo_api/expire.rb
CHANGED
data/lib/tokyo_api/identity.rb
CHANGED
@@ -5,11 +5,16 @@ module TokyoApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def full_user(id)
|
8
|
-
client.get_request("#{normalized_base_path}full_user/#{id}").body
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{url_escape(id)}").body
|
9
9
|
end
|
10
10
|
|
11
|
-
def tokyo_identity_user_path(id,
|
12
|
-
"/#{normalized_base_path}user/#{id}
|
11
|
+
def tokyo_identity_user_path(id, required_fields: nil)
|
12
|
+
path = "/#{normalized_base_path}user/#{url_escape(id)}"
|
13
|
+
|
14
|
+
unless required_fields.nil?
|
15
|
+
path << "?#{required_fields_param(required_fields)}"
|
16
|
+
end
|
17
|
+
path
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -5,11 +5,11 @@ module TokyoApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def full_user(session_id)
|
8
|
-
client.get_request("#{normalized_base_path}full_user/#{session_id}").body
|
8
|
+
client.get_request("#{normalized_base_path}full_user/#{url_escape(session_id)}").body
|
9
9
|
end
|
10
10
|
|
11
11
|
def session_status(session_id)
|
12
|
-
client.get_request("#{normalized_base_path}session_status/#{session_id}").body
|
12
|
+
client.get_request("#{normalized_base_path}session_status/#{url_escape(session_id)}").body
|
13
13
|
end
|
14
14
|
|
15
15
|
def subscription_status(token)
|
@@ -25,12 +25,16 @@ module TokyoApi
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def user_path(session_id, petition_id)
|
29
|
-
"/#{normalized_base_path}user/#{session_id}?petition_id=#{petition_id}"
|
28
|
+
def user_path(session_id, petition_id:, required_fields: nil)
|
29
|
+
path = "/#{normalized_base_path}user/#{url_escape(session_id)}?petition_id=#{url_escape(petition_id)}"
|
30
|
+
unless required_fields.nil?
|
31
|
+
path << "&#{required_fields_param(required_fields)}"
|
32
|
+
end
|
33
|
+
path
|
30
34
|
end
|
31
35
|
|
32
36
|
def subscription_status_path(token)
|
33
|
-
"/#{normalized_base_path}subscription_status/#{token}"
|
37
|
+
"/#{normalized_base_path}subscription_status/#{url_escape(token)}"
|
34
38
|
end
|
35
39
|
end
|
36
|
-
end
|
40
|
+
end
|
data/spec/actionkit_spec.rb
CHANGED
@@ -38,15 +38,19 @@ describe TokyoApi::Actionkit do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'user_path' do
|
41
|
-
context '
|
41
|
+
context 'without required_fields' do
|
42
42
|
it "should return relative path to user API endpoint" do
|
43
|
-
expect(subject.actionkit.user_path('abc.123.xyz'
|
43
|
+
expect(subject.actionkit.user_path('abc.123.xyz')).to eq('/actionkit/user/abc.123.xyz')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context '
|
47
|
+
context 'with required_fields' do
|
48
48
|
it "should return relative path to user API endpoint" do
|
49
|
-
expect(subject.actionkit.user_path('abc.123.xyz',
|
49
|
+
expect(subject.actionkit.user_path('abc.123.xyz', required_fields: [:first_name, :last_name, :email, :postal, :phone])).to eq('/actionkit/user/abc.123.xyz?required_fields=first_name,last_name,email,postal,phone')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should url-escape field names with weird characters' do
|
53
|
+
expect(subject.actionkit.user_path('abc.123.xyz', required_fields: ['email', 'fish & chips'])).to eq('/actionkit/user/abc.123.xyz?required_fields=email,fish+%26+chips')
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
@@ -39,15 +39,19 @@ describe TokyoApi::Bluestatedigital do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe 'tokyo_blue_state_digital_user_path' do
|
42
|
-
context '
|
42
|
+
context 'without required_fields' do
|
43
43
|
it "should return rooted relative path to tokyo user API endpoint" do
|
44
|
-
expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456'
|
44
|
+
expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456')).to eq('/bluestatedigital/constituent/-123456')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context '
|
48
|
+
context 'with required_fields' do
|
49
49
|
it "should return rooted relative path to tokyo user API endpoint" do
|
50
|
-
expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456',
|
50
|
+
expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456', required_fields: [:first_name, :last_name, :email, :postal, :phone])).to eq('/bluestatedigital/constituent/-123456?required_fields=first_name,last_name,email,postal,phone')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should url-escape field names with weird characters' do
|
54
|
+
expect(subject.bluestatedigital.tokyo_blue_state_digital_user_path('-123456', required_fields: ['email', 'fish & chips'])).to eq('/bluestatedigital/constituent/-123456?required_fields=email,fish+%26+chips')
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
data/spec/identity_spec.rb
CHANGED
@@ -38,15 +38,19 @@ describe TokyoApi::Identity do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'tokyo_identity_user_path' do
|
41
|
-
context '
|
41
|
+
context 'without required_fields' do
|
42
42
|
it 'should return rooted relative path to tokyo user API endpoint' do
|
43
|
-
expect(subject.identity.tokyo_identity_user_path('-123456'
|
43
|
+
expect(subject.identity.tokyo_identity_user_path('-123456')).to eq('/identity/user/-123456')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
context '
|
47
|
+
context 'with required_fields' do
|
48
48
|
it 'should return rooted relative path to tokyo user API endpoint' do
|
49
|
-
expect(subject.identity.tokyo_identity_user_path('-123456',
|
49
|
+
expect(subject.identity.tokyo_identity_user_path('-123456', required_fields: [:first_name, :last_name, :email, :postal, :phone])).to eq('/identity/user/-123456?required_fields=first_name,last_name,email,postal,phone')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should url-escape field names with weird characters' do
|
53
|
+
expect(subject.identity.tokyo_identity_user_path('-123456', required_fields: ['email', 'fish & chips'])).to eq('/identity/user/-123456?required_fields=email,fish+%26+chips')
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
data/spec/krautbuster_spec.rb
CHANGED
@@ -71,8 +71,20 @@ describe TokyoApi::Krautbuster do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
describe '#user_path' do
|
74
|
-
|
75
|
-
|
74
|
+
context 'without required_fields' do
|
75
|
+
it "should return relative path to user API endpoint" do
|
76
|
+
expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees')).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'with required_fields' do
|
81
|
+
it "should return relative path to user API endpoint" do
|
82
|
+
expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees', required_fields: [:first_name, :last_name, :email])).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees&required_fields=first_name,last_name,email'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should url-escape field names with weird characters' do
|
86
|
+
expect(subject.krautbuster.user_path('123abc456', petition_id: 'save-the-trees', required_fields: ['email', 'fish & chips'])).to eq '/krautbuster/user/123abc456?petition_id=save-the-trees&required_fields=email,fish+%26+chips'
|
87
|
+
end
|
76
88
|
end
|
77
89
|
end
|
78
90
|
|
data/tokyo_api.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.
|
5
|
+
# stub: tokyo_api 1.0.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tokyo_api".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "1.0.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Nathan Woodhull".freeze]
|
14
|
-
s.date = "2017-
|
14
|
+
s.date = "2017-09-07"
|
15
15
|
s.description = "Tokyo is a CRM middleware, this gem helps apps talk to it.".freeze
|
16
16
|
s.email = "nathan@controlshiftlabs.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
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.
|
4
|
+
version: 1.0.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: 2017-
|
11
|
+
date: 2017-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vertebrae
|