mfkessai-ruby 1.0.0.beta3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +65 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +2 -2
- data/README.md +66 -18
- data/lib/mfkessai/client.rb +19 -6
- data/lib/mfkessai/customer.rb +5 -5
- data/lib/mfkessai/errors.rb +1 -4
- data/lib/mfkessai/examination.rb +5 -5
- data/lib/mfkessai/transaction.rb +6 -7
- data/lib/mfkessai/version.rb +1 -1
- data/mfkessai-ruby.gemspec +1 -1
- metadata +5 -6
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b8db5d505788d354f084d8e0fc1f28dce41ba9724f404e99798287cdc80116f
|
4
|
+
data.tar.gz: 83cd99a0a4573c5b9657a2d8fa9b05daa0ab55d5e77a9cb0a760ccf2b5e72b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7077a9f411e3a554c4dee787dfe516336ec356202543700d474ad40024c3479b78fc21c3e7d2db556cfce63875e3d0ec12d022c9bccc8cd4a4a68593acf4489d
|
7
|
+
data.tar.gz: f7a8e9cd18d12caacf78c0ee5e2767076b1f5ed21381c9b3c17d2b6b9ddf0ac710d9795d3b0fb0a65a517c870eab5f333c9f50c9ef2c5bf934f8d12cf24a9fe7
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
stages:
|
2
|
+
- test
|
3
|
+
|
4
|
+
ruby2.3:rspec:
|
5
|
+
image: ruby:2.3-alpine
|
6
|
+
|
7
|
+
script:
|
8
|
+
- setup
|
9
|
+
- execute_rspec
|
10
|
+
|
11
|
+
ruby2.4:rspec:
|
12
|
+
image: ruby:2.4-alpine
|
13
|
+
|
14
|
+
script:
|
15
|
+
- setup
|
16
|
+
- execute_rspec
|
17
|
+
|
18
|
+
ruby2.5:rspec:
|
19
|
+
image: ruby:2.5-alpine
|
20
|
+
|
21
|
+
script:
|
22
|
+
- setup
|
23
|
+
- execute_rspec
|
24
|
+
|
25
|
+
ruby2.5.1:rspec:
|
26
|
+
image: ruby:2.5.1-alpine
|
27
|
+
|
28
|
+
script:
|
29
|
+
- setup
|
30
|
+
- execute_rspec
|
31
|
+
|
32
|
+
allow_failure: true
|
33
|
+
|
34
|
+
dependency_scanning:
|
35
|
+
image: docker:stable
|
36
|
+
variables:
|
37
|
+
DOCKER_DRIVER: overlay2
|
38
|
+
allow_failure: true
|
39
|
+
services:
|
40
|
+
- docker:stable-dind
|
41
|
+
script:
|
42
|
+
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
43
|
+
- docker run
|
44
|
+
--env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
|
45
|
+
--volume "$PWD:/code"
|
46
|
+
--volume /var/run/docker.sock:/var/run/docker.sock
|
47
|
+
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
|
48
|
+
artifacts:
|
49
|
+
paths: [gl-dependency-scanning-report.json]
|
50
|
+
|
51
|
+
.auto_devops: &auto_devops |
|
52
|
+
function execute_rspec() {
|
53
|
+
bundle exec rspec
|
54
|
+
}
|
55
|
+
|
56
|
+
function setup() {
|
57
|
+
apk --update --upgrade add $BUILD_PACKAGES
|
58
|
+
apk add git
|
59
|
+
gem install bundler --no-ri --no-rdoc
|
60
|
+
bundle check --path=${BUNDLE_CACHE} || bundle install --path=${BUNDLE_CACHE} --jobs=2 --retry=3
|
61
|
+
bundle clean
|
62
|
+
}
|
63
|
+
|
64
|
+
before_script:
|
65
|
+
- *auto_devops
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Mfkessai for Ruby
|
1
|
+
# Mfkessai Ruby Library
|
4
2
|
mfkessaiのapiを使用するための便利なアクセスをRubyで提供します
|
5
3
|
|
6
4
|
こちらのgemは非公式なライブラリです
|
7
5
|
|
8
|
-
対応API
|
6
|
+
### 対応API
|
9
7
|
|
10
|
-
- customer
|
11
|
-
- destination
|
12
|
-
- examination
|
13
|
-
- ping
|
14
|
-
- transaction
|
8
|
+
- [customer](#customer)
|
9
|
+
- [destination](#destination)
|
10
|
+
- [examination](#examination)
|
11
|
+
- [ping](#ping)
|
12
|
+
- [transaction](#transaction)
|
15
13
|
|
16
14
|
[詳しいAPIを参照する](https://mfkessai.co.jp/api_doc/endpoint.html)
|
17
15
|
|
18
16
|
## Installation
|
19
17
|
|
20
18
|
```
|
21
|
-
$ gem install mfkessai
|
19
|
+
$ gem install mfkessai-ruby
|
22
20
|
```
|
23
21
|
|
24
22
|
## Usage
|
@@ -52,6 +50,9 @@ Mfkessai.api_key = "mfkessai_test_..."
|
|
52
50
|
|
53
51
|
# 顧客リストを取得
|
54
52
|
Mfkessai::Customer.list
|
53
|
+
|
54
|
+
# ページ番号、1ページあたりの件数を指定する
|
55
|
+
Mfkessai::Customer.list(page: 3, per_page: 30)
|
55
56
|
```
|
56
57
|
|
57
58
|
- Mfkessai::Customer.retrieve
|
@@ -99,7 +100,7 @@ Mfkessai::Destination.create(request_body: params)
|
|
99
100
|
```
|
100
101
|
|
101
102
|
## examination
|
102
|
-
- Mfkessai::
|
103
|
+
- Mfkessai::Examination.list
|
103
104
|
|
104
105
|
```
|
105
106
|
require "mfkessai"
|
@@ -107,10 +108,13 @@ Mfkessai.api_url = "https://sandbox"
|
|
107
108
|
Mfkessai.api_key = "mfkessai_test_..."
|
108
109
|
|
109
110
|
# 審査リストを取得
|
110
|
-
Mfkessai::
|
111
|
+
Mfkessai::Examination.list
|
112
|
+
|
113
|
+
# ページ番号、1ページあたりの件数を指定する
|
114
|
+
Mfkessai::Examination.list(page: 3, per_page: 30)
|
111
115
|
```
|
112
116
|
|
113
|
-
- Mfkessai::
|
117
|
+
- Mfkessai::Examination.create
|
114
118
|
|
115
119
|
```
|
116
120
|
require "mfkessai"
|
@@ -138,10 +142,10 @@ params = {
|
|
138
142
|
]
|
139
143
|
}
|
140
144
|
|
141
|
-
Mfkessai::
|
145
|
+
Mfkessai::Examination.create(request_body: params)
|
142
146
|
```
|
143
147
|
|
144
|
-
- Mfkessai::
|
148
|
+
- Mfkessai::Examination.retrieve
|
145
149
|
|
146
150
|
```
|
147
151
|
require "mfkessai"
|
@@ -149,10 +153,10 @@ Mfkessai.api_url = "https://sandbox"
|
|
149
153
|
Mfkessai.api_key = "mfkessai_test_..."
|
150
154
|
|
151
155
|
# IDを指定して審査情報を取得
|
152
|
-
Mfkessai::
|
156
|
+
Mfkessai::Examination.retrieve('destination_test_123')
|
153
157
|
```
|
154
158
|
|
155
|
-
- Mfkessai::
|
159
|
+
- Mfkessai::Examination.create_transaction
|
156
160
|
|
157
161
|
```
|
158
162
|
require "mfkessai"
|
@@ -169,7 +173,7 @@ params = {
|
|
169
173
|
"user_defined_id": "transaction00000001"
|
170
174
|
}
|
171
175
|
|
172
|
-
Mfkessai::
|
176
|
+
Mfkessai::Examination.create_transaction(id: 'test_123', request_body: params)
|
173
177
|
```
|
174
178
|
|
175
179
|
## ping
|
@@ -197,6 +201,9 @@ Mfkessai.api_key = "mfkessai_test_..."
|
|
197
201
|
# 取引リストを取得
|
198
202
|
|
199
203
|
Mfkessai::Transaction.list
|
204
|
+
|
205
|
+
# ページ番号、1ページあたりの件数を指定する
|
206
|
+
Mfkessai::Transaction.list(page: 3, per_page: 30)
|
200
207
|
```
|
201
208
|
|
202
209
|
- Mfkessai::Transaction.create
|
@@ -278,6 +285,47 @@ Mfkessai.api_key = "mfkessai_test_..."
|
|
278
285
|
Mfkessai::Transaction.cancel("transation_test_123")
|
279
286
|
```
|
280
287
|
|
288
|
+
## Handling errors
|
289
|
+
|
290
|
+
```
|
291
|
+
begin
|
292
|
+
# Use Mfkessai's library to make requests...
|
293
|
+
rescue Mfkessai::BadRequestError => e
|
294
|
+
puts "Status is: #{e.http_status}"
|
295
|
+
puts "Message is: #{e.message}"
|
296
|
+
puts "http_body is: #{e.http_body}"
|
297
|
+
puts "json_body is: #{e.json_body}"
|
298
|
+
rescue Mfkessai::AuthenticationError => e
|
299
|
+
puts "Status is: #{e.http_status}"
|
300
|
+
puts "Message is: #{e.message}"
|
301
|
+
puts "http_body is: #{e.http_body}"
|
302
|
+
puts "json_body is: #{e.json_body}"
|
303
|
+
rescue Mfkessai::ForbiddenError => e
|
304
|
+
puts "Status is: #{e.http_status}"
|
305
|
+
puts "Message is: #{e.message}"
|
306
|
+
puts "http_body is: #{e.http_body}"
|
307
|
+
puts "json_body is: #{e.json_body}"
|
308
|
+
rescue Mfkessai::NotFoundError => e
|
309
|
+
puts "Status is: #{e.http_status}"
|
310
|
+
puts "Message is: #{e.message}"
|
311
|
+
puts "http_body is: #{e.http_body}"
|
312
|
+
puts "json_body is: #{e.json_body}"
|
313
|
+
rescue Mfkessai::APIConnectionError => e
|
314
|
+
puts "Status is: #{e.http_status}"
|
315
|
+
puts "Message is: #{e.message}"
|
316
|
+
puts "http_body is: #{e.http_body}"
|
317
|
+
puts "json_body is: #{e.json_body}"
|
318
|
+
rescue Mfkessai::ServerError => e
|
319
|
+
puts "Status is: #{e.http_status}"
|
320
|
+
puts "Message is: #{e.message}"
|
321
|
+
puts "http_body is: #{e.http_body}"
|
322
|
+
puts "json_body is: #{e.json_body}"
|
323
|
+
rescue => e
|
324
|
+
# Something else happened, completely unrelated to Mfkessai
|
325
|
+
end
|
326
|
+
|
327
|
+
```
|
328
|
+
|
281
329
|
## Development
|
282
330
|
|
283
331
|
Run all tests:
|
data/lib/mfkessai/client.rb
CHANGED
@@ -56,6 +56,13 @@ module Mfkessai
|
|
56
56
|
resp
|
57
57
|
end
|
58
58
|
|
59
|
+
def list_filter_parameters(page, per_page)
|
60
|
+
params = {}
|
61
|
+
params[:page] = page if page
|
62
|
+
params[:per_page] = per_page if per_page
|
63
|
+
'?' + URI.encode_www_form(params)
|
64
|
+
end
|
65
|
+
|
59
66
|
def request_headers
|
60
67
|
headers = {
|
61
68
|
"User-Agent" => "Mfkessai/v1 RubyBindings/#{Mfkessai::VERSION}",
|
@@ -124,32 +131,38 @@ module Mfkessai
|
|
124
131
|
case error_response[:status]
|
125
132
|
when 400
|
126
133
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
127
|
-
raise BadRequestError.new(
|
134
|
+
raise BadRequestError.new(message: data[:detail],
|
135
|
+
http_status: error_response[:status],
|
128
136
|
http_body: error_response[:body],
|
129
137
|
json_body: data)
|
130
138
|
when 401
|
131
139
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
132
|
-
raise AuthenticationError.new(
|
140
|
+
raise AuthenticationError.new(message: data[:detail],
|
141
|
+
http_status: error_response[:status],
|
133
142
|
http_body: error_response[:body],
|
134
143
|
json_body: data)
|
135
144
|
when 403
|
136
145
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
137
|
-
raise ForbiddenError.new(
|
146
|
+
raise ForbiddenError.new(message: data[:detail],
|
147
|
+
http_status: error_response[:status],
|
138
148
|
http_body: error_response[:body],
|
139
149
|
json_body: data)
|
140
150
|
when 404
|
141
151
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
142
|
-
raise NotFoundError.new(
|
152
|
+
raise NotFoundError.new(message: data[:detail],
|
153
|
+
http_status: error_response[:status],
|
143
154
|
http_body: error_response[:body],
|
144
155
|
json_body: data)
|
145
156
|
when 500
|
146
157
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
147
|
-
raise ServerError.new(
|
158
|
+
raise ServerError.new(message: data[:detail],
|
159
|
+
http_status: error_response[:status],
|
148
160
|
http_body: error_response[:body],
|
149
161
|
json_body: data)
|
150
162
|
when 503
|
151
163
|
data = JSON.parse(error_response[:body], symbolize_names: true)
|
152
|
-
raise ServerError.new(
|
164
|
+
raise ServerError.new(message: data[:detail],
|
165
|
+
http_status: error_response[:status],
|
153
166
|
http_body: error_response[:body],
|
154
167
|
json_body: data)
|
155
168
|
else
|
data/lib/mfkessai/customer.rb
CHANGED
@@ -4,15 +4,15 @@ module Mfkessai
|
|
4
4
|
extend Mfkessai::Client
|
5
5
|
|
6
6
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/customer/customer_index
|
7
|
-
def self.list
|
8
|
-
|
9
|
-
|
7
|
+
def self.list(page: nil, per_page: nil)
|
8
|
+
url = '/v1/customers'
|
9
|
+
url += list_filter_parameters(page, per_page) if !page.nil? || !per_page.nil?
|
10
|
+
request(url: url, request_type: :get)
|
10
11
|
end
|
11
12
|
|
12
13
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/customer/customer_show
|
13
14
|
def self.retrieve(id)
|
14
|
-
request(url: "/v1/customers/#{id}",
|
15
|
-
request_type: :get)
|
15
|
+
request(url: "/v1/customers/#{id}", request_type: :get)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/mfkessai/errors.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Mfkessai
|
3
3
|
class MfkessaiError < StandardError
|
4
|
-
attr_reader :message
|
5
|
-
attr_reader :http_status
|
6
|
-
attr_reader :http_body
|
7
|
-
attr_reader :json_body
|
4
|
+
attr_reader :message, :http_status, :http_body, :json_body
|
8
5
|
|
9
6
|
def initialize(message: nil, http_status: nil, http_body: nil, json_body: nil)
|
10
7
|
@message = message
|
data/lib/mfkessai/examination.rb
CHANGED
@@ -4,9 +4,10 @@ module Mfkessai
|
|
4
4
|
extend Mfkessai::Client
|
5
5
|
|
6
6
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/examination/examination_index
|
7
|
-
def self.list
|
8
|
-
|
9
|
-
|
7
|
+
def self.list(page: nil, per_page: nil)
|
8
|
+
url = '/v1/examinations'
|
9
|
+
url += list_filter_parameters(page, per_page) if !page.nil? || !per_page.nil?
|
10
|
+
request(url: url, request_type: :get)
|
10
11
|
end
|
11
12
|
|
12
13
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/examination/examination_create
|
@@ -18,8 +19,7 @@ module Mfkessai
|
|
18
19
|
|
19
20
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/examination/examination_show
|
20
21
|
def self.retrieve(id)
|
21
|
-
request(url: "/v1/examinations/#{id}",
|
22
|
-
request_type: :get)
|
22
|
+
request(url: "/v1/examinations/#{id}", request_type: :get)
|
23
23
|
end
|
24
24
|
|
25
25
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/examination/examination_create_transaction
|
data/lib/mfkessai/transaction.rb
CHANGED
@@ -4,9 +4,10 @@ module Mfkessai
|
|
4
4
|
extend Mfkessai::Client
|
5
5
|
|
6
6
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/transaction/transaction_index
|
7
|
-
def self.list
|
8
|
-
|
9
|
-
|
7
|
+
def self.list(page: nil, per_page: nil)
|
8
|
+
url = '/v1/transactions'
|
9
|
+
url += list_filter_parameters(page, per_page) if !page.nil? || !per_page.nil?
|
10
|
+
request(url: url, request_type: :get)
|
10
11
|
end
|
11
12
|
|
12
13
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/transaction/transaction_create
|
@@ -18,14 +19,12 @@ module Mfkessai
|
|
18
19
|
|
19
20
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/transaction/transaction_show
|
20
21
|
def self.retrieve(id)
|
21
|
-
request(url: "/v1/transactions/#{id}",
|
22
|
-
request_type: :get)
|
22
|
+
request(url: "/v1/transactions/#{id}", request_type: :get)
|
23
23
|
end
|
24
24
|
|
25
25
|
# ref: https://mfkessai.co.jp/api_doc/endpoint.html#/transaction/transaction_cancel
|
26
26
|
def self.cancel(id)
|
27
|
-
request(url: "/v1/transactions/#{id}/cancel",
|
28
|
-
request_type: :post)
|
27
|
+
request(url: "/v1/transactions/#{id}/cancel", request_type: :post)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/lib/mfkessai/version.rb
CHANGED
data/mfkessai-ruby.gemspec
CHANGED
@@ -6,7 +6,7 @@ require "mfkessai/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "mfkessai-ruby"
|
8
8
|
spec.version = Mfkessai::VERSION
|
9
|
-
spec.authors = ["torufukui"
|
9
|
+
spec.authors = ["torufukui"]
|
10
10
|
spec.email = ["fukui.development@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = 'Ruby bindings for the Mfkessai API'
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mfkessai-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- torufukui
|
8
|
-
- sora.inc
|
9
8
|
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: faraday
|
@@ -75,8 +74,8 @@ extensions: []
|
|
75
74
|
extra_rdoc_files: []
|
76
75
|
files:
|
77
76
|
- ".gitignore"
|
77
|
+
- ".gitlab-ci.yml"
|
78
78
|
- ".rspec"
|
79
|
-
- ".travis.yml"
|
80
79
|
- CHANGELOG.md
|
81
80
|
- Gemfile
|
82
81
|
- Gemfile.lock
|
@@ -110,9 +109,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
109
|
version: '0'
|
111
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
111
|
requirements:
|
113
|
-
- - "
|
112
|
+
- - ">="
|
114
113
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
114
|
+
version: '0'
|
116
115
|
requirements: []
|
117
116
|
rubyforge_project:
|
118
117
|
rubygems_version: 2.7.6
|