dianping-api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/dianping/api.rb +5 -2
- data/lib/dianping/api/client.rb +2 -0
- data/lib/dianping/api/middle_ware.rb +9 -2
- data/lib/dianping/api/modules/tuangou.rb +20 -0
- data/lib/dianping/api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3221f07cd5c4e9b610a2ad6e5752816a542387b8db12f0f3c86f2d631ed39089
|
4
|
+
data.tar.gz: 15032efba732a33d797ab1d3a8f96695ef6f55ce92c09cc6048b777684e315ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d94c5c7381bb2e560689cbd858f98748d5aa743f7da4fd39db94d142a679a2c5df70c77c42417d051c045eae6b37e96a88840c99bd2eb6f138e61446ece3e73
|
7
|
+
data.tar.gz: c4c76fab3731eccc2b31244c852451403cb7310d33f4a25d3824f3419fdabe68b143117dbf0a1e3902abd7fd81f9d5363cd9e280388cbf871f8896d474a259c0
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
dianping-api (0.1.0)
|
5
5
|
faraday (~> 1.0)
|
6
|
-
multi_json (
|
6
|
+
multi_json (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -82,12 +82,12 @@ PLATFORMS
|
|
82
82
|
DEPENDENCIES
|
83
83
|
bundler (~> 1.17)
|
84
84
|
dianping-api!
|
85
|
-
guard (
|
86
|
-
guard-rspec (
|
85
|
+
guard (~> 2.0)
|
86
|
+
guard-rspec (~> 4.0)
|
87
87
|
rake (~> 10.0)
|
88
|
-
rspec (
|
89
|
-
rspec-its (
|
90
|
-
webmock (
|
88
|
+
rspec (~> 3.0)
|
89
|
+
rspec-its (~> 1.0)
|
90
|
+
webmock (~> 3.0)
|
91
91
|
|
92
92
|
BUNDLED WITH
|
93
93
|
1.17.3
|
data/lib/dianping/api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'dianping/api/version'
|
2
2
|
require 'faraday'
|
3
3
|
|
4
4
|
module Dianping
|
@@ -8,11 +8,14 @@ module Dianping
|
|
8
8
|
class UsageError < StandardError; end
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
|
+
module Modules; end
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
require 'dianping/api/modules/tuangou'
|
16
|
+
|
14
17
|
require 'dianping/api/middle_ware'
|
15
18
|
require 'dianping/api/token'
|
16
19
|
require 'dianping/api/client'
|
17
20
|
|
18
|
-
Faraday::Request.register_middleware dianping: ::Dianping::Api::MiddleWare
|
21
|
+
Faraday::Request.register_middleware dianping: ::Dianping::Api::MiddleWare
|
data/lib/dianping/api/client.rb
CHANGED
@@ -11,7 +11,8 @@ module Dianping
|
|
11
11
|
def call(env)
|
12
12
|
check_session(env)
|
13
13
|
@app.call(env).on_complete do |response_env|
|
14
|
-
|
14
|
+
hash = MultiJson.load response_env.body, symbolized_keys: true
|
15
|
+
check_response(hash)
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -23,7 +24,13 @@ module Dianping
|
|
23
24
|
raise TokenExpireError
|
24
25
|
end
|
25
26
|
|
26
|
-
def check_response(
|
27
|
+
def check_response(body)
|
28
|
+
code = body[:code].to_i
|
29
|
+
msg = format('[%<code>d]%<msg>s', code: code, msg: body[:msg])
|
30
|
+
|
31
|
+
raise TokenExpireError, msg if code == 608
|
32
|
+
raise UsageError, msg if code >= 800
|
33
|
+
raise Error, msg unless code == 200
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Dianping
|
2
|
+
module Api
|
3
|
+
module Modules
|
4
|
+
module Tuangou
|
5
|
+
def receipt_pre_code(shop_uuid, code)
|
6
|
+
post('/router/tuangou/receipt/prepare', open_shop_uuid: shop_uuid, receipt_code: code)
|
7
|
+
end
|
8
|
+
|
9
|
+
def receipt_consume(shop_uuid, code, request_id, count = 1, **params)
|
10
|
+
params.merge! open_shop_uuid: shop_uuid,
|
11
|
+
receipt_code: code,
|
12
|
+
request_id: request_id,
|
13
|
+
count: count
|
14
|
+
|
15
|
+
post '/router/tuangou/receipt/consume', params
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/dianping/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dianping-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/dianping/api.rb
|
160
160
|
- lib/dianping/api/client.rb
|
161
161
|
- lib/dianping/api/middle_ware.rb
|
162
|
+
- lib/dianping/api/modules/tuangou.rb
|
162
163
|
- lib/dianping/api/token.rb
|
163
164
|
- lib/dianping/api/version.rb
|
164
165
|
homepage: https://github.com/lazing/dianping-api
|