jamm 0.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/.gitignore +6 -57
- data/.rubocop.yml +18 -25
- data/Gemfile +4 -0
- data/Gemfile.lock +99 -0
- data/README.md +4 -4
- data/Rakefile +2 -0
- data/jamm.gemspec +16 -3
- data/lib/jamm/api/api/customer_api.rb +265 -0
- data/lib/jamm/api/api/healthcheck_api.rb +76 -0
- data/lib/jamm/api/api/payment_api.rb +145 -0
- data/lib/jamm/api/api_client.rb +385 -0
- data/lib/jamm/api/api_error.rb +58 -0
- data/lib/jamm/api/configuration.rb +293 -0
- data/lib/jamm/api/models/customer_service_update_customer_body.rb +247 -0
- data/lib/jamm/api/models/protobuf_any.rb +209 -0
- data/lib/jamm/api/models/rpc_status.rb +218 -0
- data/lib/jamm/api/models/v1_buyer.rb +274 -0
- data/lib/jamm/api/models/v1_charge.rb +233 -0
- data/lib/jamm/api/models/v1_contract.rb +225 -0
- data/lib/jamm/api/models/v1_create_contract_with_charge_request.rb +217 -0
- data/lib/jamm/api/models/v1_create_contract_with_charge_response.rb +222 -0
- data/lib/jamm/api/models/v1_create_contract_without_charge_request.rb +212 -0
- data/lib/jamm/api/models/v1_create_contract_without_charge_response.rb +217 -0
- data/lib/jamm/api/models/v1_create_customer_request.rb +207 -0
- data/lib/jamm/api/models/v1_create_customer_response.rb +207 -0
- data/lib/jamm/api/models/v1_customer.rb +223 -0
- data/lib/jamm/api/models/v1_delete_customer_response.rb +207 -0
- data/lib/jamm/api/models/v1_get_customer_response.rb +207 -0
- data/lib/jamm/api/models/v1_initial_charge.rb +225 -0
- data/lib/jamm/api/models/v1_merchant.rb +212 -0
- data/lib/jamm/api/models/v1_merchant_customer.rb +213 -0
- data/lib/jamm/api/models/v1_payment_link.rb +221 -0
- data/lib/jamm/api/models/v1_ping_response.rb +207 -0
- data/lib/jamm/api/models/v1_update_customer_response.rb +207 -0
- data/lib/jamm/api/models/v1_url.rb +216 -0
- data/lib/jamm/api/version.rb +15 -0
- data/lib/jamm/api.rb +64 -0
- data/lib/jamm/errors.rb +4 -14
- data/lib/jamm/oauth.rb +3 -1
- data/lib/jamm/version.rb +3 -1
- data/lib/jamm.rb +14 -127
- metadata +59 -38
- data/.github/workflows/build.yml +0 -23
- data/.github/workflows/ruby-publish.yml +0 -24
- data/CONTRIBUTORS +0 -1
- data/images/jamm_logo.png +0 -0
- data/lib/jamm/api_operations/create.rb +0 -16
- data/lib/jamm/api_operations/get.rb +0 -16
- data/lib/jamm/api_operations/list.rb +0 -16
- data/lib/jamm/api_operations/update.rb +0 -16
- data/lib/jamm/api_resource.rb +0 -5
- data/lib/jamm/charge.rb +0 -10
- data/lib/jamm/jamm_object.rb +0 -249
- data/lib/jamm/payment.rb +0 -18
- data/lib/jamm/request.rb +0 -13
- data/lib/jamm/time_util.rb +0 -41
- data/lib/jamm/token.rb +0 -10
- data/lib/jamm/util.rb +0 -76
- data/test/jamm/charge_test.rb +0 -56
- data/test/jamm/oauth_test.rb +0 -47
- data/test/jamm/payment_test.rb +0 -17
- data/test/jamm/time_util_test.rb +0 -18
- data/test/jamm/token_test.rb +0 -52
- data/test/test_data.rb +0 -118
- data/test/test_helper.rb +0 -59
data/test/test_data.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
module Jamm
|
2
|
-
module TestData
|
3
|
-
def test_response(body, code = 200)
|
4
|
-
body = JSON.generate(body) unless body.is_a? String
|
5
|
-
m = mock
|
6
|
-
m.instance_variable_set('@jamm_values', { body: body, code: code })
|
7
|
-
def m.body
|
8
|
-
@jamm_values[:body]
|
9
|
-
end
|
10
|
-
|
11
|
-
def m.code
|
12
|
-
@jamm_values[:code]
|
13
|
-
end
|
14
|
-
m
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_bad_request
|
18
|
-
{
|
19
|
-
"timestamp": '2023-11-07T15:30:00.000+09:00',
|
20
|
-
"status": 400,
|
21
|
-
"error": 'Bad Request',
|
22
|
-
"message": 'some error message',
|
23
|
-
"path": '/api/v0/deduction_contract_tokens'
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_cognito_response
|
28
|
-
{
|
29
|
-
access_token: 'access_token'
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_token_list
|
34
|
-
[test_token]
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_token
|
38
|
-
{
|
39
|
-
contract_id: 'dt_f5e599d3-8b9e-4d46-9a52-1a37e7b5b8ef',
|
40
|
-
status: 'CREATED',
|
41
|
-
description: 'Gold Gym',
|
42
|
-
initial_amount: 1000,
|
43
|
-
currency: 'JPY',
|
44
|
-
metadata: {
|
45
|
-
key1: 'value1',
|
46
|
-
key2: 'value2'
|
47
|
-
},
|
48
|
-
created_at: '2023-11-07T15:30:00.000+03:00',
|
49
|
-
updated_at: '2023-11-11T15:30:00.000+03:00'
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_create_payment_request
|
54
|
-
{
|
55
|
-
charge: {
|
56
|
-
description: 'Gold Gym',
|
57
|
-
amount: 10_000,
|
58
|
-
currency: 'JPY'
|
59
|
-
},
|
60
|
-
redirect: {
|
61
|
-
success_url: 'http://www.example.com/success',
|
62
|
-
failure_url: 'http://www.example.com/fail',
|
63
|
-
info_url: 'http://www.example.com/customer_service',
|
64
|
-
expired_at: '2024-04-11T16:28:07.420Z'
|
65
|
-
},
|
66
|
-
metadata: {
|
67
|
-
key1: 'value1',
|
68
|
-
key2: 'value2'
|
69
|
-
},
|
70
|
-
customer: {
|
71
|
-
name: 'Taro Taro',
|
72
|
-
katakanaFirstName: 'タロ',
|
73
|
-
katakanaLastName: 'タロ',
|
74
|
-
gender: 'MALE',
|
75
|
-
postNum: '112-0001',
|
76
|
-
address: '東京都渋谷区1−1−1',
|
77
|
-
email: 'test@jamm-pay.jp',
|
78
|
-
phone: '010-1234-5678',
|
79
|
-
birthdate: '2000-01-01'
|
80
|
-
},
|
81
|
-
options: {
|
82
|
-
force_kyc: true
|
83
|
-
}
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_create_payment_response
|
88
|
-
{
|
89
|
-
token_id: 'dt_f5e599d3-8b9e-4d46-9a52-1a37e7b5b8ef',
|
90
|
-
charge_id: 'ct_h5e599d3-0000-4d46-9a52-1a37e7b5b8ef',
|
91
|
-
payment_url: 'https://jamm-pay.com/K5e599d3-8b9e-4d46-9a72-1a37e7b5b8ef',
|
92
|
-
created_at: '2023-11-07T15:30:00.000+03:00'
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_charges
|
97
|
-
[test_charge]
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_charge
|
101
|
-
{
|
102
|
-
charge_id: 'ct_h5e599d3-0000-4d46-9a52-1a37e7b5b8ef',
|
103
|
-
contract_id: 'dt_f5e599d3-8b9e-4d46-9a52-1a37e7b5b8ef',
|
104
|
-
status: 'CREATED',
|
105
|
-
description: 'Gold Gym',
|
106
|
-
amount: 1000,
|
107
|
-
amount_refunded: 800,
|
108
|
-
currency: 'JPY',
|
109
|
-
merchant_metadata: {
|
110
|
-
key1: 'value1',
|
111
|
-
key2: 'value2'
|
112
|
-
},
|
113
|
-
created_at: '2023-11-07T15:30:00.000+03:00',
|
114
|
-
updated_at: '2023-11-11T15:30:00.000+03:00'
|
115
|
-
}
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.join(File.dirname(__FILE__), '..'), 'lib'))
|
2
|
-
require 'test/unit'
|
3
|
-
require 'mocha/test_unit'
|
4
|
-
require 'stringio'
|
5
|
-
require 'jamm'
|
6
|
-
require File.expand_path('test_data', __dir__)
|
7
|
-
|
8
|
-
# monkeypatch request methods
|
9
|
-
module Jamm
|
10
|
-
@mock_rest_client = nil
|
11
|
-
|
12
|
-
class << self
|
13
|
-
attr_writer :mock_rest_client
|
14
|
-
|
15
|
-
remove_method :execute_request
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.execute_request(options)
|
19
|
-
get_params = (options[:headers] || {})[:params]
|
20
|
-
post_params = options[:payload]
|
21
|
-
case options[:method]
|
22
|
-
when :get then @mock_rest_client.get options[:url], get_params, post_params
|
23
|
-
when :post then @mock_rest_client.post options[:url], get_params, post_params
|
24
|
-
when :patch then @mock_rest_client.patch options[:url], get_params, post_params
|
25
|
-
when :delete then @mock_rest_client.delete options[:url], get_params, post_params
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module Test
|
31
|
-
module Unit
|
32
|
-
class TestCase
|
33
|
-
include Jamm::TestData
|
34
|
-
include Mocha
|
35
|
-
|
36
|
-
class << self
|
37
|
-
alias context sub_test_case
|
38
|
-
alias should test
|
39
|
-
end
|
40
|
-
|
41
|
-
def encode_credentials(client_id, client_secret)
|
42
|
-
"Basic #{Base64.strict_encode64("#{client_id}:#{client_secret}")}"
|
43
|
-
end
|
44
|
-
|
45
|
-
setup do
|
46
|
-
@mock = mock
|
47
|
-
Jamm.mock_rest_client = @mock
|
48
|
-
Jamm.client_id = 'client id'
|
49
|
-
Jamm.client_secret = 'client secret'
|
50
|
-
end
|
51
|
-
|
52
|
-
teardown do
|
53
|
-
Jamm.mock_rest_client = nil
|
54
|
-
Jamm.client_id = nil
|
55
|
-
Jamm.client_secret = nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|