xdelivery 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/xdelivery/callback.rb +59 -0
- data/lib/xdelivery/version.rb +1 -1
- data/lib/xdelivery.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d92f2aaad01c0ebc7a226cbb22fc08b52d74c697
|
4
|
+
data.tar.gz: 070694f59a56765b20971805470f712704b74ded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa8a207525114da3d26f2268be95bbf4023ab3330cdeb796ec5518e2f4612844f5b76d82b1792531c170d9145f61445f8096165f19c3f0965e29f92c0ee6ee1
|
7
|
+
data.tar.gz: 0735a33a6509d8f53993287b667b6dd6da1dbb702813c54a3657cb4a760406cc412e3e53db43b89da3c31afba76c5521d9f36c0e096479fe8d92e04fe8157c7f
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Xdelivery
|
2
|
+
class Callback
|
3
|
+
attr_accessor :params, :check_code, :merchant_no, :access_key
|
4
|
+
|
5
|
+
PARAM_KEYS = [ :action, :title, :desc, :provider, :created_at ]
|
6
|
+
|
7
|
+
def initialize(merchant_no, access_key, params)
|
8
|
+
self.params = PARAM_KEYS.map do |key|
|
9
|
+
[ key, params[key] ]
|
10
|
+
end.to_h
|
11
|
+
|
12
|
+
self.check_code = params[:check_code]
|
13
|
+
self.merchant_no = merchant_no
|
14
|
+
self.access_key = access_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid?
|
18
|
+
check_code == check_code!
|
19
|
+
end
|
20
|
+
|
21
|
+
def action
|
22
|
+
params[:action]
|
23
|
+
end
|
24
|
+
|
25
|
+
def title
|
26
|
+
params[:title]
|
27
|
+
end
|
28
|
+
|
29
|
+
def desc
|
30
|
+
params[:desc]
|
31
|
+
end
|
32
|
+
|
33
|
+
def provider
|
34
|
+
params[:provider]
|
35
|
+
end
|
36
|
+
|
37
|
+
def created_at
|
38
|
+
if params[:created_at] == ''
|
39
|
+
nil
|
40
|
+
elsif Time.respond_to?(:zone)
|
41
|
+
Time.zone.parse(params[:created_at])
|
42
|
+
else
|
43
|
+
Time.parse(params[:created_at])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def query_string
|
50
|
+
URI.encode_www_form(params.sort.to_h)
|
51
|
+
end
|
52
|
+
|
53
|
+
def check_code!
|
54
|
+
query_string_with_salt = "merchant_no=#{merchant_no}&#{query_string}&access_key=#{access_key}"
|
55
|
+
Digest::SHA256.hexdigest(query_string_with_salt).upcase
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
data/lib/xdelivery/version.rb
CHANGED
data/lib/xdelivery.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xdelivery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eddie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/xdelivery/api/response/ping.rb
|
109
109
|
- lib/xdelivery/api/response/products.rb
|
110
110
|
- lib/xdelivery/api/sales.rb
|
111
|
+
- lib/xdelivery/callback.rb
|
111
112
|
- lib/xdelivery/client.rb
|
112
113
|
- lib/xdelivery/version.rb
|
113
114
|
- xdelivery-ruby.gemspec
|