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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 881a99289c3011b73d93cb47cf731b6e7c123c98
4
- data.tar.gz: 26d7b853649b57ab7f6668b81a7127ee67fc1720
3
+ metadata.gz: d92f2aaad01c0ebc7a226cbb22fc08b52d74c697
4
+ data.tar.gz: 070694f59a56765b20971805470f712704b74ded
5
5
  SHA512:
6
- metadata.gz: 4bb7f29746e165f7df9aaf812a26699d2db99d04285c5401dfecce47d4a7d80a53f8b17d8c88dd4dae4cd17f2922f5ffe42c696210b07cfbf016b5239ee949f6
7
- data.tar.gz: ef4b270bbecf0b1b46d9daef7bf2ed0eef752bfa65043843fda2a2c250c601952864c8d8d6627f1c93f45b28e7be4b56a541c79080ceaaf5e8a9369590b0c61a
6
+ metadata.gz: dfa8a207525114da3d26f2268be95bbf4023ab3330cdeb796ec5518e2f4612844f5b76d82b1792531c170d9145f61445f8096165f19c3f0965e29f92c0ee6ee1
7
+ data.tar.gz: 0735a33a6509d8f53993287b667b6dd6da1dbb702813c54a3657cb4a760406cc412e3e53db43b89da3c31afba76c5521d9f36c0e096479fe8d92e04fe8157c7f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xdelivery (0.2.0)
4
+ xdelivery (0.2.3)
5
5
  rest-client
6
6
 
7
7
  GEM
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module Xdelivery
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/xdelivery.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'rest-client'
3
3
  require "xdelivery/version"
4
+ require "xdelivery/callback"
4
5
  require "xdelivery/client"
5
6
  require "xdelivery/api/base"
6
7
  require "xdelivery/api/orders"
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.3
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-30 00:00:00.000000000 Z
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