tokyo_api 1.5.0 → 1.7.0

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
  SHA256:
3
- metadata.gz: 879c3eec6862437e9ab0804668b7cdc48d0194320af0dbc16d990bed2565d1c1
4
- data.tar.gz: 6322d8e872f7cc5ae26708795c42809d50eab916766fa2035306836ee982c697
3
+ metadata.gz: 1632d0b0d73603bbf7eba85d8343f91cb8ee95926cf4b1e9e82dcd7e8e2674f7
4
+ data.tar.gz: 96e8a638a06c798c45e54b40e2018a1a0c5652614363c9f094e95c08cbdddc18
5
5
  SHA512:
6
- metadata.gz: 1505f232ce2c5e21c1446e39b891b36358536351ef0884ebdea5171c0ec21a0a68bf6b19fe04acc72689f79e3c2fca86421de80cf106f122ce4c1a2d65ecf834
7
- data.tar.gz: 8814d7b820864e694e3e3de69c7ea24542479aa389db00e10cc4da1ab28f3bd100120f4a5339d8ac7f93f279a6dbde72e8c97f5201101700ec72783b8ea44c35
6
+ metadata.gz: e161f064e5dc728c24bafd7e4062eaef534ce63f2b278ba3cde492e8e5688156d5667f24fe858ded83fff39f21487085bbd15acc2ae73c52831bcafa6cdd1c38
7
+ data.tar.gz: 13c6dc24f97b53163e12e8f8e134a7e7c1e709d3847a6edfec9df131cbbd35e6053784482d1e5757b88bf5fdd98cc29f4ce1177e4f3c001dc097b3573fee113e
@@ -0,0 +1,14 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v2
9
+ - uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
10
+ with:
11
+ ruby-version: 2.7
12
+ bundler-cache: true
13
+ - run: bundle install
14
+ - run: bundle exec rspec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.1
1
+ 3.0.3
data/Gemfile CHANGED
@@ -1,13 +1,16 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- gem 'vertebrae', '~> 0.5.1'
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'vertebrae', '>= 0.6.0'
4
6
 
5
7
  # Add dependencies to develop your gem here.
6
8
  # Include everything needed to run rake, tests, features, etc.
7
9
  group :development do
8
- gem "rspec"
9
- gem 'webmock'
10
+ gem 'bundler'
10
11
  gem 'byebug'
11
- gem "bundler"
12
- gem "juwelier"
12
+ gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
13
+ gem 'rspec'
14
+ gem 'rubocop'
15
+ gem 'webmock'
13
16
  end
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # tokyo_api
1
+ # tokyo\_api
2
2
 
3
3
  A ruby gem for communicating with ControlShift's Tokyo API.
4
4
 
5
- [![Build Status](https://travis-ci.org/controlshift/tokyo_api.svg)](https://travis-ci.org/controlshift/tokyo_api)
5
+ [![CI Status](https://github.com/controlshift/tokyo_api/actions/workflows/ci.yml/badge.svg)](https://github.com/controlshift/tokyo_api/actions/workflows/ci.yml)
6
6
 
7
7
  ## Usage
8
8
 
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
5
  begin
6
6
  Bundler.setup(:default, :development)
7
7
  rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
8
+ warn e.message
9
+ warn 'Run `bundle install` to install missing gems'
10
10
  exit e.status_code
11
11
  end
12
12
  require 'rake'
@@ -14,13 +14,13 @@ require 'rake'
14
14
  require 'juwelier'
15
15
  Juwelier::Tasks.new do |gem|
16
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"]
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
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Juwelier::RubygemsDotOrgTasks.new
@@ -36,11 +36,11 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
36
  spec.rcov = true
37
37
  end
38
38
 
39
- task :default => :spec
39
+ task default: :spec
40
40
 
41
41
  require 'rdoc/task'
42
42
  Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
44
44
 
45
45
  rdoc.rdoc_dir = 'rdoc'
46
46
  rdoc.title = "tokyo_api #{version}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0
1
+ 1.7.0
data/example.rb CHANGED
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
2
4
 
3
5
  require 'tokyo_api'
4
6
 
5
7
  ta = TokyoApi.new(host: 'localhost:9000', username: 'tokyo', password: 'Passw0rd!', scheme: 'http')
6
8
 
7
-
8
9
  require 'pry-debugger'
9
- binding.pry
10
+ binding.pry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Actionkit < Base
3
5
  def base_path
@@ -9,10 +11,8 @@ module TokyoApi
9
11
  end
10
12
 
11
13
  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
14
+ path = String.new("/#{normalized_base_path}user/#{url_escape(id)}")
15
+ path << "?#{required_fields_param(required_fields)}" unless required_fields.nil?
16
16
  path
17
17
  end
18
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Base < Vertebrae::Model
3
5
  def normalized_base_path
@@ -10,10 +12,10 @@ module TokyoApi
10
12
 
11
13
  def required_fields_param(required_fields)
12
14
  if required_fields.present?
13
- "required_fields=#{required_fields.collect{|v| url_escape(v.to_s)}.join(',')}"
15
+ "required_fields=#{required_fields.collect { |v| url_escape(v.to_s) }.join(',')}"
14
16
  else
15
17
  ''
16
18
  end
17
19
  end
18
20
  end
19
- end
21
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Campact < Base
3
5
  def base_path
@@ -17,26 +19,18 @@ module TokyoApi
17
19
  end
18
20
 
19
21
  def subscription_status(token)
20
- begin
21
- client.get_request(subscription_status_path(token)).body
22
- rescue Vertebrae::ResponseError => e
23
- # Status 404 is expected in these calls
24
- if e.status_code == 404
25
- return nil
26
- end
27
-
28
- raise
29
- end
22
+ client.get_request(subscription_status_path(token)).body
23
+ rescue Vertebrae::ResponseError => e
24
+ # Status 404 is expected in these calls
25
+ return nil if e.status_code == 404
26
+
27
+ raise
30
28
  end
31
29
 
32
30
  def user_path(session_id, petition_id:, with_subscription_status: false, required_fields: nil)
33
- path = "/#{normalized_base_path}user/#{url_escape(session_id)}?petition_id=#{url_escape(petition_id)}"
34
- if with_subscription_status
35
- path << '&with_subscription_status=true'
36
- end
37
- unless required_fields.nil?
38
- path << "&#{required_fields_param(required_fields)}"
39
- end
31
+ path = String.new("/#{normalized_base_path}user/#{url_escape(session_id)}?petition_id=#{url_escape(petition_id)}")
32
+ path << '&with_subscription_status=true' if with_subscription_status
33
+ path << "&#{required_fields_param(required_fields)}" unless required_fields.nil?
40
34
  path
41
35
  end
42
36
 
@@ -1,16 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Client < Vertebrae::API
3
5
  def actionkit
4
6
  @actionkit ||= TokyoApi::Actionkit.new(client: self)
5
7
  end
6
8
 
7
- alias_method :action_kit, :actionkit
8
-
9
- def bluestatedigital
10
- @bluestatedigital ||= TokyoApi::Bluestatedigital.new(client: self)
11
- end
12
-
13
- alias_method :blue_state_digital, :bluestatedigital
9
+ alias action_kit actionkit
14
10
 
15
11
  def campact
16
12
  @campact ||= TokyoApi::Campact.new(client: self)
@@ -24,7 +20,6 @@ module TokyoApi
24
20
  @expire ||= TokyoApi::Expire.new(client: self)
25
21
  end
26
22
 
27
-
28
23
  def default_options
29
24
  opts = {
30
25
  user_agent: 'TokyoApi Gem',
@@ -32,32 +27,27 @@ module TokyoApi
32
27
  content_type: 'application/json'
33
28
  }
34
29
 
35
- if initialisation_options.has_key?(:timeout)
36
- opts[:connection_options] = {request: {timeout: initialisation_options[:timeout]}}
30
+ if initialisation_options.key?(:timeout)
31
+ opts[:connection_options] = { request: { timeout: initialisation_options[:timeout] } }
37
32
  end
38
33
 
39
34
  opts
40
35
  end
41
36
 
42
37
  def request(method, path, params, options) # :nodoc:
43
- if !::Vertebrae::Request::METHODS.include?(method)
44
- raise ArgumentError, "unknown http method: #{method}"
45
- end
38
+ raise ArgumentError, "unknown http method: #{method}" unless ::Vertebrae::Request::METHODS.include?(method)
46
39
 
47
- unless connection.configuration.prefix.blank?
48
- path = connection.configuration.prefix + '/' + path
49
- end
40
+ path = "#{connection.configuration.prefix}/#{path}" unless connection.configuration.prefix.blank?
50
41
 
51
42
  ::Vertebrae::Base.logger.debug "EXECUTED: #{method} - #{path} with #{params} and #{options}"
52
43
 
53
44
  connection.connection.send(method) do |request|
54
-
55
45
  case method.to_sym
56
- when *(::Vertebrae::Request::METHODS - ::Vertebrae::Request::METHODS_WITH_BODIES)
57
- request.url(path, params)
58
- when *::Vertebrae::Request::METHODS_WITH_BODIES
59
- request.path = path
60
- request.body = extract_data_from_params(params) unless params.empty?
46
+ when *(::Vertebrae::Request::METHODS - ::Vertebrae::Request::METHODS_WITH_BODIES)
47
+ request.url(path, params)
48
+ when *::Vertebrae::Request::METHODS_WITH_BODIES
49
+ request.path = path
50
+ request.body = extract_data_from_params(params) unless params.empty?
61
51
  end
62
52
  end
63
53
  end
@@ -67,7 +57,8 @@ module TokyoApi
67
57
  builder.use Faraday::Request::Multipart
68
58
  builder.use Faraday::Request::UrlEncoded
69
59
  if connection.configuration.authenticated?
70
- builder.use Faraday::Request::BasicAuthentication, connection.configuration.username, connection.configuration.password
60
+ builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
61
+ connection.configuration.password
71
62
  end
72
63
 
73
64
  builder.use Faraday::Response::Logger if ENV['DEBUG']
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Expire < Base
3
5
  def base_path
@@ -8,4 +10,4 @@ module TokyoApi
8
10
  client.get_request("#{normalized_base_path}organisation/#{url_escape(host)}").body
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TokyoApi
2
4
  class Identity < Base
3
5
  def base_path
@@ -8,25 +10,17 @@ module TokyoApi
8
10
  client.get_request("#{normalized_base_path}full_user/#{url_escape(id)}").body
9
11
  end
10
12
 
11
- def tokyo_identity_user_path(id, with_subscription_status: false, required_fields: nil, opt_in_public_ids: nil, minimum_consent_level: nil, encrypted: nil)
12
- path = "/#{normalized_base_path}user/#{url_escape(id)}"
13
+ def tokyo_identity_user_path(id, required_fields: nil, opt_in_public_ids: nil, minimum_consent_level: nil, encrypted: nil)
14
+ path = String.new("/#{normalized_base_path}user/#{url_escape(id)}")
13
15
 
14
16
  params = []
15
- unless required_fields.nil?
16
- params << required_fields_param(required_fields)
17
- end
18
-
19
- if with_subscription_status
20
- params << 'with_subscription_status=true'
21
- additional_subscription_parameters = path_for_subscription_status_params(opt_in_public_ids, minimum_consent_level, encrypted)
22
- unless additional_subscription_parameters.blank?
23
- params << additional_subscription_parameters
24
- end
25
- end
26
-
27
- if params.any?
28
- path << "?#{params.join('&')}"
29
- end
17
+ params << required_fields_param(required_fields) unless required_fields.nil?
18
+
19
+ additional_subscription_parameters = path_for_subscription_status_params(opt_in_public_ids,
20
+ minimum_consent_level, encrypted)
21
+ params << additional_subscription_parameters if additional_subscription_parameters.present?
22
+
23
+ path << "?#{params.join('&')}" if params.any?
30
24
 
31
25
  path
32
26
  end
@@ -34,25 +28,23 @@ module TokyoApi
34
28
  def subscription_status_path(id, opt_in_public_ids: nil, minimum_consent_level: nil, encrypted: nil)
35
29
  raise 'must provide opt_in_public_ids' if opt_in_public_ids.nil?
36
30
 
37
- "/#{normalized_base_path}subscription_status/#{url_escape(id)}?#{path_for_subscription_status_params(opt_in_public_ids, minimum_consent_level, encrypted)}"
31
+ "/#{normalized_base_path}subscription_status/#{url_escape(id)}?#{path_for_subscription_status_params(
32
+ opt_in_public_ids, minimum_consent_level, encrypted
33
+ )}"
38
34
  end
39
35
 
40
36
  private
41
37
 
42
38
  def path_for_subscription_status_params(opt_in_public_ids, minimum_consent_level, encrypted = nil)
43
- path = ''
44
-
45
- if opt_in_public_ids.present?
46
- path = "opt_in_public_ids=#{url_escape(opt_in_public_ids.join(','))}"
47
- end
39
+ path = if opt_in_public_ids.present?
40
+ String.new("opt_in_public_ids=#{url_escape(opt_in_public_ids.join(','))}")
41
+ else
42
+ String.new('')
43
+ end
48
44
 
49
- if minimum_consent_level
50
- path << "&minimum_consent_level=#{url_escape(minimum_consent_level)}"
51
- end
45
+ path << "&minimum_consent_level=#{url_escape(minimum_consent_level)}" if minimum_consent_level
52
46
 
53
- if encrypted
54
- path << "&encrypted=1"
55
- end
47
+ path << '&encrypted=1' if encrypted
56
48
 
57
49
  path
58
50
  end
data/lib/tokyo_api.rb CHANGED
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'vertebrae'
2
4
  require 'tokyo_api/base'
3
5
  require 'tokyo_api/actionkit'
4
- require 'tokyo_api/bluestatedigital'
5
6
  require 'tokyo_api/campact'
6
7
  require 'tokyo_api/client'
7
8
  require 'tokyo_api/expire'
@@ -1,4 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi::Actionkit do
4
6
  subject { TokyoApi.new(host: 'test.com') }
@@ -15,15 +17,15 @@ describe TokyoApi::Actionkit do
15
17
  let(:status) { 200 }
16
18
 
17
19
  before(:each) do
18
- stub_get(request_path).to_return(:body => body, :status => status,
19
- :headers => { content_type: "application/json; charset=utf-8"})
20
+ stub_get(request_path).to_return(body: body, status: status,
21
+ headers: { content_type: 'application/json; charset=utf-8' })
20
22
  end
21
23
 
22
24
  describe 'error' do
23
25
  let(:body) { fixture('responses/full_user_error') }
24
26
 
25
27
  it 'should return an error hash' do
26
- expect(subject.actionkit.full_user('1')).to eq({'error' => 'Connection refused'})
28
+ expect(subject.actionkit.full_user('1')).to eq({ 'error' => 'Connection refused' })
27
29
  end
28
30
  end
29
31
 
@@ -39,18 +41,22 @@ describe TokyoApi::Actionkit do
39
41
 
40
42
  describe 'user_path' do
41
43
  context 'without required_fields' do
42
- it "should return relative path to user API endpoint" do
44
+ it 'should return relative path to user API endpoint' do
43
45
  expect(subject.actionkit.user_path('abc.123.xyz')).to eq('/actionkit/user/abc.123.xyz')
44
46
  end
45
47
  end
46
48
 
47
49
  context 'with required_fields' do
48
- it "should return relative path to user API endpoint" do
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
+ it 'should return relative path to user API endpoint' do
51
+ expect(subject.actionkit.user_path('abc.123.xyz',
52
+ required_fields: %i[first_name last_name email postal
53
+ phone])).to eq('/actionkit/user/abc.123.xyz?required_fields=first_name,last_name,email,postal,phone')
50
54
  end
51
55
 
52
56
  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')
57
+ expect(subject.actionkit.user_path('abc.123.xyz',
58
+ required_fields: ['email',
59
+ 'fish & chips'])).to eq('/actionkit/user/abc.123.xyz?required_fields=email,fish+%26+chips')
54
60
  end
55
61
  end
56
62
  end
data/spec/campact_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi::Campact do
4
6
  subject { TokyoApi.new(host: 'test.com') }
@@ -15,15 +17,15 @@ describe TokyoApi::Campact do
15
17
  let(:status) { 200 }
16
18
 
17
19
  before(:each) do
18
- stub_get(request_path).to_return(:body => body, :status => status,
19
- :headers => { content_type: "application/json; charset=utf-8"})
20
+ stub_get(request_path).to_return(body: body, status: status,
21
+ headers: { content_type: 'application/json; charset=utf-8' })
20
22
  end
21
23
 
22
24
  describe 'error' do
23
25
  let(:body) { fixture('responses/full_user_error') }
24
26
 
25
27
  it 'should return an error message' do
26
- expect(subject.campact.full_user('123abc456')).to eq({'error' => 'Connection refused'})
28
+ expect(subject.campact.full_user('123abc456')).to eq({ 'error' => 'Connection refused' })
27
29
  end
28
30
  end
29
31
 
@@ -31,8 +33,8 @@ describe TokyoApi::Campact do
31
33
  let(:body) { fixture('responses/campact/full_user_success') }
32
34
 
33
35
  it 'should find an organisation' do
34
- expect(subject.campact.full_user('123abc456')).to eq({'first_name' => 'Homer', 'last_name' => 'Simpson',
35
- 'country' => 'DE', 'postal' => '12345', 'email' => 'foo@bar.com' })
36
+ expect(subject.campact.full_user('123abc456')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
37
+ 'country' => 'DE', 'postal' => '12345', 'email' => 'foo@bar.com' })
36
38
  end
37
39
  end
38
40
  end
@@ -48,15 +50,19 @@ describe TokyoApi::Campact do
48
50
  end
49
51
 
50
52
  it 'should perform request on subscription_status_path' do
51
- expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_return(double(body: {subscribed: true}))
53
+ expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_return(double(body: { subscribed: true }))
52
54
 
53
55
  subs_status = subject.subscription_status(token)
54
56
 
55
- expect(subs_status).to eq({subscribed: true})
57
+ expect(subs_status).to eq({ subscribed: true })
56
58
  end
57
59
 
58
60
  it 'should return nil if tokyo responds with 404' do
59
- expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(404, {method: 'get', url: "/campact/subscription_status?token=#{token}", status: '404', body: 'Not Found'}))
61
+ expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(
62
+ 404, {
63
+ method: 'get', url: "/campact/subscription_status?token=#{token}", status: '404', body: 'Not Found'
64
+ }
65
+ ))
60
66
 
61
67
  subs_status = subject.subscription_status(token)
62
68
 
@@ -64,7 +70,10 @@ describe TokyoApi::Campact do
64
70
  end
65
71
 
66
72
  it 'should raise if tokyo responds with other error code' do
67
- expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(500, {method: 'get', url: "/campact/subscription_status?token=#{token}", status: '500', body: 'Something bad happened'}))
73
+ expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_raise(Vertebrae::ResponseError.new(
74
+ 500, { method: 'get', url: "/campact/subscription_status?token=#{token}", status: '500',
75
+ body: 'Something bad happened' }
76
+ ))
68
77
 
69
78
  expect { subject.subscription_status(token) }.to raise_error Vertebrae::ResponseError
70
79
  end
@@ -72,32 +81,38 @@ describe TokyoApi::Campact do
72
81
 
73
82
  describe '#user_path' do
74
83
  context 'without required_fields' do
75
- it "should return relative path to user API endpoint" do
76
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees')).to eq '/campact/user/123abc456?petition_id=save-the-trees'
84
+ it 'should return relative path to user API endpoint' do
85
+ expect(subject.campact.user_path('123abc456',
86
+ petition_id: 'save-the-trees')).to eq '/campact/user/123abc456?petition_id=save-the-trees'
77
87
  end
78
88
  end
79
89
 
80
90
  context 'with required_fields' do
81
- it "should return relative path to user API endpoint" do
82
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees', required_fields: [:first_name, :last_name, :email])).to eq '/campact/user/123abc456?petition_id=save-the-trees&required_fields=first_name,last_name,email'
91
+ it 'should return relative path to user API endpoint' do
92
+ expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
93
+ required_fields: %i[first_name last_name email])).to eq '/campact/user/123abc456?petition_id=save-the-trees&required_fields=first_name,last_name,email'
83
94
  end
84
95
 
85
96
  it 'should url-escape field names with weird characters' do
86
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees', required_fields: ['email', 'fish & chips'])).to eq '/campact/user/123abc456?petition_id=save-the-trees&required_fields=email,fish+%26+chips'
97
+ expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
98
+ required_fields: ['email', 'fish & chips'])).to eq '/campact/user/123abc456?petition_id=save-the-trees&required_fields=email,fish+%26+chips'
87
99
  end
88
100
  end
89
101
 
90
102
  context 'with_subscription_status argument' do
91
103
  it 'should not include query string parameter if argument is missing' do
92
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees')).not_to match /.+with_subscription_status=.+/
104
+ expect(subject.campact.user_path('123abc456',
105
+ petition_id: 'save-the-trees')).not_to match(/.+with_subscription_status=.+/)
93
106
  end
94
107
 
95
108
  it 'should not include query string parameter if argument is false' do
96
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees', with_subscription_status: false)).not_to match /.+with_subscription_status=.+/
109
+ expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
110
+ with_subscription_status: false)).not_to match(/.+with_subscription_status=.+/)
97
111
  end
98
112
 
99
113
  it 'should include query string parameter if argument is true' do
100
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees', with_subscription_status: true)).to match /.+with_subscription_status=true.*/
114
+ expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
115
+ with_subscription_status: true)).to match(/.+with_subscription_status=true.*/)
101
116
  end
102
117
  end
103
118
  end
@@ -117,7 +132,9 @@ describe TokyoApi::Campact do
117
132
  subject { TokyoApi::Campact.new(client: client) }
118
133
 
119
134
  it 'should perform request on session status path' do
120
- expect(client).to receive(:get_request).with("/campact/session/#{session_id}/status").and_return(double(body: { hard_login: false, soft_login: true }))
135
+ expect(client).to receive(:get_request).with("/campact/session/#{session_id}/status").and_return(double(body: {
136
+ hard_login: false, soft_login: true
137
+ }))
121
138
 
122
139
  session_status = subject.session_status(session_id)
123
140
 
data/spec/client_spec.rb CHANGED
@@ -1,11 +1,13 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi::Client do
4
6
  describe 'initialisation' do
5
7
  subject { described_class.new(options) }
6
8
 
7
9
  context 'with a basic_auth string parameter' do
8
- let(:options) { {basic_auth: 'login:password'} }
10
+ let(:options) { { basic_auth: 'login:password' } }
9
11
 
10
12
  it 'should set username/password on the configuration' do
11
13
  config = subject.connection.configuration
@@ -15,7 +17,7 @@ describe TokyoApi::Client do
15
17
  end
16
18
 
17
19
  context 'with a timeout' do
18
- let(:options) { {timeout: 5} }
20
+ let(:options) { { timeout: 5 } }
19
21
 
20
22
  it 'should set the timeout on the faraday options' do
21
23
  config = subject.connection.configuration
data/spec/expire_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi::Expire do
4
6
  subject { TokyoApi.new(host: 'test.com') }
@@ -8,16 +10,16 @@ describe TokyoApi::Expire do
8
10
  let(:request_path) { '/expire/organisation/foo.com' }
9
11
 
10
12
  before(:each) do
11
- stub_get(request_path).to_return(:body => body, :status => status,
12
- :headers => { content_type: "application/json; charset=utf-8"})
13
+ stub_get(request_path).to_return(body: body, status: status,
14
+ headers: { content_type: 'application/json; charset=utf-8' })
13
15
  end
14
16
 
15
17
  describe 'success' do
16
- let(:status) { 200 }
18
+ let(:status) { 200 }
17
19
 
18
20
  it 'should find an organisation' do
19
- expect(subject.expire.organisation('foo.com')).to eq({'status' => 'success'})
21
+ expect(subject.expire.organisation('foo.com')).to eq({ 'status' => 'success' })
20
22
  end
21
23
  end
22
24
  end
23
- end
25
+ end
@@ -1,4 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi::Identity do
4
6
  subject { TokyoApi.new(host: 'test.com') }
@@ -15,15 +17,15 @@ describe TokyoApi::Identity do
15
17
  let(:status) { 200 }
16
18
 
17
19
  before(:each) do
18
- stub_get(request_path).to_return(:body => body, :status => status,
19
- :headers => { content_type: "application/json; charset=utf-8"})
20
+ stub_get(request_path).to_return(body: body, status: status,
21
+ headers: { content_type: 'application/json; charset=utf-8' })
20
22
  end
21
23
 
22
24
  describe 'error' do
23
25
  let(:body) { fixture('responses/full_user_error') }
24
26
 
25
27
  it 'should return an error hash' do
26
- expect(subject.identity.full_user('1')).to eq({'error' => 'Connection refused'})
28
+ expect(subject.identity.full_user('1')).to eq({ 'error' => 'Connection refused' })
27
29
  end
28
30
  end
29
31
 
@@ -31,8 +33,8 @@ describe TokyoApi::Identity do
31
33
  let(:body) { fixture('responses/identity/full_user_success') }
32
34
 
33
35
  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
+ expect(subject.identity.full_user('1')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
37
+ 'country' => 'GB', 'postal' => '12345', 'email' => 'foo@bar.com' })
36
38
  end
37
39
  end
38
40
  end
@@ -46,53 +48,32 @@ describe TokyoApi::Identity do
46
48
 
47
49
  context 'with required_fields' do
48
50
  it 'should return rooted relative path to tokyo user API endpoint' do
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')
51
+ expect(subject.identity.tokyo_identity_user_path('-123456',
52
+ required_fields: %i[first_name last_name email postal
53
+ phone])).to eq('/identity/user/-123456?required_fields=first_name,last_name,email,postal,phone')
50
54
  end
51
55
 
52
56
  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')
57
+ expect(subject.identity.tokyo_identity_user_path('-123456',
58
+ required_fields: ['email',
59
+ 'fish & chips'])).to eq('/identity/user/-123456?required_fields=email,fish+%26+chips')
54
60
  end
55
61
  end
56
62
 
57
- context 'with_subscription_status and associated arguments' do
58
- it 'should not include query string parameter if argument is missing' do
59
- expect(subject.identity.tokyo_identity_user_path('123abc456')).not_to match /.+with_subscription_status=.+/
60
- end
61
-
62
- it 'should not include query string parameter if argument is false' do
63
- expect(subject.identity.tokyo_identity_user_path('123abc456', with_subscription_status: false)).not_to match /.+with_subscription_status=.+/
64
- end
65
-
66
- it 'should not include opt_in_public_ids and minimum_consent_level if with_subscription_status is false' do
67
- tokyo_path = subject.identity.tokyo_identity_user_path('123abc456',
68
- with_subscription_status: false,
69
- opt_in_public_ids: ['policy-1.5'],
70
- minimum_consent_level: 'explicit')
71
-
72
- expect(tokyo_path).not_to match /.+opt_in_public_ids=.+/
73
- expect(tokyo_path).not_to match /.+minimum_consent_level=.+/
74
- end
75
-
76
- it 'should include query string parameter if argument is true' do
77
- expect(subject.identity.tokyo_identity_user_path('123abc456', with_subscription_status: true)).to match /.+with_subscription_status=.+/
78
- end
63
+ it 'should include encrypted parameter if argument is true' do
64
+ expect(subject.identity.tokyo_identity_user_path('123abc456', encrypted: true)).to match(/.+encrypted=.+/)
65
+ end
79
66
 
80
- it 'should include encrypted parameter if argument is true' do
81
- expect(subject.identity.tokyo_identity_user_path('123abc456', with_subscription_status: true, encrypted: true)).to match /.+encrypted=.+/
82
- end
67
+ it 'should include opt_in_public_ids and minimum_consent_level' do
68
+ tokyo_path = subject.identity.tokyo_identity_user_path('123abc456',
69
+ required_fields: %i[first_name last_name email
70
+ postal phone],
71
+ opt_in_public_ids: ['policy-1.5'],
72
+ minimum_consent_level: 'explicit')
83
73
 
84
- it 'should include opt_in_public_ids and minimum_consent_level if with_subscription_status is true' do
85
- tokyo_path = subject.identity.tokyo_identity_user_path('123abc456',
86
- required_fields: [:first_name, :last_name, :email, :postal, :phone],
87
- with_subscription_status: true,
88
- opt_in_public_ids: ['policy-1.5'],
89
- minimum_consent_level: 'explicit')
90
-
91
- expect(tokyo_path).to match /.+with_subscription_status=true.*/
92
- expect(tokyo_path).to match /.+opt_in_public_ids=.+/
93
- expect(tokyo_path).to match /.+minimum_consent_level=.+/
94
- expect { URI::parse(tokyo_path) }.not_to raise_error
95
- end
74
+ expect(tokyo_path).to match(/.+opt_in_public_ids=.+/)
75
+ expect(tokyo_path).to match(/.+minimum_consent_level=.+/)
76
+ expect { URI.parse(tokyo_path) }.not_to raise_error
96
77
  end
97
78
  end
98
79
 
@@ -103,17 +84,21 @@ describe TokyoApi::Identity do
103
84
 
104
85
  it 'should return correct path for a list of public ids' do
105
86
  expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5%2Cpolicy-1.6'
106
- expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5', 'policy-1.6'])).to eq expected_path
87
+ expect(subject.identity.subscription_status_path('abc123',
88
+ opt_in_public_ids: ['policy-1.5',
89
+ 'policy-1.6'])).to eq expected_path
107
90
  end
108
91
 
109
92
  it 'should support minimum_consent_level' do
110
93
  expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5&minimum_consent_level=explicit'
111
- expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5'], minimum_consent_level: 'explicit')).to eq expected_path
94
+ expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5'],
95
+ minimum_consent_level: 'explicit')).to eq expected_path
112
96
  end
113
97
 
114
98
  it 'should support encrypted param' do
115
99
  expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5&minimum_consent_level=explicit&encrypted=1'
116
- expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5'], minimum_consent_level: 'explicit', encrypted: true)).to eq expected_path
100
+ expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5'],
101
+ minimum_consent_level: 'explicit', encrypted: true)).to eq expected_path
117
102
  end
118
103
  end
119
104
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
5
  require 'rspec'
@@ -6,12 +8,12 @@ require 'tokyo_api'
6
8
 
7
9
  # Requires supporting files with custom matchers and macros, etc,
8
10
  # in ./support/ and its subdirectories.
9
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
10
12
 
11
13
  RSpec.configure do |config|
12
14
  config.include WebMock::API
13
15
  config.color = true
14
- #config.raise_errors_for_deprecations!
16
+ # config.raise_errors_for_deprecations!
15
17
  end
16
18
 
17
19
  def stub_get(path)
@@ -29,7 +31,7 @@ def stub_tokyo_request(method, path)
29
31
  end
30
32
 
31
33
  def fixture_path
32
- File.expand_path("../fixtures", __FILE__)
34
+ File.expand_path('fixtures', __dir__)
33
35
  end
34
36
 
35
37
  def fixture(file)
@@ -1,11 +1,11 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
4
 
3
5
  describe TokyoApi do
4
6
  before(:each) do
5
7
  allow(TokyoApi::Client).to receive(:setup_client)
6
8
  end
7
9
  specify { expect(subject).to respond_to :actionkit }
8
- specify { expect(subject.new).to be_a(TokyoApi::Client)}
10
+ specify { expect(subject.new).to be_a(TokyoApi::Client) }
9
11
  end
10
-
11
-
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 1.5.0 ruby lib
5
+ # stub: tokyo_api 1.7.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tokyo_api".freeze
9
- s.version = "1.5.0"
9
+ s.version = "1.7.0"
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 = "2020-03-16"
14
+ s.date = "2022-02-22"
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 = [
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
+ ".github/workflows/ci.yml",
23
24
  ".rspec",
24
25
  ".ruby-gemset",
25
26
  ".ruby-version",
26
- ".travis.yml",
27
27
  "Gemfile",
28
28
  "LICENSE.txt",
29
29
  "README.md",
@@ -33,19 +33,16 @@ Gem::Specification.new do |s|
33
33
  "lib/tokyo_api.rb",
34
34
  "lib/tokyo_api/actionkit.rb",
35
35
  "lib/tokyo_api/base.rb",
36
- "lib/tokyo_api/bluestatedigital.rb",
37
36
  "lib/tokyo_api/campact.rb",
38
37
  "lib/tokyo_api/client.rb",
39
38
  "lib/tokyo_api/expire.rb",
40
39
  "lib/tokyo_api/identity.rb",
41
40
  "spec/actionkit_spec.rb",
42
- "spec/bluestatedigital_spec.rb",
43
41
  "spec/campact_spec.rb",
44
42
  "spec/client_spec.rb",
45
43
  "spec/expire_spec.rb",
46
44
  "spec/fixtures/expire/success",
47
45
  "spec/fixtures/responses/actionkit/full_user_success",
48
- "spec/fixtures/responses/bluestatedigital/full_user_success",
49
46
  "spec/fixtures/responses/campact/full_user_success",
50
47
  "spec/fixtures/responses/full_user_error",
51
48
  "spec/fixtures/responses/full_user_success",
@@ -58,34 +55,29 @@ Gem::Specification.new do |s|
58
55
  ]
59
56
  s.homepage = "http://github.com/controlshift/tokyo_api".freeze
60
57
  s.licenses = ["MIT".freeze]
61
- s.rubygems_version = "3.0.8".freeze
58
+ s.rubygems_version = "3.2.32".freeze
62
59
  s.summary = "Ruby API Wrapper for Tokyo CRM service".freeze
63
60
 
64
61
  if s.respond_to? :specification_version then
65
62
  s.specification_version = 4
63
+ end
66
64
 
67
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
- s.add_runtime_dependency(%q<vertebrae>.freeze, ["~> 0.5.1"])
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"])
74
- else
75
- s.add_dependency(%q<vertebrae>.freeze, ["~> 0.5.1"])
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"])
81
- end
65
+ if s.respond_to? :add_runtime_dependency then
66
+ s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
67
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
68
+ s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
69
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
70
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
71
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
72
+ s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
82
73
  else
83
- s.add_dependency(%q<vertebrae>.freeze, ["~> 0.5.1"])
84
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
85
- s.add_dependency(%q<webmock>.freeze, [">= 0"])
86
- s.add_dependency(%q<byebug>.freeze, [">= 0"])
74
+ s.add_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
87
75
  s.add_dependency(%q<bundler>.freeze, [">= 0"])
76
+ s.add_dependency(%q<byebug>.freeze, [">= 0"])
88
77
  s.add_dependency(%q<juwelier>.freeze, [">= 0"])
78
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
79
+ s.add_dependency(%q<rubocop>.freeze, [">= 0"])
80
+ s.add_dependency(%q<webmock>.freeze, [">= 0"])
89
81
  end
90
82
  end
91
83
 
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokyo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vertebrae
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.1
19
+ version: 0.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.5.1
26
+ version: 0.6.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: webmock
42
+ name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: byebug
56
+ name: juwelier
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: juwelier
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -103,10 +117,10 @@ extra_rdoc_files:
103
117
  - README.md
104
118
  files:
105
119
  - ".document"
120
+ - ".github/workflows/ci.yml"
106
121
  - ".rspec"
107
122
  - ".ruby-gemset"
108
123
  - ".ruby-version"
109
- - ".travis.yml"
110
124
  - Gemfile
111
125
  - LICENSE.txt
112
126
  - README.md
@@ -116,19 +130,16 @@ files:
116
130
  - lib/tokyo_api.rb
117
131
  - lib/tokyo_api/actionkit.rb
118
132
  - lib/tokyo_api/base.rb
119
- - lib/tokyo_api/bluestatedigital.rb
120
133
  - lib/tokyo_api/campact.rb
121
134
  - lib/tokyo_api/client.rb
122
135
  - lib/tokyo_api/expire.rb
123
136
  - lib/tokyo_api/identity.rb
124
137
  - spec/actionkit_spec.rb
125
- - spec/bluestatedigital_spec.rb
126
138
  - spec/campact_spec.rb
127
139
  - spec/client_spec.rb
128
140
  - spec/expire_spec.rb
129
141
  - spec/fixtures/expire/success
130
142
  - spec/fixtures/responses/actionkit/full_user_success
131
- - spec/fixtures/responses/bluestatedigital/full_user_success
132
143
  - spec/fixtures/responses/campact/full_user_success
133
144
  - spec/fixtures/responses/full_user_error
134
145
  - spec/fixtures/responses/full_user_success
@@ -157,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
168
  - !ruby/object:Gem::Version
158
169
  version: '0'
159
170
  requirements: []
160
- rubygems_version: 3.0.8
171
+ rubygems_version: 3.2.32
161
172
  signing_key:
162
173
  specification_version: 4
163
174
  summary: Ruby API Wrapper for Tokyo CRM service
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "2.3.3"
@@ -1,19 +0,0 @@
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/#{url_escape(id)}").body
9
- end
10
-
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
17
- end
18
- end
19
- end
@@ -1,58 +0,0 @@
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
- expect(subject.bluestatedigital.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) { '/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 return an error message' do
26
- expect(subject.bluestatedigital.full_user('1')).to eq({'error' => 'Connection refused'})
27
- end
28
- end
29
-
30
- describe 'success' do
31
- let(:body) { fixture('responses/bluestatedigital/full_user_success') }
32
-
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' })
37
- end
38
- end
39
- end
40
-
41
- describe 'tokyo_blue_state_digital_user_path' do
42
- context 'without required_fields' 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')).to eq('/bluestatedigital/constituent/-123456')
45
- end
46
- end
47
-
48
- context 'with required_fields' 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', 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')
55
- end
56
- end
57
- end
58
- end
@@ -1 +0,0 @@
1
- {"first_name":"Homer","last_name":"Simpson","city":"Springfield","state":"YZ","country":"US","postal":"12345","email":"foo@bar.com"}