fondy 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/bin/console +1 -0
- data/lib/fondy.rb +3 -0
- data/lib/fondy/base_response.rb +39 -0
- data/lib/fondy/client.rb +16 -2
- data/lib/fondy/errors.rb +1 -0
- data/lib/fondy/request.rb +2 -1
- data/lib/fondy/response.rb +2 -24
- data/lib/fondy/signature.rb +1 -0
- data/lib/fondy/transaction_list_response.rb +20 -0
- data/lib/fondy/version.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9df4598dab25bd0bcd77d4a2416abe2a2ac0b3b
|
4
|
+
data.tar.gz: 6d966ddfe92439ac1d4d534de7864754307bc4af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d342a92161f05c2aa5f150e72a21c8a441329e1ee0e32240103f49626ee354e7f5477a47443a8922dfd19bab7200efedcdc861aee438e18ae027061ed49ce52
|
7
|
+
data.tar.gz: 27bf1e76c71ea98216c77d29509bd27ef0c6420f03ba0aac9f3fe483cc3ce24a3e146d777bcd21dcc5dc4eda3599eb34e3909da7b65b9ff4a98b40011eb6e499
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.3
|
3
3
|
DisplayCopNames: true
|
4
4
|
DisplayStyleGuide: true
|
5
5
|
Exclude:
|
@@ -29,3 +29,7 @@ Style/MultilineMethodCallIndentation:
|
|
29
29
|
Style/EmptyLines:
|
30
30
|
Exclude:
|
31
31
|
- 'spec/**/*'
|
32
|
+
|
33
|
+
Metrics/BlockLength:
|
34
|
+
Exclude:
|
35
|
+
- 'spec/**/*'
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/fondy.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'json'
|
2
3
|
require 'faraday'
|
3
4
|
|
@@ -5,7 +6,9 @@ require 'fondy/version'
|
|
5
6
|
require 'fondy/errors'
|
6
7
|
require 'fondy/client'
|
7
8
|
require 'fondy/request'
|
9
|
+
require 'fondy/base_response'
|
8
10
|
require 'fondy/response'
|
11
|
+
require 'fondy/transaction_list_response'
|
9
12
|
require 'fondy/signature'
|
10
13
|
|
11
14
|
module Fondy
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Fondy
|
3
|
+
class BaseResponse
|
4
|
+
def initialize(http_response)
|
5
|
+
@http_response = http_response
|
6
|
+
end
|
7
|
+
|
8
|
+
def success?
|
9
|
+
raise NotImplementedError
|
10
|
+
end
|
11
|
+
|
12
|
+
def error?
|
13
|
+
!success?
|
14
|
+
end
|
15
|
+
|
16
|
+
def error_code
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
def error_message
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def response
|
27
|
+
@response ||= json_body[:response] || raise(Fondy::Error, 'Invalid response')
|
28
|
+
end
|
29
|
+
|
30
|
+
def json_body
|
31
|
+
@json_body ||=
|
32
|
+
begin
|
33
|
+
JSON.parse(@http_response.body, symbolize_names: true)
|
34
|
+
rescue
|
35
|
+
raise Fondy::InvalidResponseError, 'Invalid response'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/fondy/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Fondy
|
2
3
|
class Client
|
3
4
|
attr_reader :merchant_id, :password
|
@@ -48,12 +49,25 @@ module Fondy
|
|
48
49
|
send_request(:post, '/api/reverse/order_id', params)
|
49
50
|
end
|
50
51
|
|
52
|
+
def transaction_list(order_id:)
|
53
|
+
send_request(
|
54
|
+
:post,
|
55
|
+
'/api/transaction_list',
|
56
|
+
{
|
57
|
+
merchant_id: merchant_id,
|
58
|
+
order_id: order_id,
|
59
|
+
},
|
60
|
+
verify_signature: false,
|
61
|
+
response_class: TransactionListResponse,
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
51
65
|
private
|
52
66
|
|
53
|
-
def send_request(method, url, params, verify_signature: true)
|
67
|
+
def send_request(method, url, params, verify_signature: true, response_class: Response)
|
54
68
|
params[:signature] = Signature.build(params: params, password: password)
|
55
69
|
http_response = Request.call(method, url, params)
|
56
|
-
response =
|
70
|
+
response = response_class.new(http_response)
|
57
71
|
|
58
72
|
if verify_signature && response.success?
|
59
73
|
Signature.verify(params: response.to_h, password: password)
|
data/lib/fondy/errors.rb
CHANGED
data/lib/fondy/request.rb
CHANGED
data/lib/fondy/response.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Fondy
|
2
|
-
class Response
|
3
|
-
def initialize(http_response)
|
4
|
-
@http_response = http_response
|
5
|
-
end
|
6
|
-
|
3
|
+
class Response < BaseResponse
|
7
4
|
def to_h
|
8
5
|
response
|
9
6
|
end
|
@@ -12,10 +9,6 @@ module Fondy
|
|
12
9
|
response[:response_status] == 'success'
|
13
10
|
end
|
14
11
|
|
15
|
-
def error?
|
16
|
-
!success?
|
17
|
-
end
|
18
|
-
|
19
12
|
def error_code
|
20
13
|
response[:error_code]
|
21
14
|
end
|
@@ -31,20 +24,5 @@ module Fondy
|
|
31
24
|
def respond_to_missing?(method, *_args)
|
32
25
|
response.key?(method)
|
33
26
|
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def response
|
38
|
-
@response ||= json_body[:response] || raise(Fondy::Error, 'Invalid response')
|
39
|
-
end
|
40
|
-
|
41
|
-
def json_body
|
42
|
-
@json_body ||=
|
43
|
-
begin
|
44
|
-
JSON.parse(@http_response.body, symbolize_names: true)
|
45
|
-
rescue
|
46
|
-
raise Fondy::InvalidResponseError, 'Invalid response'
|
47
|
-
end
|
48
|
-
end
|
49
27
|
end
|
50
28
|
end
|
data/lib/fondy/signature.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Fondy
|
3
|
+
class TransactionListResponse < BaseResponse
|
4
|
+
def transactions
|
5
|
+
success? ? response : []
|
6
|
+
end
|
7
|
+
|
8
|
+
def success?
|
9
|
+
response.is_a?(Array)
|
10
|
+
end
|
11
|
+
|
12
|
+
def error_code
|
13
|
+
response[:error_code] if response.is_a?(Hash)
|
14
|
+
end
|
15
|
+
|
16
|
+
def error_message
|
17
|
+
response[:error_message] if response.is_a?(Hash)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/fondy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fondy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Khrebtov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -113,11 +113,13 @@ files:
|
|
113
113
|
- bin/setup
|
114
114
|
- fondy.gemspec
|
115
115
|
- lib/fondy.rb
|
116
|
+
- lib/fondy/base_response.rb
|
116
117
|
- lib/fondy/client.rb
|
117
118
|
- lib/fondy/errors.rb
|
118
119
|
- lib/fondy/request.rb
|
119
120
|
- lib/fondy/response.rb
|
120
121
|
- lib/fondy/signature.rb
|
122
|
+
- lib/fondy/transaction_list_response.rb
|
121
123
|
- lib/fondy/version.rb
|
122
124
|
homepage: https://github.com/busfor/fondy
|
123
125
|
licenses:
|
@@ -139,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
141
|
version: '0'
|
140
142
|
requirements: []
|
141
143
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
144
|
+
rubygems_version: 2.5.2.1
|
143
145
|
signing_key:
|
144
146
|
specification_version: 4
|
145
147
|
summary: Ruby wrapper for Fondy API
|