tokyo_api 1.9.0 → 1.11.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: bfc6a2a8d61d454b3c1a7f4768dc0e9dab131495fbaf3b0ed9c8f8c8ad6aa447
4
- data.tar.gz: 6e238d49fdb49d5e39cc0eaffb07b77bfd228e102229ddc8bcc060558eb9b04b
3
+ metadata.gz: 49f134a22279a6c8b11904a1514b8e29fdaf5e18c7af790b6ce1cdaeb1104339
4
+ data.tar.gz: d883c100f0e091564b62f74899b66d48f4b3464fbf5c89b2ac773f19851ea7bc
5
5
  SHA512:
6
- metadata.gz: f3e73888127a00603e3e2905c15ca0b396da6ad3faacd3ecb693a2fbb3b41041032b872746ee8332841efb57d374007426ec3e0c557893e6836e08c800006b2f
7
- data.tar.gz: 791852faa2ae959db274440d8d5e42dd1391ad41c22a0bc114cbdea1a598a44b4f5a52d121af4a409666d3ebf6522bdd57f6dac8492e91b611d67a385632f23a
6
+ metadata.gz: 306e4c05d68345f4bc18864fdf095a7a099a4d0d8a6dae384a8dcff25be52638f48370b56d278a2e7eb6360d4dd9f2a31c3a7067ba0c12f3433e1c550219c94f
7
+ data.tar.gz: db5710196204365696229a2b81a4743950eacd2773709d030223934086698545e793669928df896214d3e6a9db99acfcdacf1350b854a956bffd503fe8835dd5
@@ -4,11 +4,22 @@ on: [push]
4
4
  jobs:
5
5
  test:
6
6
  runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby-version: ['3.3', '3.4', '4.0']
7
10
  steps:
8
- - uses: actions/checkout@v2
9
- - uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
11
+ - uses: actions/checkout@v4
12
+ - uses: ruby/setup-ruby@v1
10
13
  with:
11
- ruby-version: 2.7
14
+ ruby-version: ${{ matrix.ruby-version }}
12
15
  bundler-cache: true
13
- - run: bundle install
14
16
  - run: bundle exec rspec
17
+ rubocop:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '4.0'
24
+ bundler-cache: true
25
+ - run: bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,53 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+ Gemfile.lock
15
+
16
+ # jeweler generated
17
+ pkg
18
+
19
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
+ #
21
+ # * Create a file at ~/.gitignore
22
+ # * Include files you want ignored
23
+ # * Run: git config --global core.excludesfile ~/.gitignore
24
+ #
25
+ # After doing this, these files will be ignored in all your git projects,
26
+ # saving you from having to 'pollute' every project you touch with them
27
+ #
28
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
29
+ #
30
+ # For MacOS:
31
+ #
32
+ .DS_Store
33
+
34
+ # For TextMate
35
+ #*.tmproj
36
+ #tmtags
37
+
38
+ # For emacs:
39
+ #*~
40
+ #\#*
41
+ #.\#*
42
+
43
+ # For vim:
44
+ #*.swp
45
+
46
+ # For redcar:
47
+ #.redcar
48
+
49
+ # For rubinius:
50
+ #*.rbc
51
+ .idea
52
+
53
+ .vscode
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ DisabledByDefault: true
3
+
4
+ Security:
5
+ Enabled: true
6
+
7
+ Bundler/DuplicatedGem:
8
+ Enabled: true
9
+ Bundler/InsecureProtocolSource:
10
+ Enabled: true
11
+ Layout/IndentationStyle:
12
+ Enabled: true
13
+ Layout/SpaceInsideRangeLiteral:
14
+ Enabled: true
15
+ Lint:
16
+ Enabled: true
17
+ Naming/AsciiIdentifiers:
18
+ Enabled: true
19
+ Naming/ClassAndModuleCamelCase:
20
+ Enabled: true
21
+ Naming/ConstantName:
22
+ Enabled: true
23
+ Naming/FileName:
24
+ Enabled: true
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 4.0.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## [1.11.0] - 2026-02-11
4
+
5
+ ### Breaking Changes
6
+ - Now requires Faraday 2.x (previously supported Faraday 1.x)
7
+ - Dropped support for Ruby versions older than 3.3. Officially supported versions are Ruby 3.3, 3.4, and 4.0.
data/Gemfile CHANGED
@@ -1,16 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'http://rubygems.org'
3
+ source 'https://rubygems.org'
4
4
 
5
- gem 'vertebrae', '< 1'
6
-
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem 'bundler'
11
- gem 'byebug'
12
- gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
13
- gem 'rspec'
14
- gem 'rubocop'
15
- gem 'webmock'
16
- end
5
+ # Specify your gem's dependencies in tokyo_api.gemspec
6
+ gemspec
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  A ruby gem for communicating with ControlShift's Tokyo API.
4
4
 
5
+ ## Requirements
6
+
7
+ - Ruby 3.3, 3.4, or 4.0
8
+ - Faraday ~> 2.0
9
+
5
10
  [![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
11
 
7
12
  ## Usage
data/Rakefile CHANGED
@@ -1,49 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- warn e.message
9
- warn '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'
3
+ require 'bundler/gem_tasks'
29
4
  require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
32
- end
33
5
 
34
- RSpec::Core::RakeTask.new(:rcov) do |spec|
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
6
+ RSpec::Core::RakeTask.new(:spec)
38
7
 
39
8
  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 CHANGED
@@ -1 +1 @@
1
- 1.9.0
1
+ 1.11.0
data/example.rb CHANGED
@@ -7,4 +7,4 @@ require 'tokyo_api'
7
7
  ta = TokyoApi.new(host: 'localhost:9000', username: 'tokyo', password: 'Passw0rd!', scheme: 'http')
8
8
 
9
9
  require 'pry-debugger'
10
- binding.pry
10
+ binding.pry # rubocop:disable Lint/Debugger
@@ -34,6 +34,10 @@ module TokyoApi
34
34
  path
35
35
  end
36
36
 
37
+ def update_prefill_forms_path(session_id)
38
+ String.new("/#{normalized_base_path}user/#{url_escape(session_id)}/prefill_forms")
39
+ end
40
+
37
41
  def subscription_status_path(token)
38
42
  "/#{normalized_base_path}subscription_status/#{url_escape(token)}"
39
43
  end
@@ -57,21 +57,19 @@ module TokyoApi
57
57
  end
58
58
 
59
59
  def setup
60
- connection.stack do |builder|
61
- builder.use Faraday::Request::Multipart
62
- builder.use Faraday::Request::UrlEncoded
60
+ connection.faraday_connection = Faraday.new(connection.configuration.faraday_options) do |f|
61
+ f.request :multipart
62
+ f.request :url_encoded
63
63
  if connection.configuration.authenticated?
64
- builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
65
- connection.configuration.password
64
+ f.request :authorization, :basic, connection.configuration.username, connection.configuration.password
66
65
  end
67
66
 
68
- builder.use Faraday::Response::Logger if ENV['DEBUG']
67
+ f.response :logger if ENV['DEBUG']
68
+ f.response :mashify
69
+ f.response :json
69
70
 
70
- builder.use FaradayMiddleware::Mashify
71
- builder.use FaradayMiddleware::ParseJson
72
-
73
- builder.use Vertebrae::Response::RaiseError
74
- builder.adapter connection.configuration.adapter
71
+ f.use Vertebrae::Response::RaiseError
72
+ f.adapter connection.configuration.adapter
75
73
  end
76
74
  end
77
75
  end
data/lib/tokyo_api.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'vertebrae'
4
+ require 'faraday/mashify'
4
5
  require 'tokyo_api/base'
5
6
  require 'tokyo_api/actionkit'
6
7
  require 'tokyo_api/campact'
data/tokyo_api.gemspec CHANGED
@@ -1,85 +1,38 @@
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 1.9.0 ruby lib
1
+ # frozen_string_literal: true
6
2
 
7
- Gem::Specification.new do |s|
8
- s.name = "tokyo_api".freeze
9
- s.version = "1.9.0"
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
10
5
 
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 = "2023-09-28"
15
- s.description = "Tokyo is a CRM middleware, this gem helps apps talk to it.".freeze
16
- s.email = "nathan@controlshiftlabs.com".freeze
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".github/workflows/ci.yml",
24
- ".rspec",
25
- ".ruby-gemset",
26
- ".ruby-version",
27
- "Gemfile",
28
- "LICENSE.txt",
29
- "README.md",
30
- "Rakefile",
31
- "VERSION",
32
- "example.rb",
33
- "lib/tokyo_api.rb",
34
- "lib/tokyo_api/actionkit.rb",
35
- "lib/tokyo_api/base.rb",
36
- "lib/tokyo_api/campact.rb",
37
- "lib/tokyo_api/client.rb",
38
- "lib/tokyo_api/expire.rb",
39
- "lib/tokyo_api/external_image.rb",
40
- "lib/tokyo_api/identity.rb",
41
- "spec/actionkit_spec.rb",
42
- "spec/campact_spec.rb",
43
- "spec/client_spec.rb",
44
- "spec/expire_spec.rb",
45
- "spec/external_image_spec.rb",
46
- "spec/fixtures/expire/success",
47
- "spec/fixtures/responses/actionkit/full_user_success",
48
- "spec/fixtures/responses/campact/full_user_success",
49
- "spec/fixtures/responses/full_user_error",
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",
54
- "spec/spec_helper.rb",
55
- "spec/tokyo_api_spec.rb",
56
- "tokyo_api.gemspec"
57
- ]
58
- s.homepage = "http://github.com/controlshift/tokyo_api".freeze
59
- s.licenses = ["MIT".freeze]
60
- s.rubygems_version = "3.3.19".freeze
61
- s.summary = "Ruby API Wrapper for Tokyo CRM service".freeze
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'tokyo_api'
8
+ spec.version = File.read(File.expand_path('VERSION', __dir__)).strip
9
+ spec.authors = ['Nathan Woodhull', 'Owens Ehimen', 'Grey Moore', 'Diego Marcet']
10
+ spec.email = ['talk@controlshiftlabs.com']
62
11
 
63
- if s.respond_to? :specification_version then
64
- s.specification_version = 4
65
- end
12
+ spec.summary = 'Ruby API Wrapper for Tokyo CRM service'
13
+ spec.description = 'Tokyo is a CRM middleware, this gem helps apps talk to it.'
14
+ spec.homepage = 'https://github.com/controlshift/tokyo_api'
15
+ spec.license = 'MIT'
66
16
 
67
- if s.respond_to? :add_runtime_dependency then
68
- s.add_runtime_dependency(%q<vertebrae>.freeze, ["< 1"])
69
- s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
70
- s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
71
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
72
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
73
- s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
74
- s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
75
- else
76
- s.add_dependency(%q<vertebrae>.freeze, ["< 1"])
77
- s.add_dependency(%q<bundler>.freeze, [">= 0"])
78
- s.add_dependency(%q<byebug>.freeze, [">= 0"])
79
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
80
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
81
- s.add_dependency(%q<rubocop>.freeze, [">= 0"])
82
- s.add_dependency(%q<webmock>.freeze, [">= 0"])
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
83
19
  end
84
- end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = ['>= 3.3', '< 5.0']
85
23
 
24
+ # Runtime dependencies
25
+ spec.add_runtime_dependency 'vertebrae', '~> 1.0'
26
+ spec.add_runtime_dependency 'faraday', '~> 2.0'
27
+ spec.add_runtime_dependency 'faraday-mashify', '~> 1.0'
28
+
29
+ # Development dependencies
30
+ spec.add_development_dependency 'bundler', '>= 2.0', '< 5.0'
31
+ spec.add_development_dependency 'byebug', '~> 13.0'
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'rubocop', '~> 1.0'
35
+ spec.add_development_dependency 'webmock', '~> 3.0'
36
+
37
+ spec.metadata['rubygems_mfa_required'] = 'true'
38
+ end
metadata CHANGED
@@ -1,126 +1,164 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokyo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
- autorequire:
8
+ - Owens Ehimen
9
+ - Grey Moore
10
+ - Diego Marcet
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2023-09-28 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: vertebrae
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
- - - "<"
19
+ - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: '1'
21
+ version: '1.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - "<"
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: faraday
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: faraday-mashify
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
25
55
  - !ruby/object:Gem::Version
26
- version: '1'
56
+ version: '1.0'
27
57
  - !ruby/object:Gem::Dependency
28
58
  name: bundler
29
59
  requirement: !ruby/object:Gem::Requirement
30
60
  requirements:
31
61
  - - ">="
32
62
  - !ruby/object:Gem::Version
33
- version: '0'
63
+ version: '2.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.0'
34
67
  type: :development
35
68
  prerelease: false
36
69
  version_requirements: !ruby/object:Gem::Requirement
37
70
  requirements:
38
71
  - - ">="
39
72
  - !ruby/object:Gem::Version
40
- version: '0'
73
+ version: '2.0'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '5.0'
41
77
  - !ruby/object:Gem::Dependency
42
78
  name: byebug
43
79
  requirement: !ruby/object:Gem::Requirement
44
80
  requirements:
45
- - - ">="
81
+ - - "~>"
46
82
  - !ruby/object:Gem::Version
47
- version: '0'
83
+ version: '13.0'
48
84
  type: :development
49
85
  prerelease: false
50
86
  version_requirements: !ruby/object:Gem::Requirement
51
87
  requirements:
52
- - - ">="
88
+ - - "~>"
53
89
  - !ruby/object:Gem::Version
54
- version: '0'
90
+ version: '13.0'
55
91
  - !ruby/object:Gem::Dependency
56
- name: juwelier
92
+ name: rake
57
93
  requirement: !ruby/object:Gem::Requirement
58
94
  requirements:
59
- - - ">="
95
+ - - "~>"
60
96
  - !ruby/object:Gem::Version
61
- version: '0'
97
+ version: '13.0'
62
98
  type: :development
63
99
  prerelease: false
64
100
  version_requirements: !ruby/object:Gem::Requirement
65
101
  requirements:
66
- - - ">="
102
+ - - "~>"
67
103
  - !ruby/object:Gem::Version
68
- version: '0'
104
+ version: '13.0'
69
105
  - !ruby/object:Gem::Dependency
70
106
  name: rspec
71
107
  requirement: !ruby/object:Gem::Requirement
72
108
  requirements:
73
- - - ">="
109
+ - - "~>"
74
110
  - !ruby/object:Gem::Version
75
- version: '0'
111
+ version: '3.0'
76
112
  type: :development
77
113
  prerelease: false
78
114
  version_requirements: !ruby/object:Gem::Requirement
79
115
  requirements:
80
- - - ">="
116
+ - - "~>"
81
117
  - !ruby/object:Gem::Version
82
- version: '0'
118
+ version: '3.0'
83
119
  - !ruby/object:Gem::Dependency
84
120
  name: rubocop
85
121
  requirement: !ruby/object:Gem::Requirement
86
122
  requirements:
87
- - - ">="
123
+ - - "~>"
88
124
  - !ruby/object:Gem::Version
89
- version: '0'
125
+ version: '1.0'
90
126
  type: :development
91
127
  prerelease: false
92
128
  version_requirements: !ruby/object:Gem::Requirement
93
129
  requirements:
94
- - - ">="
130
+ - - "~>"
95
131
  - !ruby/object:Gem::Version
96
- version: '0'
132
+ version: '1.0'
97
133
  - !ruby/object:Gem::Dependency
98
134
  name: webmock
99
135
  requirement: !ruby/object:Gem::Requirement
100
136
  requirements:
101
- - - ">="
137
+ - - "~>"
102
138
  - !ruby/object:Gem::Version
103
- version: '0'
139
+ version: '3.0'
104
140
  type: :development
105
141
  prerelease: false
106
142
  version_requirements: !ruby/object:Gem::Requirement
107
143
  requirements:
108
- - - ">="
144
+ - - "~>"
109
145
  - !ruby/object:Gem::Version
110
- version: '0'
146
+ version: '3.0'
111
147
  description: Tokyo is a CRM middleware, this gem helps apps talk to it.
112
- email: nathan@controlshiftlabs.com
148
+ email:
149
+ - talk@controlshiftlabs.com
113
150
  executables: []
114
151
  extensions: []
115
- extra_rdoc_files:
116
- - LICENSE.txt
117
- - README.md
152
+ extra_rdoc_files: []
118
153
  files:
119
154
  - ".document"
120
155
  - ".github/workflows/ci.yml"
156
+ - ".gitignore"
121
157
  - ".rspec"
158
+ - ".rubocop.yml"
122
159
  - ".ruby-gemset"
123
160
  - ".ruby-version"
161
+ - CHANGELOG.md
124
162
  - Gemfile
125
163
  - LICENSE.txt
126
164
  - README.md
@@ -135,27 +173,12 @@ files:
135
173
  - lib/tokyo_api/expire.rb
136
174
  - lib/tokyo_api/external_image.rb
137
175
  - lib/tokyo_api/identity.rb
138
- - spec/actionkit_spec.rb
139
- - spec/campact_spec.rb
140
- - spec/client_spec.rb
141
- - spec/expire_spec.rb
142
- - spec/external_image_spec.rb
143
- - spec/fixtures/expire/success
144
- - spec/fixtures/responses/actionkit/full_user_success
145
- - spec/fixtures/responses/campact/full_user_success
146
- - spec/fixtures/responses/full_user_error
147
- - spec/fixtures/responses/full_user_success
148
- - spec/fixtures/responses/identity/full_user_success
149
- - spec/fixtures/responses/krautbuster/full_user_success
150
- - spec/identity_spec.rb
151
- - spec/spec_helper.rb
152
- - spec/tokyo_api_spec.rb
153
176
  - tokyo_api.gemspec
154
- homepage: http://github.com/controlshift/tokyo_api
177
+ homepage: https://github.com/controlshift/tokyo_api
155
178
  licenses:
156
179
  - MIT
157
- metadata: {}
158
- post_install_message:
180
+ metadata:
181
+ rubygems_mfa_required: 'true'
159
182
  rdoc_options: []
160
183
  require_paths:
161
184
  - lib
@@ -163,15 +186,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
186
  requirements:
164
187
  - - ">="
165
188
  - !ruby/object:Gem::Version
166
- version: '0'
189
+ version: '3.3'
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: '5.0'
167
193
  required_rubygems_version: !ruby/object:Gem::Requirement
168
194
  requirements:
169
195
  - - ">="
170
196
  - !ruby/object:Gem::Version
171
197
  version: '0'
172
198
  requirements: []
173
- rubygems_version: 3.3.19
174
- signing_key:
199
+ rubygems_version: 4.0.3
175
200
  specification_version: 4
176
201
  summary: Ruby API Wrapper for Tokyo CRM service
177
202
  test_files: []
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::Actionkit do
6
- subject { TokyoApi.new(host: 'test.com') }
7
-
8
- describe 'configuration' do
9
- it 'should propagate the host' do
10
- expect(subject.actionkit.client.connection.configuration.host).to eq('test.com')
11
- end
12
- end
13
-
14
- describe 'full_user' do
15
- let(:body) { fixture('responses/full_user_success') }
16
- let(:request_path) { '/actionkit/full_user/1' }
17
- let(:status) { 200 }
18
-
19
- before(:each) do
20
- stub_get(request_path).to_return(body: body, status: status,
21
- headers: { content_type: 'application/json; charset=utf-8' })
22
- end
23
-
24
- describe 'error' do
25
- let(:body) { fixture('responses/full_user_error') }
26
-
27
- it 'should return an error hash' do
28
- expect(subject.actionkit.full_user('1')).to eq({ 'error' => 'Connection refused' })
29
- end
30
- end
31
-
32
- describe 'success' do
33
- let(:body) { fixture('responses/actionkit/full_user_success') }
34
-
35
- it 'should return a user message' do
36
- expect(subject.actionkit.full_user('1')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
37
- 'city' => 'Springfield', 'state' => 'YZ', 'country' => 'US',
38
- 'extra_field' => 'hidden extra field', 'email' => 'foo@bar.com' })
39
- end
40
- end
41
-
42
- describe 'user_path' do
43
- context 'without required_fields' do
44
- it 'should return relative path to user API endpoint' do
45
- expect(subject.actionkit.user_path('abc.123.xyz')).to eq('/actionkit/user/abc.123.xyz')
46
- end
47
- end
48
-
49
- context 'with required_fields' do
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')
54
- end
55
-
56
- it 'should url-escape field names with weird characters' do
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')
60
- end
61
- end
62
- end
63
- end
64
- end
data/spec/campact_spec.rb DELETED
@@ -1,167 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::Campact do
6
- subject { TokyoApi.new(host: 'test.com') }
7
-
8
- describe 'configuration' do
9
- it 'should propagate the host' do
10
- expect(subject.campact.client.connection.configuration.host).to eq 'test.com'
11
- end
12
- end
13
-
14
- describe '#full_user' do
15
- let(:body) { fixture('responses/full_user_success') }
16
- let(:request_path) { '/campact/full_user/123abc456' }
17
- let(:status) { 200 }
18
-
19
- before(:each) do
20
- stub_get(request_path).to_return(body: body, status: status,
21
- headers: { content_type: 'application/json; charset=utf-8' })
22
- end
23
-
24
- describe 'error' do
25
- let(:body) { fixture('responses/full_user_error') }
26
-
27
- it 'should return an error message' do
28
- expect(subject.campact.full_user('123abc456')).to eq({ 'error' => 'Connection refused' })
29
- end
30
- end
31
-
32
- describe 'success' do
33
- let(:body) { fixture('responses/campact/full_user_success') }
34
-
35
- it 'should find an organisation' do
36
- expect(subject.campact.full_user('123abc456')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
37
- 'country' => 'DE', 'postal' => '12345', 'email' => 'foo@bar.com' })
38
- end
39
- end
40
- end
41
-
42
- describe '#subscription_status' do
43
- let(:client) { double }
44
- let(:token) { '2134567890abcdef' }
45
-
46
- subject { TokyoApi::Campact.new(client: client) }
47
-
48
- before :each do
49
- expect(subject).to receive(:subscription_status_path).with(token).and_return("/campact/subscription_status?token=#{token}")
50
- end
51
-
52
- it 'should perform request on subscription_status_path' do
53
- expect(client).to receive(:get_request).with("/campact/subscription_status?token=#{token}").and_return(double(body: { subscribed: true }))
54
-
55
- subs_status = subject.subscription_status(token)
56
-
57
- expect(subs_status).to eq({ subscribed: true })
58
- end
59
-
60
- it 'should return nil if tokyo responds with 404' do
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
- ))
66
-
67
- subs_status = subject.subscription_status(token)
68
-
69
- expect(subs_status).to be_nil
70
- end
71
-
72
- it 'should raise if tokyo responds with other error code' do
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
- ))
77
-
78
- expect { subject.subscription_status(token) }.to raise_error Vertebrae::ResponseError
79
- end
80
- end
81
-
82
- describe '#user_path' do
83
- context 'without required_fields' do
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'
87
- end
88
- end
89
-
90
- context 'with required_fields' do
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'
94
- end
95
-
96
- it 'should url-escape field names with weird characters' do
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'
99
- end
100
- end
101
-
102
- context 'with_subscription_status argument' do
103
- it 'should not include query string parameter if argument is missing' do
104
- expect(subject.campact.user_path('123abc456',
105
- petition_id: 'save-the-trees')).not_to match(/.+with_subscription_status=.+/)
106
- end
107
-
108
- it 'should not include query string parameter if argument is false' do
109
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
110
- with_subscription_status: false)).not_to match(/.+with_subscription_status=.+/)
111
- end
112
-
113
- it 'should include query string parameter if argument is true' do
114
- expect(subject.campact.user_path('123abc456', petition_id: 'save-the-trees',
115
- with_subscription_status: true)).to match(/.+with_subscription_status=true.*/)
116
- end
117
- end
118
- end
119
-
120
- describe '#subscription_status_path' do
121
- subject { TokyoApi::Campact.new }
122
-
123
- it 'should return correct path' do
124
- expect(subject.subscription_status_path('abc123')).to eq '/campact/subscription_status/abc123'
125
- end
126
- end
127
-
128
- describe '#session_status' do
129
- let(:client) { double }
130
- let(:session_id) { '123456789abcdef' }
131
-
132
- subject { TokyoApi::Campact.new(client: client) }
133
-
134
- it 'should perform request on session status path' do
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
- }))
138
-
139
- session_status = subject.session_status(session_id)
140
-
141
- expect(session_status).to eq({ hard_login: false, soft_login: true })
142
- end
143
- end
144
-
145
- describe '#destroy_session' do
146
- let(:client) { double }
147
- let(:session_id) { '123456789abcdef' }
148
-
149
- subject { TokyoApi::Campact.new(client: client) }
150
-
151
- it 'should perform request on session status path' do
152
- expect(client).to receive(:delete_request).with("/campact/session/#{session_id}").and_return(double(status: 204))
153
-
154
- result = subject.destroy_session(session_id)
155
-
156
- expect(result).to be_truthy
157
- end
158
-
159
- it 'should return false if response status is 404' do
160
- expect(client).to receive(:delete_request).with("/campact/session/#{session_id}").and_return(double(status: 404))
161
-
162
- result = subject.destroy_session(session_id)
163
-
164
- expect(result).to be_falsey
165
- end
166
- end
167
- end
data/spec/client_spec.rb DELETED
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::Client do
6
- describe 'initialisation' do
7
- subject { described_class.new(options) }
8
-
9
- context 'with a basic_auth string parameter' do
10
- let(:options) { { basic_auth: 'login:password' } }
11
-
12
- it 'should set username/password on the configuration' do
13
- config = subject.connection.configuration
14
- expect(config.username).to eq 'login'
15
- expect(config.password).to eq 'password'
16
- end
17
- end
18
-
19
- context 'with a timeout' do
20
- let(:options) { { timeout: 5 } }
21
-
22
- it 'should set the timeout on the faraday options' do
23
- config = subject.connection.configuration
24
- expect(config.faraday_options[:request][:timeout]).to eq 5
25
- end
26
- end
27
- end
28
- end
data/spec/expire_spec.rb DELETED
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::Expire do
6
- subject { TokyoApi.new(host: 'test.com') }
7
-
8
- describe 'expire organisation' do
9
- let(:body) { fixture('expire/success') }
10
- let(:request_path) { '/expire/organisation/foo.com' }
11
-
12
- before(:each) do
13
- stub_get(request_path).to_return(body: body, status: status,
14
- headers: { content_type: 'application/json; charset=utf-8' })
15
- end
16
-
17
- describe 'success' do
18
- let(:status) { 200 }
19
-
20
- it 'should find an organisation' do
21
- expect(subject.expire.organisation('foo.com')).to eq({ 'status' => 'success' })
22
- end
23
- end
24
- end
25
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::ExternalImage do
6
- subject { TokyoApi.new(host: 'test.com') }
7
-
8
- describe '#track_download' do
9
- let(:photo_id) { 'abcde-123456' }
10
- let(:request_path) { "/external_image/#{photo_id}/download" }
11
-
12
- before(:each) do
13
- stub_post(request_path).to_return(body: body, status: status,
14
- headers: { content_type: 'application/json; charset=utf-8' })
15
- end
16
-
17
- context 'error on tokyo' do
18
- let(:status) { 500 }
19
- let(:body) { {status: :error}.to_json }
20
-
21
- it 'should raise error' do
22
- expect { subject.external_image.track_download(photo_id) }.to raise_error(Vertebrae::ResponseError)
23
- end
24
- end
25
-
26
- context 'successful call to tokyo' do
27
- let(:status) { 204 }
28
- let(:body) { nil }
29
-
30
- it 'should return true' do
31
- result = subject.external_image.track_download(photo_id)
32
-
33
- expect(result).to be_truthy
34
- end
35
- end
36
- end
37
- end
@@ -1 +0,0 @@
1
- {"status":"success"}
@@ -1 +0,0 @@
1
- {"first_name":"Homer","last_name":"Simpson","city":"Springfield","state":"YZ","country":"US","extra_field":"hidden extra field","email":"foo@bar.com"}
@@ -1 +0,0 @@
1
- {"first_name":"Homer","last_name":"Simpson","country":"DE","postal":"12345","email":"foo@bar.com"}
@@ -1 +0,0 @@
1
- {"error":"Connection refused"}
File without changes
@@ -1 +0,0 @@
1
- {"first_name":"Homer","last_name":"Simpson","country":"GB","postal":"12345","email":"foo@bar.com"}
@@ -1 +0,0 @@
1
- {"first_name":"Homer","last_name":"Simpson","country":"DE","postal":"12345","email":"foo@bar.com"}
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi::Identity do
6
- subject { TokyoApi.new(host: 'test.com') }
7
-
8
- describe 'configuration' do
9
- it 'should propagate the host' do
10
- expect(subject.identity.client.connection.configuration.host).to eq('test.com')
11
- end
12
- end
13
-
14
- describe 'full_user' do
15
- let(:body) { fixture('responses/full_user_success') }
16
- let(:request_path) { '/identity/full_user/1' }
17
- let(:status) { 200 }
18
-
19
- before(:each) do
20
- stub_get(request_path).to_return(body: body, status: status,
21
- headers: { content_type: 'application/json; charset=utf-8' })
22
- end
23
-
24
- describe 'error' do
25
- let(:body) { fixture('responses/full_user_error') }
26
-
27
- it 'should return an error hash' do
28
- expect(subject.identity.full_user('1')).to eq({ 'error' => 'Connection refused' })
29
- end
30
- end
31
-
32
- describe 'success' do
33
- let(:body) { fixture('responses/identity/full_user_success') }
34
-
35
- it 'should return a hash' do
36
- expect(subject.identity.full_user('1')).to eq({ 'first_name' => 'Homer', 'last_name' => 'Simpson',
37
- 'country' => 'GB', 'postal' => '12345', 'email' => 'foo@bar.com' })
38
- end
39
- end
40
- end
41
-
42
- describe 'tokyo_identity_user_path' do
43
- context 'without required_fields' do
44
- it 'should return rooted relative path to tokyo user API endpoint' do
45
- expect(subject.identity.tokyo_identity_user_path('-123456')).to eq('/identity/user/-123456')
46
- end
47
- end
48
-
49
- context 'with required_fields' do
50
- it 'should return rooted relative path to tokyo user API endpoint' do
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')
54
- end
55
-
56
- it 'should url-escape field names with weird characters' do
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')
60
- end
61
- end
62
-
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
66
-
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')
73
-
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
77
- end
78
- end
79
-
80
- describe '#subscription_status_path' do
81
- it 'should raise if neither param provided' do
82
- expect { subject.identity.subscription_status_path('abc123') }.to raise_error(RuntimeError)
83
- end
84
-
85
- it 'should return correct path for a list of public ids' do
86
- expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5%2Cpolicy-1.6'
87
- expect(subject.identity.subscription_status_path('abc123',
88
- opt_in_public_ids: ['policy-1.5',
89
- 'policy-1.6'])).to eq expected_path
90
- end
91
-
92
- it 'should support minimum_consent_level' do
93
- expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5&minimum_consent_level=explicit'
94
- expect(subject.identity.subscription_status_path('abc123', opt_in_public_ids: ['policy-1.5'],
95
- minimum_consent_level: 'explicit')).to eq expected_path
96
- end
97
-
98
- it 'should support encrypted param' do
99
- expected_path = '/identity/subscription_status/abc123?opt_in_public_ids=policy-1.5&minimum_consent_level=explicit&encrypted=1'
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
102
- end
103
- end
104
- end
data/spec/spec_helper.rb DELETED
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- require 'rspec'
6
- require 'webmock/rspec'
7
- require 'tokyo_api'
8
-
9
- # Requires supporting files with custom matchers and macros, etc,
10
- # in ./support/ and its subdirectories.
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
12
-
13
- RSpec.configure do |config|
14
- config.include WebMock::API
15
- config.color = true
16
- # config.raise_errors_for_deprecations!
17
- end
18
-
19
- def stub_get(path)
20
- stub_tokyo_request(:get, path)
21
- end
22
-
23
- def stub_post(path)
24
- stub_tokyo_request(:post, path)
25
- end
26
-
27
- def stub_tokyo_request(method, path)
28
- prefix = TokyoApi.new.connection.configuration.prefix.to_s
29
- scheme = TokyoApi.new.connection.configuration.scheme.to_s
30
- stub_request(method, "#{scheme}://test.com" + prefix + path)
31
- end
32
-
33
- def fixture_path
34
- File.expand_path('fixtures', __dir__)
35
- end
36
-
37
- def fixture(file)
38
- File.new(File.join(fixture_path, '/', file))
39
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
4
-
5
- describe TokyoApi do
6
- before(:each) do
7
- allow(TokyoApi::Client).to receive(:setup_client)
8
- end
9
- specify { expect(subject).to respond_to :actionkit }
10
- specify { expect(subject.new).to be_a(TokyoApi::Client) }
11
- end