tokyo_api 1.10.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: 6a6f675e1943c05d41a71cbfc51d58396b2dc50d1505ab25fa4b0806168a0c27
4
- data.tar.gz: b40f2fc82b64e8f62a1d9ca1a24d340d18ad7ccfd6d589e5aee22338826bce6c
3
+ metadata.gz: 49f134a22279a6c8b11904a1514b8e29fdaf5e18c7af790b6ce1cdaeb1104339
4
+ data.tar.gz: d883c100f0e091564b62f74899b66d48f4b3464fbf5c89b2ac773f19851ea7bc
5
5
  SHA512:
6
- metadata.gz: b5c512e1e56b7bf071f7e8cc4f081c9ee6cbc845d9fd7818b58d0fc6a53f80c7d231eccd44601ec0e84df856851404da935b6cc0592d47399e981fae6e12215d
7
- data.tar.gz: 61e09b3f2d6f74afcd2c7b287121d2c85f1a412a9e872aa7330571f57f0f50d16b66f2c307cfb9d7d69aafe9ea7cdb787f87d7062b4b6e9d0c5168b940b8f694
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
11
+ - uses: actions/checkout@v4
9
12
  - uses: ruby/setup-ruby@v1
10
13
  with:
11
- ruby-version: 3.4
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.4.5
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.10.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
@@ -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,73 +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.10.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.10.0".freeze
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 = "1980-01-02"
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.6.9".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
- s.specification_version = 4
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'
64
16
 
65
- s.add_runtime_dependency(%q<vertebrae>.freeze, ["< 1".freeze])
66
- s.add_development_dependency(%q<bundler>.freeze, [">= 0".freeze])
67
- s.add_development_dependency(%q<byebug>.freeze, [">= 0".freeze])
68
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0".freeze])
69
- s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
70
- s.add_development_dependency(%q<rubocop>.freeze, [">= 0".freeze])
71
- s.add_development_dependency(%q<webmock>.freeze, [">= 0".freeze])
72
- end
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)/}) }
19
+ end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = ['>= 3.3', '< 5.0']
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'
73
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,10 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokyo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
+ - Owens Ehimen
9
+ - Grey Moore
10
+ - Diego Marcet
8
11
  bindir: bin
9
12
  cert_chain: []
10
13
  date: 1980-01-02 00:00:00.000000000 Z
@@ -13,113 +16,149 @@ dependencies:
13
16
  name: vertebrae
14
17
  requirement: !ruby/object:Gem::Requirement
15
18
  requirements:
16
- - - "<"
19
+ - - "~>"
17
20
  - !ruby/object:Gem::Version
18
- version: '1'
21
+ version: '1.0'
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
22
25
  requirements:
23
- - - "<"
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
+ - - "~>"
24
55
  - !ruby/object:Gem::Version
25
- version: '1'
56
+ version: '1.0'
26
57
  - !ruby/object:Gem::Dependency
27
58
  name: bundler
28
59
  requirement: !ruby/object:Gem::Requirement
29
60
  requirements:
30
61
  - - ">="
31
62
  - !ruby/object:Gem::Version
32
- version: '0'
63
+ version: '2.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.0'
33
67
  type: :development
34
68
  prerelease: false
35
69
  version_requirements: !ruby/object:Gem::Requirement
36
70
  requirements:
37
71
  - - ">="
38
72
  - !ruby/object:Gem::Version
39
- version: '0'
73
+ version: '2.0'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '5.0'
40
77
  - !ruby/object:Gem::Dependency
41
78
  name: byebug
42
79
  requirement: !ruby/object:Gem::Requirement
43
80
  requirements:
44
- - - ">="
81
+ - - "~>"
45
82
  - !ruby/object:Gem::Version
46
- version: '0'
83
+ version: '13.0'
47
84
  type: :development
48
85
  prerelease: false
49
86
  version_requirements: !ruby/object:Gem::Requirement
50
87
  requirements:
51
- - - ">="
88
+ - - "~>"
52
89
  - !ruby/object:Gem::Version
53
- version: '0'
90
+ version: '13.0'
54
91
  - !ruby/object:Gem::Dependency
55
- name: juwelier
92
+ name: rake
56
93
  requirement: !ruby/object:Gem::Requirement
57
94
  requirements:
58
- - - ">="
95
+ - - "~>"
59
96
  - !ruby/object:Gem::Version
60
- version: '0'
97
+ version: '13.0'
61
98
  type: :development
62
99
  prerelease: false
63
100
  version_requirements: !ruby/object:Gem::Requirement
64
101
  requirements:
65
- - - ">="
102
+ - - "~>"
66
103
  - !ruby/object:Gem::Version
67
- version: '0'
104
+ version: '13.0'
68
105
  - !ruby/object:Gem::Dependency
69
106
  name: rspec
70
107
  requirement: !ruby/object:Gem::Requirement
71
108
  requirements:
72
- - - ">="
109
+ - - "~>"
73
110
  - !ruby/object:Gem::Version
74
- version: '0'
111
+ version: '3.0'
75
112
  type: :development
76
113
  prerelease: false
77
114
  version_requirements: !ruby/object:Gem::Requirement
78
115
  requirements:
79
- - - ">="
116
+ - - "~>"
80
117
  - !ruby/object:Gem::Version
81
- version: '0'
118
+ version: '3.0'
82
119
  - !ruby/object:Gem::Dependency
83
120
  name: rubocop
84
121
  requirement: !ruby/object:Gem::Requirement
85
122
  requirements:
86
- - - ">="
123
+ - - "~>"
87
124
  - !ruby/object:Gem::Version
88
- version: '0'
125
+ version: '1.0'
89
126
  type: :development
90
127
  prerelease: false
91
128
  version_requirements: !ruby/object:Gem::Requirement
92
129
  requirements:
93
- - - ">="
130
+ - - "~>"
94
131
  - !ruby/object:Gem::Version
95
- version: '0'
132
+ version: '1.0'
96
133
  - !ruby/object:Gem::Dependency
97
134
  name: webmock
98
135
  requirement: !ruby/object:Gem::Requirement
99
136
  requirements:
100
- - - ">="
137
+ - - "~>"
101
138
  - !ruby/object:Gem::Version
102
- version: '0'
139
+ version: '3.0'
103
140
  type: :development
104
141
  prerelease: false
105
142
  version_requirements: !ruby/object:Gem::Requirement
106
143
  requirements:
107
- - - ">="
144
+ - - "~>"
108
145
  - !ruby/object:Gem::Version
109
- version: '0'
146
+ version: '3.0'
110
147
  description: Tokyo is a CRM middleware, this gem helps apps talk to it.
111
- email: nathan@controlshiftlabs.com
148
+ email:
149
+ - talk@controlshiftlabs.com
112
150
  executables: []
113
151
  extensions: []
114
- extra_rdoc_files:
115
- - LICENSE.txt
116
- - README.md
152
+ extra_rdoc_files: []
117
153
  files:
118
154
  - ".document"
119
155
  - ".github/workflows/ci.yml"
156
+ - ".gitignore"
120
157
  - ".rspec"
158
+ - ".rubocop.yml"
121
159
  - ".ruby-gemset"
122
160
  - ".ruby-version"
161
+ - CHANGELOG.md
123
162
  - Gemfile
124
163
  - LICENSE.txt
125
164
  - README.md
@@ -134,26 +173,12 @@ files:
134
173
  - lib/tokyo_api/expire.rb
135
174
  - lib/tokyo_api/external_image.rb
136
175
  - lib/tokyo_api/identity.rb
137
- - spec/actionkit_spec.rb
138
- - spec/campact_spec.rb
139
- - spec/client_spec.rb
140
- - spec/expire_spec.rb
141
- - spec/external_image_spec.rb
142
- - spec/fixtures/expire/success
143
- - spec/fixtures/responses/actionkit/full_user_success
144
- - spec/fixtures/responses/campact/full_user_success
145
- - spec/fixtures/responses/full_user_error
146
- - spec/fixtures/responses/full_user_success
147
- - spec/fixtures/responses/identity/full_user_success
148
- - spec/fixtures/responses/krautbuster/full_user_success
149
- - spec/identity_spec.rb
150
- - spec/spec_helper.rb
151
- - spec/tokyo_api_spec.rb
152
176
  - tokyo_api.gemspec
153
- homepage: http://github.com/controlshift/tokyo_api
177
+ homepage: https://github.com/controlshift/tokyo_api
154
178
  licenses:
155
179
  - MIT
156
- metadata: {}
180
+ metadata:
181
+ rubygems_mfa_required: 'true'
157
182
  rdoc_options: []
158
183
  require_paths:
159
184
  - lib
@@ -161,14 +186,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
186
  requirements:
162
187
  - - ">="
163
188
  - !ruby/object:Gem::Version
164
- version: '0'
189
+ version: '3.3'
190
+ - - "<"
191
+ - !ruby/object:Gem::Version
192
+ version: '5.0'
165
193
  required_rubygems_version: !ruby/object:Gem::Requirement
166
194
  requirements:
167
195
  - - ">="
168
196
  - !ruby/object:Gem::Version
169
197
  version: '0'
170
198
  requirements: []
171
- rubygems_version: 3.6.9
199
+ rubygems_version: 4.0.3
172
200
  specification_version: 4
173
201
  summary: Ruby API Wrapper for Tokyo CRM service
174
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,173 +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 '#update_prefill_forms_path' do
121
- it 'should return relative path to prefill forms endpoint' do
122
- expect(subject.campact.update_prefill_forms_path('123abc456')).to eq '/campact/user/123abc456/prefill_forms'
123
- end
124
- end
125
-
126
- describe '#subscription_status_path' do
127
- subject { TokyoApi::Campact.new }
128
-
129
- it 'should return correct path' do
130
- expect(subject.subscription_status_path('abc123')).to eq '/campact/subscription_status/abc123'
131
- end
132
- end
133
-
134
- describe '#session_status' do
135
- let(:client) { double }
136
- let(:session_id) { '123456789abcdef' }
137
-
138
- subject { TokyoApi::Campact.new(client: client) }
139
-
140
- it 'should perform request on session status path' do
141
- expect(client).to receive(:get_request).with("/campact/session/#{session_id}/status").and_return(double(body: {
142
- hard_login: false, soft_login: true
143
- }))
144
-
145
- session_status = subject.session_status(session_id)
146
-
147
- expect(session_status).to eq({ hard_login: false, soft_login: true })
148
- end
149
- end
150
-
151
- describe '#destroy_session' do
152
- let(:client) { double }
153
- let(:session_id) { '123456789abcdef' }
154
-
155
- subject { TokyoApi::Campact.new(client: client) }
156
-
157
- it 'should perform request on session status path' do
158
- expect(client).to receive(:delete_request).with("/campact/session/#{session_id}").and_return(double(status: 204))
159
-
160
- result = subject.destroy_session(session_id)
161
-
162
- expect(result).to be_truthy
163
- end
164
-
165
- it 'should return false if response status is 404' do
166
- expect(client).to receive(:delete_request).with("/campact/session/#{session_id}").and_return(double(status: 404))
167
-
168
- result = subject.destroy_session(session_id)
169
-
170
- expect(result).to be_falsey
171
- end
172
- end
173
- 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