tokyo_api 1.6.0 → 1.8.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: 608376ec5c22df615936ab9c5603877f983e3f1c36c93071f3e4e4195bc6012e
4
- data.tar.gz: 48218037c0aa31d24ca5f708311677387172422adc63a1ee5a0f190b3f92bfd2
3
+ metadata.gz: da756851722d19fe2817efef68b7800fc078f3a56e6494fbd83e1728576dcb92
4
+ data.tar.gz: ea742d2a8fb9a47eb773b60c0b7d364b9e4057d9679c4f4da9fc8a6cdf7097ca
5
5
  SHA512:
6
- metadata.gz: 5baf06d1f979d9efa535600046b02f384cc53ce3dc794be57e1e799a4cb1a9744b7202725656905940438b0a8081951f5545b9e46f463fa90f0c9ecf870d8a0b
7
- data.tar.gz: 585fb0e20ce10d6aec74c764a8b43716dabed99e6c32605f8789837840e3ba80a0ae828dd5ed104fb604f2314e1c405242389bfcffe83b1467cba761b15256c3
6
+ metadata.gz: 918a3f26f02b51ba6893f218b3dab6f34e9089d163715b10947aabff02ba1f8bf0890cfd637070944865c8cf0f1da1f0045241f28aad4a2e60f1e62e055edbcd
7
+ data.tar.gz: 7633e4061040949bf31d27352f7e6a4e1119c96e8b6959588e1b350b1721bad1c05745a3da5d8daba63d527ae96be976454538f1335b61d58d59aaee14296820
@@ -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.6.6
1
+ 3.1.2
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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.8.0
@@ -16,6 +16,10 @@ module TokyoApi
16
16
  @identity ||= TokyoApi::Identity.new(client: self)
17
17
  end
18
18
 
19
+ def external_image
20
+ @external_image ||= TokyoApi::ExternalImage.new(client: self)
21
+ end
22
+
19
23
  def expire
20
24
  @expire ||= TokyoApi::Expire.new(client: self)
21
25
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TokyoApi
4
+ class ExternalImage < Base
5
+ def base_path
6
+ 'external_image'
7
+ end
8
+
9
+ def track_download(photo_id)
10
+ client.post_request("#{normalized_base_path}#{url_escape(photo_id)}/download").status == 204
11
+ end
12
+ end
13
+ end
@@ -10,18 +10,15 @@ module TokyoApi
10
10
  client.get_request("#{normalized_base_path}full_user/#{url_escape(id)}").body
11
11
  end
12
12
 
13
- def tokyo_identity_user_path(id, with_subscription_status: false, required_fields: nil, opt_in_public_ids: nil, minimum_consent_level: nil, encrypted: nil)
13
+ def tokyo_identity_user_path(id, required_fields: nil, opt_in_public_ids: nil, minimum_consent_level: nil, encrypted: nil)
14
14
  path = String.new("/#{normalized_base_path}user/#{url_escape(id)}")
15
15
 
16
16
  params = []
17
17
  params << required_fields_param(required_fields) unless required_fields.nil?
18
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,
22
- minimum_consent_level, encrypted)
23
- params << additional_subscription_parameters if additional_subscription_parameters.present?
24
- end
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?
25
22
 
26
23
  path << "?#{params.join('&')}" if params.any?
27
24
 
data/lib/tokyo_api.rb CHANGED
@@ -5,6 +5,7 @@ require 'tokyo_api/base'
5
5
  require 'tokyo_api/actionkit'
6
6
  require 'tokyo_api/campact'
7
7
  require 'tokyo_api/client'
8
+ require 'tokyo_api/external_image'
8
9
  require 'tokyo_api/expire'
9
10
  require 'tokyo_api/identity'
10
11
 
@@ -0,0 +1,37 @@
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
@@ -60,49 +60,20 @@ describe TokyoApi::Identity do
60
60
  end
61
61
  end
62
62
 
63
- context 'with_subscription_status and associated arguments' do
64
- it 'should not include query string parameter if argument is missing' do
65
- expect(subject.identity.tokyo_identity_user_path('123abc456')).not_to match(/.+with_subscription_status=.+/)
66
- end
67
-
68
- it 'should not include query string parameter if argument is false' do
69
- expect(subject.identity.tokyo_identity_user_path('123abc456',
70
- with_subscription_status: false)).not_to match(/.+with_subscription_status=.+/)
71
- end
72
-
73
- it 'should not include opt_in_public_ids and minimum_consent_level if with_subscription_status is false' do
74
- tokyo_path = subject.identity.tokyo_identity_user_path('123abc456',
75
- with_subscription_status: false,
76
- opt_in_public_ids: ['policy-1.5'],
77
- minimum_consent_level: 'explicit')
78
-
79
- expect(tokyo_path).not_to match(/.+opt_in_public_ids=.+/)
80
- expect(tokyo_path).not_to match(/.+minimum_consent_level=.+/)
81
- 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
82
66
 
83
- it 'should include query string parameter if argument is true' do
84
- expect(subject.identity.tokyo_identity_user_path('123abc456',
85
- with_subscription_status: true)).to match(/.+with_subscription_status=.+/)
86
- 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')
87
73
 
88
- it 'should include encrypted parameter if argument is true' do
89
- expect(subject.identity.tokyo_identity_user_path('123abc456', with_subscription_status: true,
90
- encrypted: true)).to match(/.+encrypted=.+/)
91
- end
92
-
93
- it 'should include opt_in_public_ids and minimum_consent_level if with_subscription_status is true' do
94
- tokyo_path = subject.identity.tokyo_identity_user_path('123abc456',
95
- required_fields: %i[first_name last_name email
96
- postal phone],
97
- with_subscription_status: true,
98
- opt_in_public_ids: ['policy-1.5'],
99
- minimum_consent_level: 'explicit')
100
-
101
- expect(tokyo_path).to match(/.+with_subscription_status=true.*/)
102
- expect(tokyo_path).to match(/.+opt_in_public_ids=.+/)
103
- expect(tokyo_path).to match(/.+minimum_consent_level=.+/)
104
- expect { URI.parse(tokyo_path) }.not_to raise_error
105
- 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
106
77
  end
107
78
  end
108
79
 
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.6.0 ruby lib
5
+ # stub: tokyo_api 1.8.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tokyo_api".freeze
9
- s.version = "1.6.0"
9
+ s.version = "1.8.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 = "2021-03-24"
14
+ s.date = "2022-11-25"
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",
@@ -36,11 +36,13 @@ Gem::Specification.new do |s|
36
36
  "lib/tokyo_api/campact.rb",
37
37
  "lib/tokyo_api/client.rb",
38
38
  "lib/tokyo_api/expire.rb",
39
+ "lib/tokyo_api/external_image.rb",
39
40
  "lib/tokyo_api/identity.rb",
40
41
  "spec/actionkit_spec.rb",
41
42
  "spec/campact_spec.rb",
42
43
  "spec/client_spec.rb",
43
44
  "spec/expire_spec.rb",
45
+ "spec/external_image_spec.rb",
44
46
  "spec/fixtures/expire/success",
45
47
  "spec/fixtures/responses/actionkit/full_user_success",
46
48
  "spec/fixtures/responses/campact/full_user_success",
@@ -55,29 +57,21 @@ Gem::Specification.new do |s|
55
57
  ]
56
58
  s.homepage = "http://github.com/controlshift/tokyo_api".freeze
57
59
  s.licenses = ["MIT".freeze]
58
- s.rubygems_version = "3.0.8".freeze
60
+ s.rubygems_version = "3.3.19".freeze
59
61
  s.summary = "Ruby API Wrapper for Tokyo CRM service".freeze
60
62
 
61
63
  if s.respond_to? :specification_version then
62
64
  s.specification_version = 4
65
+ end
63
66
 
64
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
- s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
66
- s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
67
- s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
68
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
69
- s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
70
- s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
71
- s.add_development_dependency(%q<webmock>.freeze, [">= 0"])
72
- else
73
- s.add_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
74
- s.add_dependency(%q<bundler>.freeze, [">= 0"])
75
- s.add_dependency(%q<byebug>.freeze, [">= 0"])
76
- s.add_dependency(%q<juwelier>.freeze, [">= 0"])
77
- s.add_dependency(%q<rspec>.freeze, [">= 0"])
78
- s.add_dependency(%q<rubocop>.freeze, [">= 0"])
79
- s.add_dependency(%q<webmock>.freeze, [">= 0"])
80
- end
67
+ if s.respond_to? :add_runtime_dependency then
68
+ s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
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"])
81
75
  else
82
76
  s.add_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
83
77
  s.add_dependency(%q<bundler>.freeze, [">= 0"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tokyo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-24 00:00:00.000000000 Z
11
+ date: 2022-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vertebrae
@@ -117,10 +117,10 @@ extra_rdoc_files:
117
117
  - README.md
118
118
  files:
119
119
  - ".document"
120
+ - ".github/workflows/ci.yml"
120
121
  - ".rspec"
121
122
  - ".ruby-gemset"
122
123
  - ".ruby-version"
123
- - ".travis.yml"
124
124
  - Gemfile
125
125
  - LICENSE.txt
126
126
  - README.md
@@ -133,11 +133,13 @@ files:
133
133
  - lib/tokyo_api/campact.rb
134
134
  - lib/tokyo_api/client.rb
135
135
  - lib/tokyo_api/expire.rb
136
+ - lib/tokyo_api/external_image.rb
136
137
  - lib/tokyo_api/identity.rb
137
138
  - spec/actionkit_spec.rb
138
139
  - spec/campact_spec.rb
139
140
  - spec/client_spec.rb
140
141
  - spec/expire_spec.rb
142
+ - spec/external_image_spec.rb
141
143
  - spec/fixtures/expire/success
142
144
  - spec/fixtures/responses/actionkit/full_user_success
143
145
  - spec/fixtures/responses/campact/full_user_success
@@ -153,7 +155,7 @@ homepage: http://github.com/controlshift/tokyo_api
153
155
  licenses:
154
156
  - MIT
155
157
  metadata: {}
156
- post_install_message:
158
+ post_install_message:
157
159
  rdoc_options: []
158
160
  require_paths:
159
161
  - lib
@@ -168,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
170
  - !ruby/object:Gem::Version
169
171
  version: '0'
170
172
  requirements: []
171
- rubygems_version: 3.0.8
172
- signing_key:
173
+ rubygems_version: 3.3.19
174
+ signing_key:
173
175
  specification_version: 4
174
176
  summary: Ruby API Wrapper for Tokyo CRM service
175
177
  test_files: []
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "2.3.3"