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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0decbf3d4188db421f9b22b5a328cacbbf8a733
4
- data.tar.gz: 0039ff2cba2a9b0ebdbabcd153d6c179c7159f11
3
+ metadata.gz: e3a81515f110621f9f9f948ad256056aa34dcf02
4
+ data.tar.gz: 79477f08628e97b821d024aa9b093731bd339907
5
5
  SHA512:
6
- metadata.gz: 2168baf2ef8ce95054bab3eaf9b1d053018f56419bc0f63e668953bbe0a3efa05753b417372223d071371d438a174a4c385477ca63557314fec46f075a7e5f17
7
- data.tar.gz: a278f46eb45e0132596039e54134af3730ee2e0749ce53af421947cc6ac44b7f2c74336673ffa4cd99a850bd41218bca237e5b89b204c56a35a57b7be9ebe310
6
+ metadata.gz: c04790e4430d920a67a7d6e364b6de0b363714da53b4d0b9d60e1da1ec5e849e36946023bf310b7b68c94f317a12ff1b38c9b8bbbfaf93ec2e71a31857f1a603
7
+ data.tar.gz: c03d0ea2eaf99ee3a4462acf887e32e97509e4f208c1802fd922033c88cbe560e5c43640c887cf6855f3fefe163b53a906469924212e048deb141c55896ba069
@@ -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
- raise_api_error request, response if @raise_on_api_error && response.error?
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("Authorization error (#{err_code}|#{err_info})")
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("Card error (#{err_code}|#{err_info})")
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("Temporary unavailable (#{err_code}|#{err_info})")
46
+ GMO::PG::APIServerError.new('Temporary unavailable', err_code, err_info)
47
47
  else
48
- GMO::PG::APIError.new("API error (#{err_code}|#{err_info})")
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
- attr_accessor :request, :response
60
+ attr_reader :err_code, :err_info
61
61
 
62
- def initialize(message, request = nil, response = nil)
63
- super(message)
64
- @request = request
65
- @response = response
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 Record < Struct.new(:err_code, :err_info)
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 Record.new(err_code, err_info)
23
+ yield Error.new(err_code, err_info)
24
24
  end
25
25
  end
26
26
  end
@@ -1,5 +1,5 @@
1
1
  module GMO
2
2
  module PG
3
- VERSION = '1.0.9'
3
+ VERSION = '1.0.10'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmo-pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - kissy2go