gmo-pg 1.0.9 → 1.0.10
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/lib/gmo-pg/dispatcher.rb +1 -9
- data/lib/gmo-pg/error.rb +9 -9
- data/lib/gmo-pg/http_resource/errors.rb +2 -2
- data/lib/gmo-pg/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3a81515f110621f9f9f948ad256056aa34dcf02
|
|
4
|
+
data.tar.gz: 79477f08628e97b821d024aa9b093731bd339907
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c04790e4430d920a67a7d6e364b6de0b363714da53b4d0b9d60e1da1ec5e849e36946023bf310b7b68c94f317a12ff1b38c9b8bbbfaf93ec2e71a31857f1a603
|
|
7
|
+
data.tar.gz: c03d0ea2eaf99ee3a4462acf887e32e97509e4f208c1802fd922033c88cbe560e5c43640c887cf6855f3fefe163b53a906469924212e048deb141c55896ba069
|
data/lib/gmo-pg/dispatcher.rb
CHANGED
|
@@ -48,7 +48,7 @@ module GMO
|
|
|
48
48
|
when Net::HTTPSuccess
|
|
49
49
|
payload = GMO::PG::Payload.decode(res.body)
|
|
50
50
|
response = request.class.corresponding_response_class.new(payload)
|
|
51
|
-
|
|
51
|
+
raise response.errors.first.to_error if @raise_on_api_error && response.error?
|
|
52
52
|
response
|
|
53
53
|
else
|
|
54
54
|
res.value # raise Net::XxxError
|
|
@@ -67,14 +67,6 @@ module GMO
|
|
|
67
67
|
raise GMO::PG::Error.from_http_error(e)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
|
-
|
|
71
|
-
def raise_api_error(request, response)
|
|
72
|
-
e = response.errors.first.to_error
|
|
73
|
-
e.request = request
|
|
74
|
-
e.response = response
|
|
75
|
-
|
|
76
|
-
raise e
|
|
77
|
-
end
|
|
78
70
|
end
|
|
79
71
|
end
|
|
80
72
|
end
|
data/lib/gmo-pg/error.rb
CHANGED
|
@@ -26,7 +26,7 @@ module GMO
|
|
|
26
26
|
# E0119: Invalid SiteID
|
|
27
27
|
# E0120: Invalid SitePass
|
|
28
28
|
# E0121: Invalid SiteID and/or SitePass
|
|
29
|
-
GMO::PG::AuthorizationError.new(
|
|
29
|
+
GMO::PG::AuthorizationError.new('Authorization error', err_code, err_info)
|
|
30
30
|
when /\AE01(17|18|25|26|27|46|48)/, /\A(E41|42G)/
|
|
31
31
|
# E0117: Invalid CardNo
|
|
32
32
|
# E0118: Invalid Expire
|
|
@@ -37,15 +37,15 @@ module GMO
|
|
|
37
37
|
# E0148: Invalid HolderName
|
|
38
38
|
# E41 : Incorrect card
|
|
39
39
|
# 42G : Error on Card brand
|
|
40
|
-
GMO::PG::CardError.new(
|
|
40
|
+
GMO::PG::CardError.new('Card error', err_code, err_info)
|
|
41
41
|
when /\A(E61|E91|E92|42C)/
|
|
42
42
|
# E61: Shop configuration error
|
|
43
43
|
# E91: System error
|
|
44
44
|
# E92: Temporary unavailable
|
|
45
45
|
# 42C: Error on CAFIS or Card brand
|
|
46
|
-
GMO::PG::APIServerError.new(
|
|
46
|
+
GMO::PG::APIServerError.new('Temporary unavailable', err_code, err_info)
|
|
47
47
|
else
|
|
48
|
-
GMO::PG::APIError.new(
|
|
48
|
+
GMO::PG::APIError.new('API error', err_code, err_info)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -57,12 +57,12 @@ module GMO
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
class APIError < Error
|
|
60
|
-
|
|
60
|
+
attr_reader :err_code, :err_info
|
|
61
61
|
|
|
62
|
-
def initialize(message,
|
|
63
|
-
super(message)
|
|
64
|
-
@
|
|
65
|
-
@
|
|
62
|
+
def initialize(message, err_code, err_info)
|
|
63
|
+
super("#{message} (#{err_code}|#{err_info})")
|
|
64
|
+
@err_code = err_code
|
|
65
|
+
@err_info = err_info
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module GMO
|
|
2
2
|
module PG
|
|
3
3
|
class Errors
|
|
4
|
-
class
|
|
4
|
+
class Error < Struct.new(:err_code, :err_info)
|
|
5
5
|
def to_error
|
|
6
6
|
GMO::PG::Error.from_api_error(err_code, err_info)
|
|
7
7
|
end
|
|
@@ -20,7 +20,7 @@ module GMO
|
|
|
20
20
|
return to_enum unless block_given?
|
|
21
21
|
return nil if @err_code.nil? && @err_info.nil?
|
|
22
22
|
@err_code.zip(@err_info).each do |(err_code, err_info)|
|
|
23
|
-
yield
|
|
23
|
+
yield Error.new(err_code, err_info)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
data/lib/gmo-pg/version.rb
CHANGED