fondy 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 156f2c6fa3274248556be7b535462815c8c111f3
4
- data.tar.gz: 91669185ff1f24a4674efe7ea408e36786ec0f9f
3
+ metadata.gz: cd7a2cb3bab7cf8652c5c9ffb062092765c3875f
4
+ data.tar.gz: 183b415692c4a4d742678c521c0ff32fbe585908
5
5
  SHA512:
6
- metadata.gz: ed1fb35bc8d3ff2e19c60307d975aa3613d36ea427953abafc86a8366ee998d2eb3fd502dfe67490dbd0562a0a4fe0ec17233ab0807231cd2e9c2d32a3138df1
7
- data.tar.gz: 7bd31d253d4e855a17dd45ed149850d7feb718ad0031e91d5abb9c4bff2b69bfbbf56dd64100469c4795ef29ae69df5832e2227e755a714b1bbfa012afbf398d
6
+ metadata.gz: 267dd9d9bf3f81466052f0f87a791ff7417bcac1c037825ef05e99f85929ddb5e48d999aa1d774b79fd6d7a64d964231d93b2a5b88d06989ca95c28056f46d4f
7
+ data.tar.gz: 99ae2a12d7a4c778c377331c649318be714692952a7e6f4a50b884c521f36dcc5cdbf75e58245ae16d0dd05d6bae6cc7c743d2a150ede8d081e057972fdc5236
data/README.md CHANGED
@@ -38,6 +38,13 @@ response.success?
38
38
  # => true
39
39
  response.order_status
40
40
  # => "approved"
41
+ response.to_h
42
+ # => {
43
+ # response_status: "success",
44
+ # order_status: "approved",
45
+ # actual_amount: 100,
46
+ # ...
47
+ # }
41
48
 
42
49
  response.error?
43
50
  # => true
@@ -45,6 +52,12 @@ response.error_code
45
52
  # => 1018
46
53
  response.error_message
47
54
  # => "Order not found"
55
+ response.to_h
56
+ # => {
57
+ # response_status: "failure",
58
+ # error_message: "Order not found",
59
+ # error_code: 1018
60
+ # }
48
61
  ```
49
62
 
50
63
  Capture payment:
@@ -5,8 +5,12 @@ module Fondy
5
5
  check_signature(password) if success?
6
6
  end
7
7
 
8
+ def to_h
9
+ response
10
+ end
11
+
8
12
  def success?
9
- response['response_status'] == 'success'
13
+ response[:response_status] == 'success'
10
14
  end
11
15
 
12
16
  def error?
@@ -14,26 +18,26 @@ module Fondy
14
18
  end
15
19
 
16
20
  def error_code
17
- response['error_code']
21
+ response[:error_code]
18
22
  end
19
23
 
20
24
  def error_message
21
- response['error_message']
25
+ response[:error_message]
22
26
  end
23
27
 
24
28
  def method_missing(method, *_args)
25
- response[method.to_s] || super
29
+ response[method] || super
26
30
  end
27
31
 
28
32
  def respond_to_missing?(method, *_args)
29
- response.key?(method.to_s)
33
+ response.key?(method)
30
34
  end
31
35
 
32
36
  private
33
37
 
34
38
  # rubocop:disable Style/GuardClause
35
39
  def check_signature(password)
36
- signature = response['signature']
40
+ signature = response[:signature]
37
41
  unless signature
38
42
  raise Fondy::InvalidSignatureError, 'Response signature not found'
39
43
  end
@@ -45,13 +49,13 @@ module Fondy
45
49
  end
46
50
 
47
51
  def response
48
- @response ||= json_body['response'] || raise(Fondy::Error, 'Invalid response')
52
+ @response ||= json_body[:response] || raise(Fondy::Error, 'Invalid response')
49
53
  end
50
54
 
51
55
  def json_body
52
56
  @json_body ||=
53
57
  begin
54
- JSON.parse(@http_response.body)
58
+ JSON.parse(@http_response.body, symbolize_names: true)
55
59
  rescue
56
60
  raise Fondy::InvalidResponseError, 'Invalid response'
57
61
  end
@@ -1,3 +1,3 @@
1
1
  module Fondy
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fondy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Khrebtov