pcp-server-ruby-sdk 1.2.0 → 1.3.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: '095fe63398bc28f8de4e8040e0aafae3140c77f1cfc706f29d4a1a505d242279'
4
- data.tar.gz: 28c4a2ec2baceeb92d77c07ca74dbbc340845335d579878e7ff4930e0ca6255e
3
+ metadata.gz: bb0118721663f462f5bc434e7b2df5d76e517f2865d03d666cd32dbce5133fca
4
+ data.tar.gz: 37c389d8f6d02e865f4713f93b7d0745c232846acc797e697a1295de7921db43
5
5
  SHA512:
6
- metadata.gz: 23e606c466218f6c646259598e9fc50f8c99bfa44b5a457d2aceee2ef4fedc9273337332128fedaeec05bbdb4cdbbe0babb2af1304ae099c8b4981e358ff2ddd
7
- data.tar.gz: 0bea44e28cc1681047ddc73e0a3d4be47e241eeb4d0ed4d4229edecf15d2b89ba944dc1749efeea1601b3b24efd3a512593258b22ebfb4677a374dd992960fec
6
+ metadata.gz: 4f2912be3416517cb213a8d50196879fe2fa60248d011d83d19bced6d1f4b6d20abbf279b59dd68f837dd1d8df0f243431b50c571a2012a2ae940ca264512b07
7
+ data.tar.gz: 48c4c4540f71b982ca05b17c7e4d357835eee938b7164e059890a2dc85a906018a720201c5f3840fb0dc86494f25026beba0e7c5fcbb1108d1574f5f1c99c3ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [1.3.0](https://github.com/PAYONE-GmbH/PCP-ServerSDK-ruby/compare/v1.2.0...v1.3.0) (2025-07-10)
2
+
3
+ ### Features
4
+
5
+ * feat: add auth client ([c8fd009b11a8ec3416a33ecab949ec2c51406e7e](https://github.com/PAYONE-GmbH/PCP-ServerSDK-ruby/commit/c8fd009b11a8ec3416a33ecab949ec2c51406e7e))
6
+
1
7
  # [1.2.0](https://github.com/PAYONE-GmbH/PCP-ServerSDK-ruby/compare/v1.1.0...v1.2.0) (2025-05-26)
2
8
 
3
9
  ### Documentation
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency 'simplecov', '~> 0.22.0'
26
26
 
27
27
  s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
28
- s.test_files = `find test/*`.split("\n")
28
+ s.test_files = `find spec/*`.split("\n")
29
29
  s.executables = []
30
30
  s.require_paths = ["lib"]
31
31
  end
data/README.md CHANGED
@@ -19,6 +19,7 @@ This SDK requires Ruby 3.2 or later.
19
19
  - [Installation](#installation)
20
20
  - [Usage](#usage)
21
21
  - [General](#general)
22
+ - [Authentication Token Retrieval](#authentication-token-retrieval)
22
23
  - [Error Handling](#error-handling)
23
24
  - [Client Side](#client-side)
24
25
  - [Apple Pay](#apple-pay)
@@ -83,6 +84,26 @@ createCommerceCaseResponse = client.create_commerce_case_request('merchant_id',
83
84
 
84
85
  The models directly map to the API as described in [PAYONE Commerce Platform API Reference](https://docs.payone.com/pcp/commerce-platform-api). For an in depth example you can take a look at the [demo app](#demo-app).
85
86
 
87
+
88
+ ### Authentication Token Retrieval
89
+
90
+ To interact with certain client-side SDKs (such as the credit card tokenizer), you need to generate a short-lived authentication JWT token for your merchant. This token can be retrieved using the SDK as follows:
91
+
92
+ ```rb
93
+ require 'pcp-server-ruby-sdk'
94
+
95
+ authentication_client = PCPServerSDK::Endpoints::AuthenticationApiClient.new(communicator_configuration)
96
+ token = authentication_client.get_authentication_tokens(merchant_id)
97
+ puts "JWT Token: #{token.token}"
98
+ puts "Token ID: #{token.id}"
99
+ puts "Created: #{token.creation_date}"
100
+ puts "Expires: #{token.expiration_date}"
101
+ ```
102
+
103
+ This token can then be used for secure operations such as initializing the credit card tokenizer or other client-side SDKs that require merchant authentication. The token is valid for a limited time (10 minutes) and should be handled securely.
104
+
105
+ **Note:** The `get_authentication_tokens` method requires a valid `merchant_id`. Optionally, you can provide an `X-Request-ID` header for tracing requests.
106
+
86
107
  ### Error Handling
87
108
 
88
109
  When making a request any client may throw a `PCPServerSDK::Errors::ApiException`. There two subtypes of this exception:
@@ -1,12 +1,20 @@
1
1
  require_relative '../lib/PCP-server-Ruby-SDK.rb'
2
2
  class CommerceCaseApiExample
3
- attr_accessor :client, :merchant_id, :commerce_case_id
3
+ attr_accessor :client, :merchant_id, :commerce_case_id, :auth_client
4
4
 
5
5
  def initialize(config)
6
6
  @client = PCPServerSDK::Endpoints::CommerceCaseApiClient.new(config)
7
+ @auth_client = PCPServerSDK::Endpoints::AuthenticationApiClient.new(config)
7
8
  @merchant_id = ENV['MERCHANT_ID']
8
9
  @commerce_case_id = ENV['COMMERCE_CASE_ID']
9
10
  end
11
+ def run_auth_token_example
12
+ token = @auth_client.get_authentication_tokens(@merchant_id)
13
+ puts "JWT Token: #{token.token}"
14
+ puts "Token ID: #{token.id}"
15
+ puts "Created: #{token.creation_date}"
16
+ puts "Expires: #{token.expiration_date}"
17
+ end
10
18
 
11
19
  def run_post_one
12
20
  payload = {}
@@ -26,8 +26,9 @@ def run
26
26
  # commerce_case_api_client_example.run_post_one
27
27
  # commerce_case_api_client_example.run_get_all
28
28
 
29
- commerce_case_api_client_example.run_get_one
29
+ # commerce_case_api_client_example.run_get_one
30
30
  # commerce_case_api_client_example.run_update_one
31
+ commerce_case_api_client_example.run_auth_token_example
31
32
  end
32
33
 
33
34
  run
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../errors/api_error_response_exception'
4
+ require_relative '../errors/api_response_retrieval_exception'
5
+ require_relative '../models/authentication_token'
6
+ require_relative 'base_api_client'
7
+
8
+ module PCPServerSDK
9
+ module Endpoints
10
+ # Client for authentication token operations
11
+ class AuthenticationApiClient < BaseApiClient
12
+ def get_authentication_tokens(merchant_id, request_id = nil)
13
+ raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty?
14
+
15
+ url = URI.join(get_config.host, "/v1/#{merchant_id}/authentication-tokens")
16
+
17
+ request_init = {
18
+ method: 'POST',
19
+ headers: { 'Content-Type' => 'application/json' },
20
+ body: ''
21
+ }
22
+ request_init[:headers]['X-Request-ID'] = request_id unless request_id.nil?
23
+
24
+ response = make_api_call(url.to_s, request_init)
25
+ deserialize_json(response, PCPServerSDK::Models::AuthenticationToken)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,189 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'date'
5
+ require 'securerandom'
6
+
7
+ module PCPServerSDK
8
+ module Models
9
+ # Model for the authentication JWT token response
10
+ class AuthenticationToken
11
+ attr_accessor :token
12
+ attr_accessor :id
13
+ attr_accessor :creation_date
14
+ attr_accessor :expiration_date
15
+
16
+ def self.attribute_map
17
+ {
18
+ :'token' => :'token',
19
+ :'id' => :'id',
20
+ :'creation_date' => :'creationDate',
21
+ :'expiration_date' => :'expirationDate'
22
+ }
23
+ end
24
+
25
+ def self.acceptable_attributes
26
+ attribute_map.values
27
+ end
28
+
29
+ def self.openapi_types
30
+ {
31
+ :'token' => :'String',
32
+ :'id' => :'String',
33
+ :'creation_date' => :'Time',
34
+ :'expiration_date' => :'Time'
35
+ }
36
+ end
37
+
38
+ def self.openapi_nullable
39
+ Set.new([])
40
+ end
41
+
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AuthenticationToken` initialize method"
45
+ end
46
+
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AuthenticationToken`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
+ end
51
+ h[k.to_sym] = v
52
+ }
53
+
54
+ if attributes.key?(:'token')
55
+ self.token = attributes[:'token']
56
+ end
57
+
58
+ if attributes.key?(:'id')
59
+ self.id = attributes[:'id']
60
+ end
61
+
62
+ if attributes.key?(:'creation_date')
63
+ self.creation_date = attributes[:'creation_date'].is_a?(String) ? Time.parse(attributes[:'creation_date']) : attributes[:'creation_date']
64
+ end
65
+
66
+ if attributes.key?(:'expiration_date')
67
+ self.expiration_date = attributes[:'expiration_date'].is_a?(String) ? Time.parse(attributes[:'expiration_date']) : attributes[:'expiration_date']
68
+ end
69
+ end
70
+
71
+ def self.from_json(json_str)
72
+ data = JSON.parse(json_str)
73
+ new(data)
74
+ end
75
+
76
+ def self.build_from_hash(attributes)
77
+ return nil unless attributes.is_a?(Hash)
78
+ attributes = attributes.transform_keys(&:to_sym)
79
+ transformed_hash = {}
80
+ openapi_types.each_pair do |key, type|
81
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
82
+ transformed_hash[key] = nil
83
+ elsif type =~ /\AArray<(.*)>/i
84
+ if attributes[attribute_map[key]].is_a?(Array)
85
+ transformed_hash[key] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
86
+ end
87
+ elsif !attributes[attribute_map[key]].nil?
88
+ transformed_hash[key] = _deserialize(type, attributes[attribute_map[key]])
89
+ end
90
+ end
91
+ new(transformed_hash)
92
+ end
93
+
94
+ def self._deserialize(type, value)
95
+ case type.to_sym
96
+ when :Time
97
+ Time.parse(value)
98
+ when :Date
99
+ Date.parse(value)
100
+ when :String
101
+ value.to_s
102
+ when :Integer
103
+ value.to_i
104
+ when :Float
105
+ value.to_f
106
+ when :Boolean
107
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
108
+ true
109
+ else
110
+ false
111
+ end
112
+ when :Object
113
+ value
114
+ when /\AArray<(?<inner_type>.+)>/i
115
+ inner_type = Regexp.last_match[:inner_type]
116
+ value.map { |v| _deserialize(inner_type, v) }
117
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>/i
118
+ k_type = Regexp.last_match[:k_type]
119
+ v_type = Regexp.last_match[:v_type]
120
+ {}.tap do |hash|
121
+ value.each do |k, v|
122
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
123
+ end
124
+ end
125
+ else
126
+ # models (e.g. Pet) or oneOf
127
+ if PCPServerSDK::Models.const_defined?(type)
128
+ klass = PCPServerSDK::Models.const_get(type)
129
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
130
+ else
131
+ value
132
+ end
133
+ end
134
+ end
135
+
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ token == o.token &&
140
+ id == o.id &&
141
+ creation_date == o.creation_date &&
142
+ expiration_date == o.expiration_date
143
+ end
144
+
145
+ def eql?(o)
146
+ self == o
147
+ end
148
+
149
+ def hash
150
+ [token, id, creation_date, expiration_date].hash
151
+ end
152
+
153
+ def to_s
154
+ to_hash.to_s
155
+ end
156
+
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ def to_hash
162
+ hash = {}
163
+ self.class.attribute_map.each_pair do |attr, param|
164
+ value = self.send(attr)
165
+ if value.nil?
166
+ is_nullable = self.class.openapi_nullable.include?(attr)
167
+ next if !is_nullable || (is_nullable && !instance_variable_defined?("@#{attr}"))
168
+ end
169
+ hash[param] = _to_hash(value)
170
+ end
171
+ hash
172
+ end
173
+
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module PCPServerSDK
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
@@ -1,5 +1,6 @@
1
1
  # Api
2
2
  require_relative 'PCP-server-Ruby-SDK/endpoints/base_api_client'
3
+ require_relative 'PCP-server-Ruby-SDK/endpoints/authentication_api_client'
3
4
  require_relative 'PCP-server-Ruby-SDK/endpoints/checkout_api_client'
4
5
  require_relative 'PCP-server-Ruby-SDK/endpoints/commerce_case_api_client'
5
6
  require_relative 'PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client'
@@ -20,6 +21,7 @@ require_relative 'PCP-server-Ruby-SDK/models/api_error'
20
21
  require_relative 'PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information'
21
22
  require_relative 'PCP-server-Ruby-SDK/models/apple_payment_data_token_information'
22
23
  require_relative 'PCP-server-Ruby-SDK/models/apple_payment_token_version'
24
+ require_relative 'PCP-server-Ruby-SDK/models/authentication_token'
23
25
  require_relative 'PCP-server-Ruby-SDK/models/authorization_mode'
24
26
  require_relative 'PCP-server-Ruby-SDK/models/bank_account_information'
25
27
  require_relative 'PCP-server-Ruby-SDK/models/bank_payout_method_specific_input'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pcp-serversdk-ruby",
9
- "version": "1.2.0",
9
+ "version": "1.3.0",
10
10
  "devDependencies": {
11
11
  "@commitlint/cli": "19.4.0",
12
12
  "@commitlint/config-conventional": "19.2.2",
@@ -296,7 +296,7 @@
296
296
  }
297
297
  },
298
298
  "node_modules/@types/node": {
299
- "version": "1.2.0",
299
+ "version": "1.3.0",
300
300
  "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz",
301
301
  "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==",
302
302
  "dev": true,
@@ -317,7 +317,7 @@
317
317
  "dev": true
318
318
  },
319
319
  "node_modules/add-stream": {
320
- "version": "1.2.0",
320
+ "version": "1.3.0",
321
321
  "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz",
322
322
  "integrity": "sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==",
323
323
  "dev": true
@@ -369,7 +369,7 @@
369
369
  "dev": true
370
370
  },
371
371
  "node_modules/array-ify": {
372
- "version": "1.2.0",
372
+ "version": "1.3.0",
373
373
  "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz",
374
374
  "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==",
375
375
  "dev": true
@@ -566,9 +566,9 @@
566
566
  }
567
567
  },
568
568
  "node_modules/conventional-changelog-core/node_modules/conventional-commits-parser": {
569
- "version": "6.1.0",
570
- "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.1.0.tgz",
571
- "integrity": "sha512-5nxDo7TwKB5InYBl4ZC//1g9GRwB/F3TXOGR9hgUjMGfvSP4Vu5NkpNro2+1+TIEy1vwxApl5ircECr2ri5JIw==",
569
+ "version": "6.2.0",
570
+ "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.0.tgz",
571
+ "integrity": "sha512-uLnoLeIW4XaoFtH37qEcg/SXMJmKF4vi7V0H2rnPueg+VEtFGA/asSCNTcq4M/GQ6QmlzchAEtOoDTtKqWeHag==",
572
572
  "dev": true,
573
573
  "dependencies": {
574
574
  "meow": "^13.0.0"
@@ -654,9 +654,9 @@
654
654
  }
655
655
  },
656
656
  "node_modules/conventional-changelog-writer": {
657
- "version": "8.1.0",
658
- "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-8.1.0.tgz",
659
- "integrity": "sha512-dpC440QnORNCO81XYuRRFOLCsjKj4W7tMkUIn3lR6F/FAaJcWLi7iCj6IcEvSQY2zw6VUgwUKd5DEHKEWrpmEQ==",
657
+ "version": "8.2.0",
658
+ "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-8.2.0.tgz",
659
+ "integrity": "sha512-Y2aW4596l9AEvFJRwFGJGiQjt2sBYTjPD18DdvxX9Vpz0Z7HQ+g1Z+6iYDAm1vR3QOJrDBkRHixHK/+FhkR6Pw==",
660
660
  "dev": true,
661
661
  "dependencies": {
662
662
  "conventional-commits-filter": "^5.0.0",
@@ -1014,9 +1014,9 @@
1014
1014
  }
1015
1015
  },
1016
1016
  "node_modules/git-semver-tags/node_modules/conventional-commits-parser": {
1017
- "version": "6.1.0",
1018
- "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.1.0.tgz",
1019
- "integrity": "sha512-5nxDo7TwKB5InYBl4ZC//1g9GRwB/F3TXOGR9hgUjMGfvSP4Vu5NkpNro2+1+TIEy1vwxApl5ircECr2ri5JIw==",
1017
+ "version": "6.2.0",
1018
+ "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.2.0.tgz",
1019
+ "integrity": "sha512-uLnoLeIW4XaoFtH37qEcg/SXMJmKF4vi7V0H2rnPueg+VEtFGA/asSCNTcq4M/GQ6QmlzchAEtOoDTtKqWeHag==",
1020
1020
  "dev": true,
1021
1021
  "optional": true,
1022
1022
  "peer": true,
@@ -1123,7 +1123,7 @@
1123
1123
  }
1124
1124
  },
1125
1125
  "node_modules/index-to-position": {
1126
- "version": "1.2.0",
1126
+ "version": "1.3.0",
1127
1127
  "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-0.1.2.tgz",
1128
1128
  "integrity": "sha512-MWDKS3AS1bGCHLBA2VLImJz42f7bJh8wQsTGCzI3j519/CASStoDONUBVz2I/VID0MpiX3SGSnbOD2xUalbE5g==",
1129
1129
  "dev": true,
@@ -1231,13 +1231,13 @@
1231
1231
  "dev": true
1232
1232
  },
1233
1233
  "node_modules/json-schema-traverse": {
1234
- "version": "1.2.0",
1234
+ "version": "1.3.0",
1235
1235
  "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
1236
1236
  "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
1237
1237
  "dev": true
1238
1238
  },
1239
1239
  "node_modules/jsonparse": {
1240
- "version": "1.2.0",
1240
+ "version": "1.3.0",
1241
1241
  "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
1242
1242
  "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==",
1243
1243
  "dev": true,
@@ -1525,7 +1525,7 @@
1525
1525
  }
1526
1526
  },
1527
1527
  "node_modules/minimist": {
1528
- "version": "1.2.8",
1528
+ "version": "1.3.0",
1529
1529
  "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
1530
1530
  "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
1531
1531
  "dev": true,
@@ -1674,7 +1674,7 @@
1674
1674
  }
1675
1675
  },
1676
1676
  "node_modules/picocolors": {
1677
- "version": "1.2.0",
1677
+ "version": "1.3.0",
1678
1678
  "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
1679
1679
  "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
1680
1680
  "dev": true
@@ -1935,9 +1935,9 @@
1935
1935
  "dev": true
1936
1936
  },
1937
1937
  "node_modules/tinyexec": {
1938
- "version": "1.2.0",
1939
- "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz",
1940
- "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",
1938
+ "version": "1.0.1",
1939
+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.1.tgz",
1940
+ "integrity": "sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw==",
1941
1941
  "dev": true
1942
1942
  },
1943
1943
  "node_modules/type-fest": {
@@ -1986,7 +1986,7 @@
1986
1986
  "dev": true
1987
1987
  },
1988
1988
  "node_modules/unicorn-magic": {
1989
- "version": "1.2.0",
1989
+ "version": "1.3.0",
1990
1990
  "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz",
1991
1991
  "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==",
1992
1992
  "dev": true,
@@ -2023,7 +2023,7 @@
2023
2023
  }
2024
2024
  },
2025
2025
  "node_modules/wordwrap": {
2026
- "version": "1.2.0",
2026
+ "version": "1.3.0",
2027
2027
  "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
2028
2028
  "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
2029
2029
  "dev": true
@@ -2082,7 +2082,7 @@
2082
2082
  }
2083
2083
  },
2084
2084
  "node_modules/yocto-queue": {
2085
- "version": "1.2.0",
2085
+ "version": "1.3.0",
2086
2086
  "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz",
2087
2087
  "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==",
2088
2088
  "dev": true,
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcp-serversdk-ruby",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "commonjs",
5
5
  "scripts": {
6
6
  "changelog": "conventional-changelog -i CHANGELOG.md -s --config ./changelog.config.js"
@@ -0,0 +1,78 @@
1
+
2
+
3
+ require 'spec_helper'
4
+ require 'net/http'
5
+ require 'json'
6
+ require_relative '../../lib/PCP-server-Ruby-SDK.rb'
7
+
8
+
9
+ RSpec.describe PCPServerSDK::Endpoints::AuthenticationApiClient do
10
+ let(:config) { double('PCPServerSDK::CommunicatorConfiguration', api_key: '', api_secret: '', host: 'https://api.example.com') }
11
+ let(:client) { PCPServerSDK::Endpoints::AuthenticationApiClient.new(config) }
12
+
13
+ describe '#get_authentication_tokens' do
14
+ let(:merchant_id) { 'merchant123' }
15
+ let(:request_id) { 'req-456' }
16
+ let(:success_response_body) {
17
+ {
18
+ token: 'jwt-token',
19
+ id: 'uuid-123',
20
+ creationDate: '2025-07-10T12:00:00Z',
21
+ expirationDate: '2025-07-10T12:10:00Z'
22
+ }.to_json
23
+ }
24
+ let(:error_body) {
25
+ PCPServerSDK::Models::ErrorResponse.new(
26
+ error_id: '1',
27
+ errors: [PCPServerSDK::Models::APIError.new(error_code: '1', message: 'Error 1')]
28
+ ).to_body.to_json
29
+ }
30
+
31
+ context 'when request is successful' do
32
+ let(:response) { double('Response', body: success_response_body, code: 200) }
33
+
34
+ before do
35
+ allow(client).to receive(:get_response).and_return(response)
36
+ end
37
+
38
+ it 'returns an AuthenticationToken' do
39
+ token = client.get_authentication_tokens(merchant_id, request_id)
40
+ expect(token).to be_a(PCPServerSDK::Models::AuthenticationToken)
41
+ expect(token.token).to eq('jwt-token')
42
+ expect(token.id).to eq('uuid-123')
43
+ expect(token.creation_date).to be_a(Time)
44
+ expect(token.expiration_date).to be_a(Time)
45
+ end
46
+ end
47
+
48
+ context 'when request is unsuccessful (400)' do
49
+ let(:response) { double('Response', body: error_body, code: 400) }
50
+
51
+ before do
52
+ allow(client).to receive(:get_response).and_return(response)
53
+ end
54
+
55
+ it 'raises an PCPServerSDK::Errors::ApiErrorResponseException' do
56
+ expect { client.get_authentication_tokens(merchant_id, request_id) }.to raise_error(PCPServerSDK::Errors::ApiErrorResponseException)
57
+ end
58
+ end
59
+
60
+ context 'when request is unsuccessful (500)' do
61
+ let(:response) { double('Response', body: '{}', code: 500) }
62
+
63
+ before do
64
+ allow(client).to receive(:get_response).and_return(response)
65
+ end
66
+
67
+ it 'raises an PCPServerSDK::Errors::ApiResponseRetrievalException' do
68
+ expect { client.get_authentication_tokens(merchant_id, request_id) }.to raise_error(PCPServerSDK::Errors::ApiResponseRetrievalException)
69
+ end
70
+ end
71
+
72
+ context 'when merchant_id is nil' do
73
+ it 'raises an ArgumentError' do
74
+ expect { client.get_authentication_tokens(nil, '2') }.to raise_error(TypeError, 'Merchant ID is required')
75
+ end
76
+ end
77
+ end
78
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcp-server-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PAYONE GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-26 00:00:00.000000000 Z
11
+ date: 2025-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -102,6 +102,7 @@ files:
102
102
  - lefthook.yml
103
103
  - lib/PCP-server-Ruby-SDK.rb
104
104
  - lib/PCP-server-Ruby-SDK/communicator_configuration.rb
105
+ - lib/PCP-server-Ruby-SDK/endpoints/authentication_api_client.rb
105
106
  - lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb
106
107
  - lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb
107
108
  - lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_method.rb
128
129
  - lib/PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_method_type.rb
129
130
  - lib/PCP-server-Ruby-SDK/models/applepay/apple_pay_payment_token.rb
131
+ - lib/PCP-server-Ruby-SDK/models/authentication_token.rb
130
132
  - lib/PCP-server-Ruby-SDK/models/authorization_mode.rb
131
133
  - lib/PCP-server-Ruby-SDK/models/avs_result.rb
132
134
  - lib/PCP-server-Ruby-SDK/models/bank_account_information.rb
@@ -278,6 +280,7 @@ files:
278
280
  - scripts.sh
279
281
  - sonar-project.properties
280
282
  - spec/communicator_configuration_spec.rb
283
+ - spec/endpoints/authentication_api_client_spec.rb
281
284
  - spec/endpoints/checkout_api_client_spec.rb
282
285
  - spec/endpoints/commerce_case_api_client_spec.rb
283
286
  - spec/endpoints/order_management_checkout_actions_api_client_spec.rb
@@ -315,4 +318,20 @@ rubygems_version: 3.4.20
315
318
  signing_key:
316
319
  specification_version: 4
317
320
  summary: Commerce Platform API Ruby Gem
318
- test_files: []
321
+ test_files:
322
+ - spec/communicator_configuration_spec.rb
323
+ - spec/endpoints/checkout_api_client_spec.rb
324
+ - spec/endpoints/authentication_api_client_spec.rb
325
+ - spec/endpoints/commerce_case_api_client_spec.rb
326
+ - spec/endpoints/order_management_checkout_actions_api_client_spec.rb
327
+ - spec/endpoints/payment_execution_api_client_spec.rb
328
+ - spec/endpoints/payment_information_api_client_spec.rb
329
+ - spec/errors/api_response_retrieval_exception_spec.rb
330
+ - spec/errors/api_error_response_exception_spec.rb
331
+ - spec/errors/api_exception_spec.rb
332
+ - spec/queries/get_commerce_cases_query_spec.rb
333
+ - spec/queries/get_checkouts_query_spec.rb
334
+ - spec/request_header_generator_spec.rb
335
+ - spec/spec_helper.rb
336
+ - spec/transformer/apple_pay_transformer_spec.rb
337
+ - spec/utils/server_meta_info_spec.rb