jamm 1.2.1 → 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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/jamm/api/api/payment_api.rb +61 -0
  4. data/lib/jamm/api/api/webhook_service_api.rb +59 -0
  5. data/lib/jamm/api/models/{v1_error.rb → apiv1_error.rb} +18 -9
  6. data/lib/jamm/api/models/v1_bank.rb +295 -0
  7. data/lib/jamm/api/models/v1_bank_assets.rb +231 -0
  8. data/lib/jamm/api/models/v1_bank_branch.rb +232 -0
  9. data/lib/jamm/api/models/v1_bank_information.rb +35 -7
  10. data/lib/jamm/api/models/v1_bank_quota.rb +243 -0
  11. data/lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb +227 -0
  12. data/lib/jamm/api/models/v1_charge_message.rb +1 -1
  13. data/lib/jamm/api/models/v1_deposit_type.rb +42 -0
  14. data/lib/jamm/api/models/v1_error_detail.rb +220 -0
  15. data/lib/jamm/api/models/v1_error_response.rb +230 -0
  16. data/lib/jamm/api/models/v1_error_type.rb +58 -0
  17. data/lib/jamm/api/models/v1_event_type.rb +2 -1
  18. data/lib/jamm/api/models/v1_get_bank_response.rb +207 -0
  19. data/lib/jamm/api/models/v1_get_branch_response.rb +207 -0
  20. data/lib/jamm/api/models/v1_get_branches_response.rb +208 -0
  21. data/lib/jamm/api/models/v1_get_major_banks_response.rb +217 -0
  22. data/lib/jamm/api/models/v1_message_response.rb +12 -7
  23. data/lib/jamm/api/models/v1_on_session_payment_data.rb +222 -0
  24. data/lib/jamm/api/models/v1_on_session_payment_error.rb +237 -0
  25. data/lib/jamm/api/models/v1_on_session_payment_error_code.rb +49 -0
  26. data/lib/jamm/api/models/v1_on_session_payment_request.rb +223 -0
  27. data/lib/jamm/api/models/v1_on_session_payment_response.rb +218 -0
  28. data/lib/jamm/api/models/v1_search_banks_response.rb +208 -0
  29. data/lib/jamm/api/models/v1_search_branches_response.rb +208 -0
  30. data/lib/jamm/api/models/v1_user_account_message.rb +223 -0
  31. data/lib/jamm/api.rb +22 -1
  32. data/lib/jamm/customer.rb +0 -2
  33. data/lib/jamm/errors.rb +27 -1
  34. data/lib/jamm/version.rb +1 -1
  35. metadata +24 -3
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+
3
+ # #Jamm API
4
+ #
5
+ # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ #
7
+ # The version of the OpenAPI document: 1.0
8
+ #
9
+ # Generated by: https://openapi-generator.tech
10
+ # Generator version: 7.9.0
11
+ #
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ # UserAccountMessage contains information about a user account operation.
18
+ class UserAccountMessage
19
+ attr_accessor :customer, :email, :deleted_at, :merchant_name
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :customer => :customer,
25
+ :email => :email,
26
+ :deleted_at => :deletedAt,
27
+ :merchant_name => :merchantName
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :customer => :String,
40
+ :email => :String,
41
+ :deleted_at => :String,
42
+ :merchant_name => :String
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ raise ArgumentError, 'The input argument (attributes) must be a hash in `Api::UserAccountMessage` initialize method' unless attributes.is_a?(Hash)
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) do |(k, v), h|
58
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Api::UserAccountMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym)
59
+
60
+ h[k.to_sym] = v
61
+ end
62
+
63
+ self.customer = attributes[:customer] if attributes.key?(:customer)
64
+
65
+ self.email = attributes[:email] if attributes.key?(:email)
66
+
67
+ self.deleted_at = attributes[:deleted_at] if attributes.key?(:deleted_at)
68
+
69
+ return unless attributes.key?(:merchant_name)
70
+
71
+ self.merchant_name = attributes[:merchant_name]
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
78
+ []
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ warn '[DEPRECATED] the `valid?` method is obsolete'
85
+ true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(other)
91
+ return true if equal?(other)
92
+
93
+ self.class == other.class &&
94
+ customer == other.customer &&
95
+ email == other.email &&
96
+ deleted_at == other.deleted_at &&
97
+ merchant_name == other.merchant_name
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(other)
103
+ self == other
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Integer] Hash code
108
+ def hash
109
+ [customer, email, deleted_at, merchant_name].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def self.build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+
118
+ attributes = attributes.transform_keys(&:to_sym)
119
+ transformed_hash = {}
120
+ openapi_types.each_pair do |key, type|
121
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
122
+ transformed_hash[key.to_s] = nil
123
+ elsif type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the attribute
125
+ # is documented as an array but the input is not
126
+ transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) } if attributes[attribute_map[key]].is_a?(Array)
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Api.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+ end
223
+ end
data/lib/jamm/api.rb CHANGED
@@ -17,13 +17,19 @@ require 'jamm/api/version'
17
17
  require 'jamm/api/configuration'
18
18
 
19
19
  # Models
20
+ require 'jamm/api/models/apiv1_error'
20
21
  require 'jamm/api/models/apiv1_status'
21
22
  require 'jamm/api/models/customer_service_update_customer_body'
22
23
  require 'jamm/api/models/googlerpc_status'
23
24
  require 'jamm/api/models/protobuf_any'
24
25
  require 'jamm/api/models/v1_add_charge_request'
25
26
  require 'jamm/api/models/v1_add_charge_response'
27
+ require 'jamm/api/models/v1_bank'
28
+ require 'jamm/api/models/v1_bank_assets'
29
+ require 'jamm/api/models/v1_bank_branch'
26
30
  require 'jamm/api/models/v1_bank_information'
31
+ require 'jamm/api/models/v1_bank_quota'
32
+ require 'jamm/api/models/v1_bank_scheduled_maintenance_period'
27
33
  require 'jamm/api/models/v1_buyer'
28
34
  require 'jamm/api/models/v1_charge'
29
35
  require 'jamm/api/models/v1_charge_message'
@@ -40,12 +46,19 @@ require 'jamm/api/models/v1_create_customer_request'
40
46
  require 'jamm/api/models/v1_create_customer_response'
41
47
  require 'jamm/api/models/v1_customer'
42
48
  require 'jamm/api/models/v1_delete_customer_response'
43
- require 'jamm/api/models/v1_error'
49
+ require 'jamm/api/models/v1_deposit_type'
50
+ require 'jamm/api/models/v1_error_detail'
51
+ require 'jamm/api/models/v1_error_response'
52
+ require 'jamm/api/models/v1_error_type'
44
53
  require 'jamm/api/models/v1_event_type'
54
+ require 'jamm/api/models/v1_get_bank_response'
55
+ require 'jamm/api/models/v1_get_branch_response'
56
+ require 'jamm/api/models/v1_get_branches_response'
45
57
  require 'jamm/api/models/v1_get_charge_response'
46
58
  require 'jamm/api/models/v1_get_charges_response'
47
59
  require 'jamm/api/models/v1_get_contract_response'
48
60
  require 'jamm/api/models/v1_get_customer_response'
61
+ require 'jamm/api/models/v1_get_major_banks_response'
49
62
  require 'jamm/api/models/v1_initial_charge'
50
63
  require 'jamm/api/models/v1_kyc_status'
51
64
  require 'jamm/api/models/v1_merchant'
@@ -54,12 +67,20 @@ require 'jamm/api/models/v1_merchant_webhook_message'
54
67
  require 'jamm/api/models/v1_message_response'
55
68
  require 'jamm/api/models/v1_off_session_payment_request'
56
69
  require 'jamm/api/models/v1_off_session_payment_response'
70
+ require 'jamm/api/models/v1_on_session_payment_data'
71
+ require 'jamm/api/models/v1_on_session_payment_error'
72
+ require 'jamm/api/models/v1_on_session_payment_error_code'
73
+ require 'jamm/api/models/v1_on_session_payment_request'
74
+ require 'jamm/api/models/v1_on_session_payment_response'
57
75
  require 'jamm/api/models/v1_pagination'
58
76
  require 'jamm/api/models/v1_payment_authorization_status'
59
77
  require 'jamm/api/models/v1_payment_link'
60
78
  require 'jamm/api/models/v1_ping_response'
79
+ require 'jamm/api/models/v1_search_banks_response'
80
+ require 'jamm/api/models/v1_search_branches_response'
61
81
  require 'jamm/api/models/v1_url'
62
82
  require 'jamm/api/models/v1_update_customer_response'
83
+ require 'jamm/api/models/v1_user_account_message'
63
84
  require 'jamm/api/models/v1_withdraw_request'
64
85
  require 'jamm/api/models/v1_withdraw_response'
65
86
 
data/lib/jamm/customer.rb CHANGED
@@ -37,8 +37,6 @@ module Jamm
37
37
 
38
38
  r.customer
39
39
  rescue Jamm::OpenAPI::ApiError => e
40
- return nil if [404].include?(e.code)
41
-
42
40
  raise Jamm::ApiError.from_error(e)
43
41
  end
44
42
 
data/lib/jamm/errors.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'jamm/api/models/v1_error_type'
4
+
3
5
  module Jamm
4
6
  class JammError < StandardError
5
7
  attr_reader :message, :http_body, :http_headers, :http_status, :json_body
@@ -33,13 +35,28 @@ module Jamm
33
35
  # - Jamm: code is string, message is string originating from Jamm's protobuf definition.
34
36
  # - OpenAPI: code is integer, message is string originating from ConnectRPC error format.
35
37
  class ApiError < StandardError
36
- attr_reader :code, :error_code, :message, :headers, :body
38
+ attr_reader :code, :error_code, :error_type, :message, :headers, :body
37
39
 
38
40
  # Add this class method to convert StandardError to ApiError
39
41
  def self.from_error(e)
42
+ error_type = Api::ErrorType::UNSPECIFIED
43
+
44
+ # Convert Protobuf oriented error to error type.
45
+ details = JSON.parse(e.response_body)['details']
46
+
47
+ if details.is_a?(Array) && details.any?
48
+ details.each do |d|
49
+ # Loop through all error types to find a match
50
+ Api::ErrorType.all_vars.each do |type|
51
+ error_type = type.to_s if d['debug'] == type.to_s
52
+ end
53
+ end
54
+ end
55
+
40
56
  new(
41
57
  code: e.code,
42
58
  message: e.message,
59
+ error_type: error_type,
43
60
  response_headers: e.response_headers,
44
61
  response_body: e.response_body
45
62
  )
@@ -49,6 +66,7 @@ module Jamm
49
66
  # Check code existence and convert to string if it's integer
50
67
  @code = args[:code]
51
68
  @message = args[:message]
69
+ @error_type = args[:error_type]
52
70
  @headers = args[:response_headers]
53
71
 
54
72
  raw_body = if args[:response_body].nil?
@@ -117,4 +135,12 @@ module Jamm
117
135
  "#{status_string}#{@message}"
118
136
  end
119
137
  end
138
+
139
+ # ErrorType is a wrapper around Api::ErrorType to encapsulate OpenAPI related constants.
140
+ class ErrorType
141
+ # Dynamically copy constants from Api::ErrorType
142
+ Api::ErrorType.constants(false).each do |const_name|
143
+ const_set(const_name, Api::ErrorType.const_get(const_name))
144
+ end
145
+ end
120
146
  end
data/lib/jamm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jamm
4
- VERSION = '1.2.1'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jamm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-21 00:00:00.000000000 Z
11
+ date: 2025-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -67,13 +67,19 @@ files:
67
67
  - lib/jamm/api/api_client.rb
68
68
  - lib/jamm/api/api_error.rb
69
69
  - lib/jamm/api/configuration.rb
70
+ - lib/jamm/api/models/apiv1_error.rb
70
71
  - lib/jamm/api/models/apiv1_status.rb
71
72
  - lib/jamm/api/models/customer_service_update_customer_body.rb
72
73
  - lib/jamm/api/models/googlerpc_status.rb
73
74
  - lib/jamm/api/models/protobuf_any.rb
74
75
  - lib/jamm/api/models/v1_add_charge_request.rb
75
76
  - lib/jamm/api/models/v1_add_charge_response.rb
77
+ - lib/jamm/api/models/v1_bank.rb
78
+ - lib/jamm/api/models/v1_bank_assets.rb
79
+ - lib/jamm/api/models/v1_bank_branch.rb
76
80
  - lib/jamm/api/models/v1_bank_information.rb
81
+ - lib/jamm/api/models/v1_bank_quota.rb
82
+ - lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb
77
83
  - lib/jamm/api/models/v1_buyer.rb
78
84
  - lib/jamm/api/models/v1_charge.rb
79
85
  - lib/jamm/api/models/v1_charge_message.rb
@@ -90,12 +96,19 @@ files:
90
96
  - lib/jamm/api/models/v1_create_customer_response.rb
91
97
  - lib/jamm/api/models/v1_customer.rb
92
98
  - lib/jamm/api/models/v1_delete_customer_response.rb
93
- - lib/jamm/api/models/v1_error.rb
99
+ - lib/jamm/api/models/v1_deposit_type.rb
100
+ - lib/jamm/api/models/v1_error_detail.rb
101
+ - lib/jamm/api/models/v1_error_response.rb
102
+ - lib/jamm/api/models/v1_error_type.rb
94
103
  - lib/jamm/api/models/v1_event_type.rb
104
+ - lib/jamm/api/models/v1_get_bank_response.rb
105
+ - lib/jamm/api/models/v1_get_branch_response.rb
106
+ - lib/jamm/api/models/v1_get_branches_response.rb
95
107
  - lib/jamm/api/models/v1_get_charge_response.rb
96
108
  - lib/jamm/api/models/v1_get_charges_response.rb
97
109
  - lib/jamm/api/models/v1_get_contract_response.rb
98
110
  - lib/jamm/api/models/v1_get_customer_response.rb
111
+ - lib/jamm/api/models/v1_get_major_banks_response.rb
99
112
  - lib/jamm/api/models/v1_initial_charge.rb
100
113
  - lib/jamm/api/models/v1_kyc_status.rb
101
114
  - lib/jamm/api/models/v1_merchant.rb
@@ -104,12 +117,20 @@ files:
104
117
  - lib/jamm/api/models/v1_message_response.rb
105
118
  - lib/jamm/api/models/v1_off_session_payment_request.rb
106
119
  - lib/jamm/api/models/v1_off_session_payment_response.rb
120
+ - lib/jamm/api/models/v1_on_session_payment_data.rb
121
+ - lib/jamm/api/models/v1_on_session_payment_error.rb
122
+ - lib/jamm/api/models/v1_on_session_payment_error_code.rb
123
+ - lib/jamm/api/models/v1_on_session_payment_request.rb
124
+ - lib/jamm/api/models/v1_on_session_payment_response.rb
107
125
  - lib/jamm/api/models/v1_pagination.rb
108
126
  - lib/jamm/api/models/v1_payment_authorization_status.rb
109
127
  - lib/jamm/api/models/v1_payment_link.rb
110
128
  - lib/jamm/api/models/v1_ping_response.rb
129
+ - lib/jamm/api/models/v1_search_banks_response.rb
130
+ - lib/jamm/api/models/v1_search_branches_response.rb
111
131
  - lib/jamm/api/models/v1_update_customer_response.rb
112
132
  - lib/jamm/api/models/v1_url.rb
133
+ - lib/jamm/api/models/v1_user_account_message.rb
113
134
  - lib/jamm/api/models/v1_withdraw_request.rb
114
135
  - lib/jamm/api/models/v1_withdraw_response.rb
115
136
  - lib/jamm/api/version.rb