jamm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +23 -0
- data/.github/workflows/ruby-publish.yml +24 -0
- data/.gitignore +57 -0
- data/.rubocop.yml +53 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +13 -0
- data/LICENSE +21 -0
- data/README.md +86 -0
- data/Rakefile +11 -0
- data/images/jamm_logo.png +0 -0
- data/jamm.gemspec +26 -0
- data/lib/jamm/api_operations/create.rb +16 -0
- data/lib/jamm/api_operations/get.rb +16 -0
- data/lib/jamm/api_operations/list.rb +16 -0
- data/lib/jamm/api_operations/update.rb +16 -0
- data/lib/jamm/api_resource.rb +5 -0
- data/lib/jamm/charge.rb +10 -0
- data/lib/jamm/errors.rb +36 -0
- data/lib/jamm/jamm_object.rb +249 -0
- data/lib/jamm/oauth.rb +66 -0
- data/lib/jamm/payment.rb +18 -0
- data/lib/jamm/request.rb +13 -0
- data/lib/jamm/time_util.rb +41 -0
- data/lib/jamm/token.rb +10 -0
- data/lib/jamm/util.rb +76 -0
- data/lib/jamm/version.rb +3 -0
- data/lib/jamm.rb +146 -0
- data/test/jamm/charge_test.rb +56 -0
- data/test/jamm/oauth_test.rb +47 -0
- data/test/jamm/payment_test.rb +17 -0
- data/test/jamm/time_util_test.rb +18 -0
- data/test/jamm/token_test.rb +52 -0
- data/test/test_data.rb +118 -0
- data/test/test_helper.rb +59 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f327c3134101945f2fae416640e630efb160d4b1d68679d925689a73023fbabd
|
4
|
+
data.tar.gz: 3044598aaa52335f986638a8989dcae84ac7805f8676ee67e94f70896b391405
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '08c55977ae46c049e48f7933ed2926d511562f96f4a3875f61ae9790611a392efe6fc075916675ff6b69eb2409e295e8c302a02a84cc058eb0b09231b176354d'
|
7
|
+
data.tar.gz: a74807913f38478fba27cbb5df6914089253d34223091a5638289aa398dc9b5cc8de0411ea5247f19cbc026af02981b437e23b1a9b181d4a5ad357dfda1cb43c
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Multibranch Ruby CI Flow
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v4
|
16
|
+
- name: Ruby setup
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: "3.2.2"
|
20
|
+
- name: Install dependencies
|
21
|
+
run: bundle install
|
22
|
+
- name: Run Test
|
23
|
+
run: bundle exec rake
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Publish Ruby Package
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
deploy:
|
9
|
+
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v4
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '3.2'
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Build and publish
|
20
|
+
env:
|
21
|
+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
22
|
+
run: |
|
23
|
+
bundle exec rake build
|
24
|
+
bundle exec gem push pkg/jamm-*.gem
|
data/.gitignore
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
*.lock
|
4
|
+
/.config
|
5
|
+
/coverage/
|
6
|
+
/InstalledFiles
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/spec/examples.txt
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
# Used by dotenv library to load environment variables.
|
15
|
+
# .env
|
16
|
+
|
17
|
+
# Ignore Byebug command history file.
|
18
|
+
.byebug_history
|
19
|
+
|
20
|
+
## Specific to RubyMotion:
|
21
|
+
.dat*
|
22
|
+
.repl_history
|
23
|
+
build/
|
24
|
+
*.bridgesupport
|
25
|
+
build-iPhoneOS/
|
26
|
+
build-iPhoneSimulator/
|
27
|
+
|
28
|
+
## Specific to RubyMotion (use of CocoaPods):
|
29
|
+
#
|
30
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
31
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
32
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
33
|
+
#
|
34
|
+
# vendor/Pods/
|
35
|
+
|
36
|
+
## Documentation cache and generated files:
|
37
|
+
/.yardoc/
|
38
|
+
/_yardoc/
|
39
|
+
/doc/
|
40
|
+
/rdoc/
|
41
|
+
|
42
|
+
## Environment normalization:
|
43
|
+
/.bundle/
|
44
|
+
/vendor/bundle
|
45
|
+
/lib/bundler/man/
|
46
|
+
|
47
|
+
# for a library or gem, you might want to ignore these files since the code is
|
48
|
+
# intended to run in multiple environments; otherwise, check them in:
|
49
|
+
# Gemfile.lock
|
50
|
+
# .ruby-version
|
51
|
+
# .ruby-gemset
|
52
|
+
|
53
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
54
|
+
.rvmrc
|
55
|
+
|
56
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
57
|
+
# .rubocop-https?--*
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
2
|
+
# configuration file. It makes it possible to enable/disable
|
3
|
+
# certain cops (checks) and to alter their behavior if they accept
|
4
|
+
# any parameters. The file can be placed either in your home
|
5
|
+
# directory or in some project directory.
|
6
|
+
#
|
7
|
+
# RuboCop will start looking for the configuration file in the directory
|
8
|
+
# where the inspected file is and continue its way up to the root directory.
|
9
|
+
#
|
10
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
11
|
+
|
12
|
+
Style/FrozenStringLiteralComment:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/MutableConstant:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Lint/MissingSuper:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Metrics/ModuleLength:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Layout/LineLength:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Metrics/AbcSize:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Metrics/CyclomaticComplexity:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Metrics/ClassLength:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Naming/MethodParameterName:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Security/MarshalLoad:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Metrics/PerceivedComplexity:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
AllCops:
|
52
|
+
SuggestExtensions: false
|
53
|
+
NewCops: disable
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Tomu Hirata tomu.hirata@gmail.com
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Jamm
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
[![MIT License][license-shield]][license-url]
|
2
|
+
|
3
|
+
<br />
|
4
|
+
<div align="center">
|
5
|
+
<a href="https://github.com/jamm-pay/Jamm-SDK-Ruby">
|
6
|
+
<img src="images/jamm_logo.png" alt="logo" width="120" height="120">
|
7
|
+
</a>
|
8
|
+
<h3 align="center">Jamm SDK - Ruby</h3>
|
9
|
+
<p align="center">
|
10
|
+
The official Ruby SDK for Jamm's payment API! We strongly recommend using the SDK for backend integration in order to simplify and streamline your development process!
|
11
|
+
<br />
|
12
|
+
<a href="https://github.com/jamm-pay/Jamm-SDK-Ruby"><strong>Home »</strong></a>
|
13
|
+
<br />
|
14
|
+
<br />
|
15
|
+
<a href="https://github.com/jamm-pay/Jamm-SDK-Ruby/issues">Report Bug</a>
|
16
|
+
·
|
17
|
+
<a href="https://github.com/jamm-pay/Jamm-SDK-Ruby/issues">Request Feature</a>
|
18
|
+
</p>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
## How to Use
|
22
|
+
```ruby
|
23
|
+
require 'jamm'
|
24
|
+
Jamm.client_id = '<your client id>'
|
25
|
+
Jamm.client_secret = '<your client id>'
|
26
|
+
Jamm.open_timeout = 30 # optionally
|
27
|
+
Jamm.read_timeout = 90 # optionally
|
28
|
+
# ex, create a deduction contract token
|
29
|
+
deduction_token = Jamm::Payment.create(
|
30
|
+
initial_charge: {
|
31
|
+
description: 'Jamm',
|
32
|
+
initial_amount: 10_000,
|
33
|
+
currency: 'JPY'
|
34
|
+
},
|
35
|
+
redirect: {
|
36
|
+
success_url: 'http://www.example.com/success',
|
37
|
+
failure_url: 'http://www.example.com/fail',
|
38
|
+
info_url: 'http://www.example.com/customer_service',
|
39
|
+
expired_at: "2023-11-07T15:30:00.000+09:00"
|
40
|
+
},
|
41
|
+
metadata: {
|
42
|
+
key1: 'value1',
|
43
|
+
key2: 'value2'
|
44
|
+
},
|
45
|
+
customers: {
|
46
|
+
name: "Taro Taro",
|
47
|
+
katakanaFirstName: "タロ",
|
48
|
+
katakanaLastName: "タロ",
|
49
|
+
gender: "MALE",
|
50
|
+
postNum: "112-0001",
|
51
|
+
address: "東京都渋谷区1−1−1"
|
52
|
+
email: "test@jamm-pay.jp",
|
53
|
+
phone: "010-1234-5678"
|
54
|
+
birthdate: "2000-01-01",
|
55
|
+
},
|
56
|
+
options: {
|
57
|
+
force_kyc: true
|
58
|
+
}
|
59
|
+
)
|
60
|
+
```
|
61
|
+
|
62
|
+
## Installation
|
63
|
+
```sh
|
64
|
+
gem install jamm
|
65
|
+
```
|
66
|
+
If you want to build the gem from source:
|
67
|
+
```sh
|
68
|
+
gem build jamm.gemspec
|
69
|
+
```
|
70
|
+
|
71
|
+
## Development
|
72
|
+
Test cases can be run with: `bundle exec rake`
|
73
|
+
|
74
|
+
### Requirements
|
75
|
+
* Ruby 2.7.0 or above.
|
76
|
+
* rest-client
|
77
|
+
|
78
|
+
### Built With
|
79
|
+
|
80
|
+
[![Ruby][Ruby.com]][Ruby-url]
|
81
|
+
|
82
|
+
[license-shield]: https://img.shields.io/badge/license-MIT-blue?style=for-the-badge
|
83
|
+
[issues-url]: https://github.com/jamm-pay/Jamm-SDK-Ruby/issues
|
84
|
+
[license-url]: https://github.com/jamm-pay/Jamm-SDK-Ruby/blob/main/LICENSE
|
85
|
+
[Ruby.com]: https://img.shields.io/badge/ruby-820C02?style=for-the-badge&logo=ruby&logoColor=white
|
86
|
+
[Ruby-url]: https://ruby-lang.org/en
|
data/Rakefile
ADDED
Binary file
|
data/jamm.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
|
3
|
+
require 'jamm/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'jamm'
|
7
|
+
s.version = Jamm::VERSION
|
8
|
+
s.required_ruby_version = '>= 2.7.0'
|
9
|
+
s.summary = 'Ruby SDK for the Jamm API'
|
10
|
+
s.description = 'Jamm help you make payment without credit cards'
|
11
|
+
s.authors = ['Jamm']
|
12
|
+
s.email = 'support@jamm-pay.jp'
|
13
|
+
s.homepage = ''
|
14
|
+
s.license = 'MIT'
|
15
|
+
|
16
|
+
s.add_dependency('rest-client', '~> 2.0')
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
+
s.require_paths = ['lib']
|
22
|
+
|
23
|
+
s.metadata = {
|
24
|
+
'source_code_uri' => 'https://github.com/jamm-pay/Jamm-SDK-Ruby'
|
25
|
+
}
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jamm
|
4
|
+
module APIOperations
|
5
|
+
module Create
|
6
|
+
def create(params = {}, headers = {})
|
7
|
+
request_jamm_api(
|
8
|
+
method: :post,
|
9
|
+
path: resource_url,
|
10
|
+
params: params,
|
11
|
+
headers: headers
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jamm
|
4
|
+
module APIOperations
|
5
|
+
module Get
|
6
|
+
def get(id, params = {}, headers = {})
|
7
|
+
request_jamm_api(
|
8
|
+
method: :get,
|
9
|
+
path: "#{resource_url}/#{id}",
|
10
|
+
params: params,
|
11
|
+
headers: headers
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jamm
|
4
|
+
module APIOperations
|
5
|
+
module List
|
6
|
+
def list(params = {}, headers = {})
|
7
|
+
request_jamm_api(
|
8
|
+
method: :get,
|
9
|
+
path: resource_url,
|
10
|
+
params: params,
|
11
|
+
headers: headers
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jamm
|
4
|
+
module APIOperations
|
5
|
+
module Update
|
6
|
+
def update(id, params = {}, headers = {})
|
7
|
+
request_jamm_api(
|
8
|
+
method: :patch,
|
9
|
+
path: "#{resource_url}/#{id}",
|
10
|
+
params: params,
|
11
|
+
headers: headers
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/jamm/charge.rb
ADDED
data/lib/jamm/errors.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jamm
|
2
|
+
class JammError < StandardError
|
3
|
+
attr_reader :message, :http_body, :http_headers, :http_status, :json_body
|
4
|
+
|
5
|
+
def initialize(message = nil, http_status: nil, http_headers: nil, http_body: nil, json_body: nil)
|
6
|
+
@message = message
|
7
|
+
@http_status = http_status
|
8
|
+
@http_headers = http_headers
|
9
|
+
@http_body = http_body
|
10
|
+
@json_body = json_body
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
status_string = @http_status.nil? ? '' : "(Status #{@http_status}) "
|
15
|
+
"#{status_string}#{@message}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# OAuthError is raised when a request to AWS cognito failed
|
20
|
+
class OAuthError < JammError
|
21
|
+
end
|
22
|
+
|
23
|
+
# ApiConnectionError is raised when a request to Jamm api failed
|
24
|
+
class ApiConnectionError < JammError
|
25
|
+
end
|
26
|
+
|
27
|
+
# ApiError is raised when Jamm api failed with an unexpected reason
|
28
|
+
class ApiError < JammError
|
29
|
+
end
|
30
|
+
|
31
|
+
class InvalidRequestError < JammError
|
32
|
+
end
|
33
|
+
|
34
|
+
class AuthenticationError < JammError
|
35
|
+
end
|
36
|
+
end
|