jamm 1.0.6 → 1.0.9

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +9 -1
  4. data/Rakefile +5 -0
  5. data/lib/jamm/api/api/customer_api.rb +68 -10
  6. data/lib/jamm/api/api/healthcheck_api.rb +2 -2
  7. data/lib/jamm/api/api/payment_api.rb +145 -20
  8. data/lib/jamm/api/api/webhook_service_api.rb +82 -0
  9. data/lib/jamm/api/api_client.rb +2 -2
  10. data/lib/jamm/api/api_error.rb +2 -2
  11. data/lib/jamm/api/configuration.rb +2 -2
  12. data/lib/jamm/api/models/customer_service_update_customer_body.rb +9 -4
  13. data/lib/jamm/api/models/{rpc_status.rb → googlerpc_status.rb} +5 -5
  14. data/lib/jamm/api/models/protobuf_any.rb +2 -2
  15. data/lib/jamm/api/models/v1_add_charge_request.rb +2 -2
  16. data/lib/jamm/api/models/v1_add_charge_response.rb +2 -2
  17. data/lib/jamm/api/models/v1_buyer.rb +11 -3
  18. data/lib/jamm/api/models/v1_charge.rb +2 -2
  19. data/lib/jamm/api/models/v1_charge_message.rb +292 -0
  20. data/lib/jamm/api/models/v1_charge_message_status.rb +44 -0
  21. data/lib/jamm/api/models/v1_charge_result.rb +285 -0
  22. data/lib/jamm/api/models/v1_contract.rb +2 -2
  23. data/lib/jamm/api/models/v1_contract_status.rb +2 -2
  24. data/lib/jamm/api/models/v1_create_contract_with_charge_request.rb +2 -2
  25. data/lib/jamm/api/models/v1_create_contract_with_charge_response.rb +2 -2
  26. data/lib/jamm/api/models/v1_create_contract_without_charge_request.rb +2 -2
  27. data/lib/jamm/api/models/v1_create_contract_without_charge_response.rb +2 -2
  28. data/lib/jamm/api/models/v1_create_customer_request.rb +2 -2
  29. data/lib/jamm/api/models/v1_create_customer_response.rb +2 -2
  30. data/lib/jamm/api/models/v1_customer.rb +9 -4
  31. data/lib/jamm/api/models/v1_delete_customer_response.rb +2 -2
  32. data/lib/jamm/api/models/v1_event_type.rb +45 -0
  33. data/lib/jamm/api/models/v1_get_charge_response.rb +212 -0
  34. data/lib/jamm/api/models/v1_get_charges_response.rb +214 -0
  35. data/lib/jamm/api/models/v1_get_contract_response.rb +13 -13
  36. data/lib/jamm/api/models/v1_get_customer_response.rb +2 -2
  37. data/lib/jamm/api/models/v1_initial_charge.rb +2 -2
  38. data/lib/jamm/api/models/v1_merchant.rb +2 -2
  39. data/lib/jamm/api/models/v1_merchant_customer.rb +2 -2
  40. data/lib/jamm/api/models/v1_merchant_webhook_message.rb +259 -0
  41. data/lib/jamm/api/models/v1_message_response.rb +212 -0
  42. data/lib/jamm/api/models/v1_pagination.rb +212 -0
  43. data/lib/jamm/api/models/v1_payment_link.rb +2 -2
  44. data/lib/jamm/api/models/v1_ping_response.rb +2 -2
  45. data/lib/jamm/api/models/v1_update_customer_response.rb +2 -2
  46. data/lib/jamm/api/models/v1_url.rb +2 -2
  47. data/lib/jamm/api/models/v1_withdraw_request.rb +212 -0
  48. data/lib/jamm/api/models/v1_withdraw_response.rb +212 -0
  49. data/lib/jamm/api/version.rb +2 -2
  50. data/lib/jamm/api.rb +15 -3
  51. data/lib/jamm/api_patches.rb +14 -0
  52. data/lib/jamm/charge.rb +43 -0
  53. data/lib/jamm/client.rb +1 -1
  54. data/lib/jamm/contract.rb +35 -0
  55. data/lib/jamm/customer.rb +24 -9
  56. data/lib/jamm/healthcheck.rb +14 -0
  57. data/lib/jamm/openapi.rb +10 -0
  58. data/lib/jamm/version.rb +1 -1
  59. data/lib/jamm/webhook.rb +35 -0
  60. data/lib/jamm.rb +16 -14
  61. metadata +21 -4
  62. data/lib/jamm/payment.rb +0 -27
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jamm/api'
4
+
5
+ module Jamm
6
+ # Customer wrapper for OpenAPI definitions.
7
+ module OpenAPI
8
+ include Api
9
+ end
10
+ 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.0.6'
4
+ VERSION = '1.0.9'
5
5
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'base64'
6
+ require 'jamm/errors'
7
+
8
+ module Jamm
9
+ module Webhook
10
+ # Parse command is for parsing the received webhook message.
11
+ # It does not call anything remotely, instead returns the suitable object.
12
+ def self.parse(json)
13
+ out = {
14
+ id: json[:id],
15
+ signature: json[:signature],
16
+ merchant_id: json[:merchantId],
17
+ event_type: json[:eventType],
18
+ content: nil,
19
+ created_at: json[:createdAt]
20
+ }
21
+
22
+ case json[:eventType]
23
+ when Jamm::OpenAPI::EventType::CHARGE_CREATED
24
+ out[:content] = Jamm::OpenAPI::ChargeMessage.new(json[:content])
25
+ return out
26
+
27
+ when Jamm::OpenAPI::EventType::CHARGE_UPDATED
28
+ out[:content] = Jamm::OpenAPI::ChargeMessage.new(json[:content])
29
+ return out
30
+ end
31
+
32
+ raise Jamm::Error, 'Unknown event type'
33
+ end
34
+ end
35
+ end
data/lib/jamm.rb CHANGED
@@ -4,15 +4,21 @@ require 'rest-client'
4
4
  require 'openssl'
5
5
  require 'json'
6
6
 
7
- require 'jamm/api'
8
7
  require 'jamm/client'
9
8
  require 'jamm/errors'
10
9
  require 'jamm/oauth'
10
+ require 'jamm/openapi'
11
11
  require 'jamm/version'
12
12
 
13
13
  # OpenAPI wrappers
14
+ require 'jamm/charge'
14
15
  require 'jamm/customer'
15
- require 'jamm/payment'
16
+ require 'jamm/contract'
17
+ require 'jamm/healthcheck'
18
+ require 'jamm/webhook'
19
+
20
+ # Patches
21
+ require 'jamm/api_patches'
16
22
 
17
23
  # Jamm Ruby SDK
18
24
  module Jamm
@@ -23,10 +29,6 @@ module Jamm
23
29
  @read_timeout = 90
24
30
  @max_retry = 0
25
31
 
26
- # Include OpenAPI generated module into root Jamm namespace.
27
- # The OpenAPI sub-modules and methods can be accessed via Jamm::{foo}
28
- include Api
29
-
30
32
  class << self
31
33
  attr_accessor :api, :client_id, :client_secret, :api_base, :env, :oauth_base, :api_version, :connect_base,
32
34
  :openapi, :open_timeout, :read_timeout, :max_retry, :retry_initial_delay, :retry_max_delay
@@ -40,20 +42,20 @@ module Jamm
40
42
  when 'prod'
41
43
  self.oauth_base = 'https://merchant-identity.jamm-pay.jp'
42
44
 
43
- self.openapi = Jamm::ApiClient.new
45
+ self.openapi = Jamm::OpenAPI::ApiClient.new
44
46
  openapi.config.host = 'api.jamm-pay.jp'
45
47
 
46
- # Debugger mode, uncomment when needed
47
- # when 'local'
48
- # self.oauth_base = "https://merchant-identity.#{env}.jamm-pay.jp"
49
-
50
- # self.openapi = Jamm::ApiClient.new
51
- # openapi.config.host = 'api.jamm.test'
48
+ when 'local'
49
+ self.oauth_base = 'https://merchant-identity.develop.jamm-pay.jp'
52
50
 
51
+ self.openapi = Jamm::OpenAPI::ApiClient.new
52
+ openapi.config.host = 'api.jamm.test'
53
+ openapi.config.verify_ssl = false
54
+ openapi.config.verify_ssl_host = false
53
55
  else
54
56
  self.oauth_base = "https://merchant-identity.#{env}.jamm-pay.jp"
55
57
 
56
- self.openapi = Jamm::ApiClient.new
58
+ self.openapi = Jamm::OpenAPI::ApiClient.new
57
59
  openapi.config.host = "api.#{env}.jamm-pay.jp"
58
60
  end
59
61
 
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.0.6
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-04 00:00:00.000000000 Z
11
+ date: 2024-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -63,16 +63,20 @@ files:
63
63
  - lib/jamm/api/api/customer_api.rb
64
64
  - lib/jamm/api/api/healthcheck_api.rb
65
65
  - lib/jamm/api/api/payment_api.rb
66
+ - lib/jamm/api/api/webhook_service_api.rb
66
67
  - lib/jamm/api/api_client.rb
67
68
  - lib/jamm/api/api_error.rb
68
69
  - lib/jamm/api/configuration.rb
69
70
  - lib/jamm/api/models/customer_service_update_customer_body.rb
71
+ - lib/jamm/api/models/googlerpc_status.rb
70
72
  - lib/jamm/api/models/protobuf_any.rb
71
- - lib/jamm/api/models/rpc_status.rb
72
73
  - lib/jamm/api/models/v1_add_charge_request.rb
73
74
  - lib/jamm/api/models/v1_add_charge_response.rb
74
75
  - lib/jamm/api/models/v1_buyer.rb
75
76
  - lib/jamm/api/models/v1_charge.rb
77
+ - lib/jamm/api/models/v1_charge_message.rb
78
+ - lib/jamm/api/models/v1_charge_message_status.rb
79
+ - lib/jamm/api/models/v1_charge_result.rb
76
80
  - lib/jamm/api/models/v1_contract.rb
77
81
  - lib/jamm/api/models/v1_contract_status.rb
78
82
  - lib/jamm/api/models/v1_create_contract_with_charge_request.rb
@@ -83,22 +87,35 @@ files:
83
87
  - lib/jamm/api/models/v1_create_customer_response.rb
84
88
  - lib/jamm/api/models/v1_customer.rb
85
89
  - lib/jamm/api/models/v1_delete_customer_response.rb
90
+ - lib/jamm/api/models/v1_event_type.rb
91
+ - lib/jamm/api/models/v1_get_charge_response.rb
92
+ - lib/jamm/api/models/v1_get_charges_response.rb
86
93
  - lib/jamm/api/models/v1_get_contract_response.rb
87
94
  - lib/jamm/api/models/v1_get_customer_response.rb
88
95
  - lib/jamm/api/models/v1_initial_charge.rb
89
96
  - lib/jamm/api/models/v1_merchant.rb
90
97
  - lib/jamm/api/models/v1_merchant_customer.rb
98
+ - lib/jamm/api/models/v1_merchant_webhook_message.rb
99
+ - lib/jamm/api/models/v1_message_response.rb
100
+ - lib/jamm/api/models/v1_pagination.rb
91
101
  - lib/jamm/api/models/v1_payment_link.rb
92
102
  - lib/jamm/api/models/v1_ping_response.rb
93
103
  - lib/jamm/api/models/v1_update_customer_response.rb
94
104
  - lib/jamm/api/models/v1_url.rb
105
+ - lib/jamm/api/models/v1_withdraw_request.rb
106
+ - lib/jamm/api/models/v1_withdraw_response.rb
95
107
  - lib/jamm/api/version.rb
108
+ - lib/jamm/api_patches.rb
109
+ - lib/jamm/charge.rb
96
110
  - lib/jamm/client.rb
111
+ - lib/jamm/contract.rb
97
112
  - lib/jamm/customer.rb
98
113
  - lib/jamm/errors.rb
114
+ - lib/jamm/healthcheck.rb
99
115
  - lib/jamm/oauth.rb
100
- - lib/jamm/payment.rb
116
+ - lib/jamm/openapi.rb
101
117
  - lib/jamm/version.rb
118
+ - lib/jamm/webhook.rb
102
119
  homepage: https://jamm-pay.jp
103
120
  licenses:
104
121
  - MIT
data/lib/jamm/payment.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rest-client'
4
- require 'json'
5
- require 'base64'
6
- require 'jamm/errors'
7
-
8
- module Jamm
9
- module Payment
10
- def self.contract_with_charge(**params)
11
- request = Jamm::CreateContractWithChargeRequest.new(params)
12
-
13
- Jamm::PaymentApi.new(Jamm::Client.handler).create_contract_with_charge(request)
14
- end
15
-
16
- def self.get_contract(contract:)
17
- Jamm::PaymentApi.new(Jamm::Client.handler).get_contract(contract)
18
- end
19
-
20
- def self.add_charge(**params)
21
- request = Jamm::AddChargeRequest.new(params)
22
-
23
- p = Jamm::PaymentApi.new(Jamm::Client.handler)
24
- p.add_charge(request)
25
- end
26
- end
27
- end