ubox 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/lib/ubox.rb +17 -17
  4. data/lib/ubox/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37c543c515a9c858bb59e2a555c26d7e21543b16
4
- data.tar.gz: a8df0afb085b8fdefb62f92e5dbbe2bc44c21016
3
+ metadata.gz: 249f22e3cb2b990d51888c7deb9312410aa2b628
4
+ data.tar.gz: 294f9fb278bd81ac099bb97b57893239e00e29ca
5
5
  SHA512:
6
- metadata.gz: 61b29083aadc4cdc90f8e32c041d3c1a6078705b27143705f911adbe0b1269e19763c21eb007ba2519d2bd8028c73e304ac0ac120aa53201c1de465c924aa515
7
- data.tar.gz: 332b56eaff91bd2129c43352652051a36f7ee345610bc36bfb7d26375ed7449eafaf02fd9d857248777280288976eaa44c607f3fc30e001473c80f27689c5afa
6
+ metadata.gz: 26071bd34a3dd9fb7a9681eb6c3da35ab846a66ae2a3cba9c5d4d77686366fcd3d1dfafc2a568c3cff943148d0c88ca5d378b747e2718b6fb5781ffabda3af06
7
+ data.tar.gz: e8efa21256ee819cbc4d9665ca78497d24170e7a516280a36e3c8cad6e6815c4e6af32da791c7f921dd948323fd616f090c85221326a6c52358bcd4c7f963e58
data/README.md CHANGED
@@ -34,9 +34,9 @@ Or install it yourself as:
34
34
 
35
35
  ## Usage
36
36
 
37
- ###获取商品信息(扫码)
37
+ ###getProductDetail 获取商品信息(扫码)
38
38
  ```ruby
39
- Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
39
+ Ubox.product_detail(qr_string:'http://v.dev.uboxol.com/qr/c0081801_10000870_1')
40
40
  ```
41
41
 
42
42
  ```json
@@ -71,9 +71,9 @@ Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
71
71
  }
72
72
  }
73
73
  ```
74
- ### 扫码下单请求
74
+ ### notifyOrder 扫码下单请求
75
75
  ```ruby
76
- detail = Ubox.product_detail('http://v.dev.uboxol.com/qr/c0081801_10000870_1')
76
+ detail = Ubox.product_detail(qr_string:'http://v.dev.uboxol.com/qr/c0081801_10000870_1')
77
77
  notify = Ubox.notify_order(tran_id: detail['body']['tran_id'],
78
78
  retain_period: 300,
79
79
  app_tran_id: Random.rand_str(32),
@@ -31,15 +31,16 @@ module Ubox
31
31
  params.inject([]) { |a, (k, v)| a<<"#{k}=#{v}"; a }.join("&")
32
32
  end
33
33
 
34
- #商品详情
35
- def product_detail(qr_string)
34
+
35
+ def post_request(api_path, attributes)
36
+ puts attributes
36
37
  params = {
37
38
  app_id: self.config.app_id,
38
- qr_string: qr_string
39
- }
39
+ tran_id: attributes[:tran_id]
40
+ }.merge(attributes)
40
41
  params = params.merge({sign: self.sign(params)})
41
42
 
42
- url = "#{self.config.api_url}/getProductDetail"
43
+ url = "#{self.config.api_url}/#{api_path}"
43
44
  uri = URI(url)
44
45
  res = Net::HTTP.post_form(uri, params)
45
46
 
@@ -47,22 +48,21 @@ module Ubox
47
48
  JSON.parse(body)
48
49
  end
49
50
 
51
+ #商品详情
52
+ def product_detail(attributes)
53
+ post_request('/getProductDetail', attributes)
54
+ end
55
+
50
56
  #扫码下单请求
51
57
  #notify_order(tran_id:xxxx,retain_period:300,app_tran_id:xxxx,app_uid:uid)
52
58
  def notify_order(attributes)
53
- puts attributes
54
- params = {
55
- app_id: self.config.app_id,
56
- tran_id: attributes[:tran_id]
57
- }.merge(attributes)
58
- params = params.merge({sign: self.sign(params)})
59
-
60
- url = "#{self.config.api_url}/notifyOrder"
61
- uri = URI(url)
62
- res = Net::HTTP.post_form(uri, params)
59
+ post_request('/notifyOrder', attributes)
60
+ end
63
61
 
64
- body = res.body
65
- JSON.parse(body)
62
+ #m买取货吗(支付结果通知)
63
+ #notify_payment(tran_id:xxx,pay_time:13311111,app_current_time:true,deliver_now:true)
64
+ def notify_payment(attributes)
65
+ post_request('/notifyPayment', attributes)
66
66
  end
67
67
 
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module Ubox
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saxer