pcp-server-ruby-sdk 1.2.0 → 1.3.1

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/PCP-server-Ruby-SDK.gemspec +1 -1
  4. data/README.md +126 -0
  5. data/example-app/commerce_case_api_example.rb +9 -1
  6. data/example-app/example.rb +73 -1
  7. data/lib/PCP-server-Ruby-SDK/communicator_configuration.rb +6 -3
  8. data/lib/PCP-server-Ruby-SDK/endpoints/authentication_api_client.rb +33 -0
  9. data/lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb +59 -8
  10. data/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb +2 -2
  11. data/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb +2 -2
  12. data/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb +2 -2
  13. data/lib/PCP-server-Ruby-SDK/endpoints/payment_execution_api_client.rb +2 -2
  14. data/lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb +2 -2
  15. data/lib/PCP-server-Ruby-SDK/models/authentication_token.rb +189 -0
  16. data/lib/PCP-server-Ruby-SDK/version.rb +1 -1
  17. data/lib/PCP-server-Ruby-SDK.rb +2 -0
  18. data/package-lock.json +187 -187
  19. data/package.json +1 -1
  20. data/spec/communicator_configuration_spec.rb +27 -0
  21. data/spec/endpoints/authentication_api_client_spec.rb +78 -0
  22. data/spec/endpoints/base_api_client_spec.rb +222 -0
  23. data/spec/endpoints/checkout_api_client_spec.rb +1 -1
  24. data/spec/endpoints/commerce_case_api_client_spec.rb +1 -1
  25. data/spec/endpoints/order_management_checkout_actions_api_client_spec.rb +1 -1
  26. data/spec/endpoints/payment_execution_api_client_spec.rb +1 -1
  27. data/spec/endpoints/payment_information_api_client_spec.rb +1 -1
  28. data/spec/spec_helper.rb +9 -0
  29. metadata +24 -3
@@ -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.1'
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'