amex_tokenization_client 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c62e09182ba57700d963be41b847603d89a6323bce020c9e55dc505f628a0e25
4
- data.tar.gz: f762f6e1827b2e44ff8ecc3fafc58614b24bb7ae2640dfcb57aaff1efcf41855
3
+ metadata.gz: 24251fb3b1e03df879a5b952e1b06e3da4172cae6a9de57cb23245141720987d
4
+ data.tar.gz: 8db1b2120594ec3b79326ec9370ce78afc7c0b3c424d27e61421290c28626d3d
5
5
  SHA512:
6
- metadata.gz: 6fa54da88d1bbb087dff44abc4e3042e6dd459ca7fba71fa7245ed629878178cb8a3ee25eed4bf8a5e2ded85bba39b3e46724a640217e9662a031b7c8bbce937
7
- data.tar.gz: 68e290243275f584da6367c737942e78ccad1d32b2e8cf3c3ff45562ec7b9208e9c0e09b51eac43f0193b996a5bd7bfb94c680f9276be3f7c0c7307e25c06244
6
+ metadata.gz: eed0f967cef118de7a0e4498e694a7c9086f949488d5ffca4826fd2783dc13e634dbe91e142dcadee5ad5acc12d2ba497391b544ceeb1b7c9601c99c3e7ce57b
7
+ data.tar.gz: 0fd116927a10484ea29290c320ac815716ad337f731dc2f0d382939e3715e1c65093ce2b01b58fa842e1fdb8f8265c1325565bf359f4957bbfeaac1de1d74e86
@@ -0,0 +1,30 @@
1
+ ---
2
+
3
+ name: ci
4
+
5
+ on: [push]
6
+
7
+ jobs:
8
+ test:
9
+
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ ruby-version: ['2.7', '3.0']
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby-version }}
21
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
22
+ - name: Run tests
23
+ env:
24
+ AETS_TOKEN_REQUESTER_ID: ${{ secrets.AETS_TOKEN_REQUESTER_ID }}
25
+ AETS_CLIENT_ID: ${{ secrets.AETS_CLIENT_ID }}
26
+ AETS_CLIENT_SECRET: ${{ secrets.AETS_CLIENT_SECRET }}
27
+ AETS_ENC_KEY_ID: ${{ secrets.AETS_ENC_KEY_ID }}
28
+ AETS_ENC_KEY: ${{ secrets.AETS_ENC_KEY }}
29
+
30
+ run: bundle exec rake
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,12 @@
1
+ # Contributing
2
+
3
+ Bug reports and pull requests are [welcome on GitHub](https://github.com/varyonic/amex_enhanced_authorization).
4
+
5
+ ## Development
6
+
7
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
8
+
9
+ To install this gem onto your local machine, run `bundle exec rake install`.
10
+
11
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
12
+ which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/Gemfile CHANGED
@@ -4,5 +4,3 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in amex_tokenization_client.gemspec
6
6
  gemspec
7
-
8
- gem 'jwe', github: 'varyonic/ruby-jwe.git', branch: 'PR18' # Fix A256KW.
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # AmexTokenizationClient
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/amex_tokenization_client.svg)](https://badge.fury.io/rb/amex_tokenization_client)
4
- [![Travis CI Status](https://secure.travis-ci.org/varyonic/amex-api-ruby-client.svg)](https://travis-ci.org/varyonic/amex-api-ruby-client)
4
+ [![Github Actions ][actions_badge]][actions]
5
5
 
6
- Unofficial Ruby wrapper for the American Express Tokenization Service (AETS).
6
+ Unofficial Ruby wrapper for the American Express Tokenization Service (AETS)
7
+ published via the [amex developer portal](https://developer.americanexpress.com/products/amex-token-service/overview),
8
+ see also [amex-api-java-client-core](https://github.com/americanexpress/amex-api-java-client-core).
7
9
 
8
10
  ## Installation
9
11
 
@@ -11,7 +13,6 @@ Add to your application's Gemfile:
11
13
 
12
14
  ```ruby
13
15
  gem 'amex_tokenization_client'
14
- gem 'jwe', git: 'https://github.com/varyonic/ruby-jwe', branch: 'PR18' # A256KW fix
15
16
  ```
16
17
 
17
18
  And then execute:
@@ -20,18 +21,19 @@ And then execute:
20
21
 
21
22
  ## Usage
22
23
 
23
- TODO: Write usage instructions here
24
+ See [specs](https://github.com/varyonic/amex_enhanced_authorization/blob/master/spec/amex_tokenization_client_spec.rb) for sample usage.
24
25
 
25
- ## Development
26
+ ## Contributions
26
27
 
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
28
29
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+ ## License
30
31
 
31
- ## Contributing
32
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
32
33
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/varyonic/amex-api-ruby-client.
34
+ Read the [LICENSE](LICENSE.md) for details.
34
35
 
35
- ## License
36
+ Copyright (c) 2018-2021 [Varyonic](https://www.varyonic.com).
36
37
 
37
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+ [actions_badge]: https://github.com/varyonic/amex_tokenization_client/workflows/ci/badge.svg
39
+ [actions]: https://github.com/varyonic/amex_tokenization_client/actions
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["piers@varyonic.com"]
11
11
 
12
12
  spec.summary = "Unofficial Ruby wrapper for the American Express Tokenization Service (AETS)."
13
- spec.homepage = "https://github.com/varyonic/amex-api-ruby-client"
13
+ spec.homepage = "https://github.com/varyonic/amex_enhanced_authorization"
14
14
  spec.license = "MIT"
15
15
 
16
16
  # Specify which files should be added to the gem when it is released.
@@ -22,9 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "jwe"
25
+ spec.add_dependency "jwe", ">= 0.4.0"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.16"
28
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rake", "~> 13.0"
29
28
  spec.add_development_dependency "rspec", "~> 3.0"
30
29
  end
@@ -4,16 +4,18 @@ class AmexTokenizationClient
4
4
  class ProvisioningPayload
5
5
  attr_reader :account_number, :expiry_month, :expiry_year
6
6
  attr_reader :name, :email, :is_on_file, :ip_address
7
+ attr_reader :user_id
7
8
 
8
- def initialize(account_number:, name:, expiry_month:, expiry_year:, email:, is_on_file:, ip_address: nil)
9
+ def initialize(account_number:, name:, expiry_month:, expiry_year:, email:, is_on_file:, user_id: nil, ip_address: nil)
9
10
  @account_number, @expiry_month, @expiry_year = account_number, expiry_month, expiry_year
10
11
  @name, @email, @is_on_file, @ip_address = name, email, is_on_file, ip_address
12
+ @user_id = user_id
11
13
  end
12
14
 
13
15
  def to_json(encryption_key_id, encryption_key)
14
16
  Hash[
15
17
  account_data: account_data(encryption_key_id, encryption_key),
16
- user_data: { name: name, email: email },
18
+ user_data: { user_id: user_id, name: name, email: email }.compact,
17
19
  risk_assessment_data: risk_assessment_data
18
20
  ].to_json
19
21
  end
@@ -53,8 +53,11 @@ class AmexTokenizationClient
53
53
  end
54
54
 
55
55
  class UnexpectedHttpResponse < StandardError
56
+ attr_reader :response
57
+
56
58
  def initialize(response)
57
- super response.message || response.code
59
+ @response = response
60
+ super "#{response.message} (#{response.code}): #{response.body}"
58
61
  end
59
62
  end
60
63
 
@@ -1,3 +1,3 @@
1
1
  class AmexTokenizationClient
2
- VERSION = "0.1.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -8,6 +8,7 @@ require "amex_tokenization_client/provisioning_payload"
8
8
  require "amex_tokenization_client/request"
9
9
  require "amex_tokenization_client/version"
10
10
 
11
+ # https://developer.americanexpress.com/products/amex-token-service/resources
11
12
  class AmexTokenizationClient
12
13
  attr_reader :host
13
14
  attr_reader :base_path
@@ -36,6 +37,13 @@ class AmexTokenizationClient
36
37
  response
37
38
  end
38
39
 
40
+ # @return [Hash] token_ref_id and other values.
41
+ def provisionings(kargs)
42
+ response = JSON.parse send_authorized_request('POST', 'provisionings', provisioning_payload(kargs))
43
+ response.merge! JSON.parse jwe_decrypt response.delete('secure_token_data')
44
+ response
45
+ end
46
+
39
47
  def notifications(kargs)
40
48
  send_authorized_request('POST', 'notifications', notifications_payload(kargs))
41
49
  end
@@ -49,11 +57,11 @@ class AmexTokenizationClient
49
57
  end
50
58
 
51
59
  def provisioning_payload(kargs)
52
- ProvisioningPayload.new(kargs).to_json(encryption_key_id, encryption_key)
60
+ ProvisioningPayload.new(**kargs).to_json(encryption_key_id, encryption_key)
53
61
  end
54
62
 
55
63
  def notifications_payload(kargs)
56
- NotificationsPayload.new(kargs).to_json(encryption_key_id, encryption_key)
64
+ NotificationsPayload.new(**kargs).to_json(encryption_key_id, encryption_key)
57
65
  end
58
66
 
59
67
  def jwe_decrypt(data)
@@ -88,6 +96,7 @@ class AmexTokenizationClient
88
96
  Hash[
89
97
  'Content-Type' => 'application/json',
90
98
  'Content-Language' => 'en-US',
99
+ 'Accept-Language' => 'en',
91
100
  'x-amex-token-requester-id' => token_requester_id,
92
101
  'x-amex-api-key' => client_id,
93
102
  'x-amex-request-id' => SecureRandom.uuid,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amex_tokenization_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piers Chambers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwe
@@ -16,42 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.4.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'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.16'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.16'
26
+ version: 0.4.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '10.0'
33
+ version: '13.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '10.0'
40
+ version: '13.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,16 +52,17 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '3.0'
69
- description:
55
+ description:
70
56
  email:
71
57
  - piers@varyonic.com
72
58
  executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
62
+ - ".github/workflows/ci.yaml"
76
63
  - ".gitignore"
77
64
  - ".rspec"
78
- - ".travis.yml"
65
+ - CONTRIBUTING.md
79
66
  - Gemfile
80
67
  - LICENSE.txt
81
68
  - README.md
@@ -88,11 +75,11 @@ files:
88
75
  - lib/amex_tokenization_client/provisioning_payload.rb
89
76
  - lib/amex_tokenization_client/request.rb
90
77
  - lib/amex_tokenization_client/version.rb
91
- homepage: https://github.com/varyonic/amex-api-ruby-client
78
+ homepage: https://github.com/varyonic/amex_enhanced_authorization
92
79
  licenses:
93
80
  - MIT
94
81
  metadata: {}
95
- post_install_message:
82
+ post_install_message:
96
83
  rdoc_options: []
97
84
  require_paths:
98
85
  - lib
@@ -107,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
94
  - !ruby/object:Gem::Version
108
95
  version: '0'
109
96
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.7.7
112
- signing_key:
97
+ rubygems_version: 3.2.15
98
+ signing_key:
113
99
  specification_version: 4
114
100
  summary: Unofficial Ruby wrapper for the American Express Tokenization Service (AETS).
115
101
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.4.5
7
- before_install: gem install bundler -v 1.16.3