e_way_client 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/e_way_client.gemspec +2 -1
- data/lib/e_way_client/client.rb +8 -1
- data/lib/e_way_client/requests/base_request.rb +26 -0
- data/lib/e_way_client/requests/query_list_banks_request.rb +7 -9
- data/lib/e_way_client/requests/query_list_provinces_request.rb +0 -11
- data/lib/e_way_client/requests/query_txn_status_request.rb +25 -0
- data/lib/e_way_client/requests/send_transaction_request.rb +1 -5
- data/lib/e_way_client/responses/query_txn_status_response.rb +38 -0
- data/lib/e_way_client/services/gen_action_name.rb +9 -0
- data/lib/e_way_client/version.rb +1 -1
- data/lib/e_way_client.rb +5 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba5f66e336421d641d01909026ac3724a719b7e
|
4
|
+
data.tar.gz: 83d0654b22cb20d7a7ce89f3310248acff44e143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70bc39d9efcbafeffba6b1eb9df1a7a2dae6fef63de53060ac7e378ded65d532abea5d19d15d4929d685ad12a2150c7a0794b54868eb0c8ed66870cb6d0913bf
|
7
|
+
data.tar.gz: 42782d16ac779ae01e12f0d1d18f3d120a551140d8b958ce80f3fdbc940d2a69bbe7bdb7a11cb3e5fd5e47767c019aebda4bd5af572d8aab6fa77a386b807bd5
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [0.2.0] - 2017-02-13
|
8
|
+
### Added
|
9
|
+
- Option to log Savon requests
|
10
|
+
- `query_txn_status` call to get a transaction's status
|
11
|
+
|
7
12
|
## [0.1.1] - 2017-01-09
|
8
13
|
### Fixed
|
9
14
|
- Do not blow up if `diffgram` in XML response is missing. Return nil instead.
|
data/e_way_client.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.add_dependency "virtus", "~> 1.0"
|
33
33
|
spec.add_dependency "api_client_base", "~> 0.2.0"
|
34
|
-
spec.add_dependency "soap_client", "~> 0.
|
34
|
+
spec.add_dependency "soap_client", "~> 0.3.0"
|
35
35
|
spec.add_dependency "deep_fetch"
|
36
36
|
|
37
37
|
spec.add_development_dependency "bundler", "~> 1.13"
|
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "virtus-matchers"
|
41
41
|
spec.add_development_dependency "vcr"
|
42
42
|
spec.add_development_dependency "webmock"
|
43
|
+
spec.add_development_dependency "timecop"
|
43
44
|
end
|
data/lib/e_way_client/client.rb
CHANGED
@@ -8,18 +8,25 @@ module EWayClient
|
|
8
8
|
attribute :username, String
|
9
9
|
attribute :password, String
|
10
10
|
attribute :secret, String
|
11
|
+
attribute :log, Boolean, lazy: true, default: false
|
12
|
+
attribute :logger, Object, lazy: true, default: :default_logger
|
11
13
|
|
12
14
|
api_action :query_list_banks
|
13
15
|
api_action :query_list_provinces
|
14
16
|
api_action :send_transaction
|
17
|
+
api_action :query_txn_status, args: [:transaction_id]
|
15
18
|
|
16
19
|
private
|
17
20
|
|
18
21
|
def default_opts
|
19
|
-
%i[wsdl username password secret].each_with_object({}) do |attr, hash|
|
22
|
+
%i[wsdl username password secret log logger].each_with_object({}) do |attr, hash|
|
20
23
|
hash[attr] = send(attr)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
27
|
+
def default_logger
|
28
|
+
Logger.new(STDOUT)
|
29
|
+
end
|
30
|
+
|
24
31
|
end
|
25
32
|
end
|
@@ -1,10 +1,36 @@
|
|
1
1
|
module EWayClient
|
2
2
|
class BaseRequest
|
3
3
|
|
4
|
+
SOAP_ATTRS = %i[wsdl username password log logger message action]
|
5
|
+
|
4
6
|
include Virtus.model
|
5
7
|
attribute :wsdl, String
|
6
8
|
attribute :username, String
|
7
9
|
attribute :password, String
|
10
|
+
attribute :log, Boolean, lazy: true, default: false
|
11
|
+
attribute :logger, Object
|
12
|
+
attribute :message, Hash, lazy: true, default: :default_message
|
13
|
+
attribute :action, Symbol, lazy: true, default: :default_action
|
14
|
+
attribute(:soap_client_args, Hash, {
|
15
|
+
lazy: true,
|
16
|
+
default: :default_soap_client_args,
|
17
|
+
})
|
18
|
+
|
19
|
+
def call
|
20
|
+
SOAPClient.(soap_client_args)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def default_action
|
26
|
+
GenActionName.(self.class)
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_soap_client_args
|
30
|
+
SOAP_ATTRS.each_with_object({}) do |attr, hash|
|
31
|
+
hash[attr] = self.send(attr)
|
32
|
+
end
|
33
|
+
end
|
8
34
|
|
9
35
|
end
|
10
36
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module EWayClient
|
2
2
|
class QueryListBanksRequest < BaseRequest
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
},
|
12
|
-
)
|
4
|
+
private
|
5
|
+
|
6
|
+
def default_message
|
7
|
+
{
|
8
|
+
"USERNAME" => username,
|
9
|
+
"PASSWORD" => password,
|
10
|
+
}
|
13
11
|
end
|
14
12
|
|
15
13
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EWayClient
|
2
|
+
class QueryTxnStatusRequest < BaseRequest
|
3
|
+
|
4
|
+
attribute :agent_code, String
|
5
|
+
attribute :username, String
|
6
|
+
attribute :password, String
|
7
|
+
attribute :transaction_id, String
|
8
|
+
|
9
|
+
MESSAGE_ATTRS = %i[
|
10
|
+
agent_code
|
11
|
+
username
|
12
|
+
password
|
13
|
+
transaction_id
|
14
|
+
]
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def default_message
|
19
|
+
MESSAGE_ATTRS.each_with_object({}) do |attr, hash|
|
20
|
+
hash[attr.to_s.upcase] = send(attr)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -73,10 +73,6 @@ module EWayClient
|
|
73
73
|
bankbranch_address
|
74
74
|
]
|
75
75
|
|
76
|
-
def call
|
77
|
-
SOAPClient.(wsdl: wsdl, action: :send_transaction, message: message)
|
78
|
-
end
|
79
|
-
|
80
76
|
def transaction_date
|
81
77
|
return nil if super.nil?
|
82
78
|
super.in_time_zone("Bangkok").strftime("%m/%d/%Y %H:%M:%S")
|
@@ -84,7 +80,7 @@ module EWayClient
|
|
84
80
|
|
85
81
|
private
|
86
82
|
|
87
|
-
def
|
83
|
+
def default_message
|
88
84
|
MESSAGE_ATTRS.each_with_object({}) do |attr, hash|
|
89
85
|
hash[attr.to_s.upcase] = send(attr)
|
90
86
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module EWayClient
|
2
|
+
class QueryTxnStatusResponse < BaseResponse
|
3
|
+
|
4
|
+
SUCCESS_RESPONSE_CODE = "0000"
|
5
|
+
|
6
|
+
attribute(:response_code, String, {
|
7
|
+
lazy: true,
|
8
|
+
default: :default_response_code,
|
9
|
+
})
|
10
|
+
attribute(:error_message, String, {
|
11
|
+
lazy: true,
|
12
|
+
default: :default_error_message,
|
13
|
+
})
|
14
|
+
attribute :transaction_status, String, {
|
15
|
+
lazy: true,
|
16
|
+
default: :default_transaction_status,
|
17
|
+
}
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_success
|
22
|
+
response_code == SUCCESS_RESPONSE_CODE
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_response_code
|
26
|
+
data[:response_code]
|
27
|
+
end
|
28
|
+
|
29
|
+
def default_error_message
|
30
|
+
"#{response_code}: unknown description"
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_transaction_status
|
34
|
+
data[:transaction_status]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/e_way_client/version.rb
CHANGED
data/lib/e_way_client.rb
CHANGED
@@ -11,10 +11,13 @@ require "e_way_client/requests/base_request"
|
|
11
11
|
require "e_way_client/requests/query_list_banks_request"
|
12
12
|
require "e_way_client/requests/query_list_provinces_request"
|
13
13
|
require "e_way_client/requests/send_transaction_request"
|
14
|
+
require "e_way_client/requests/query_txn_status_request"
|
14
15
|
require "e_way_client/responses/base_response"
|
15
16
|
require "e_way_client/responses/query_list_banks_response"
|
16
17
|
require "e_way_client/responses/query_list_provinces_response"
|
17
18
|
require "e_way_client/responses/send_transaction_response"
|
19
|
+
require "e_way_client/responses/query_txn_status_response"
|
20
|
+
require "e_way_client/services/gen_action_name"
|
18
21
|
|
19
22
|
module EWayClient
|
20
23
|
|
@@ -25,6 +28,8 @@ module EWayClient
|
|
25
28
|
has :username, classes: String
|
26
29
|
has :password, classes: String
|
27
30
|
has :secret, classes: String
|
31
|
+
has :log, values: [true, false], default: false
|
32
|
+
has :logger
|
28
33
|
end
|
29
34
|
|
30
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: e_way_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: deep_fetch
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: timecop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
description:
|
154
168
|
email:
|
155
169
|
- ramon.tayag@gmail.com
|
@@ -179,11 +193,14 @@ files:
|
|
179
193
|
- lib/e_way_client/requests/base_request.rb
|
180
194
|
- lib/e_way_client/requests/query_list_banks_request.rb
|
181
195
|
- lib/e_way_client/requests/query_list_provinces_request.rb
|
196
|
+
- lib/e_way_client/requests/query_txn_status_request.rb
|
182
197
|
- lib/e_way_client/requests/send_transaction_request.rb
|
183
198
|
- lib/e_way_client/responses/base_response.rb
|
184
199
|
- lib/e_way_client/responses/query_list_banks_response.rb
|
185
200
|
- lib/e_way_client/responses/query_list_provinces_response.rb
|
201
|
+
- lib/e_way_client/responses/query_txn_status_response.rb
|
186
202
|
- lib/e_way_client/responses/send_transaction_response.rb
|
203
|
+
- lib/e_way_client/services/gen_action_name.rb
|
187
204
|
- lib/e_way_client/version.rb
|
188
205
|
homepage: https://github.com/imacchiato/e_way_client-ruby
|
189
206
|
licenses:
|