dian_ping 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +54 -11
- data/lib/dian_ping.rb +10 -2
- data/lib/dianping/parameter.rb +18 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dcc6881a2d3b37f355dc67ddd6e27f6b6c4b1c9
|
4
|
+
data.tar.gz: 4ed633d1d4aa70b6a812250c58dfcb51d94238b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2460e6bb7dcb98c66509fb8acc4fbda27cd1008e732da3599fe28d90f443e082b2dd34ef0039018b425fdb6d3bd65a86bb86027709f4063736da37592a581025
|
7
|
+
data.tar.gz: 005a64593b123ac5d8e6eec4689eb3648f3984ae44fc13f307b3c6fcc1660b3a3935cf6588f2ccac0b9bafdb849546c6160990d29aa9621647eacd02c75ae7cf
|
data/README.md
CHANGED
@@ -1,20 +1,63 @@
|
|
1
|
-
|
2
|
-
=========
|
1
|
+
## 大众点评API
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
Install
|
7
|
-
=========
|
3
|
+
### 安装
|
8
4
|
|
5
|
+
```
|
9
6
|
gem install 'dian_ping'
|
7
|
+
```
|
10
8
|
|
11
|
-
|
12
|
-
=========
|
9
|
+
### 优点
|
13
10
|
|
14
|
-
|
15
|
-
|
11
|
+
#### 可选参数都映射为方法链
|
12
|
+
#### 参考[API](http://developer.dianping.com/app/api/v1/business/find_businesses)
|
13
|
+
|
14
|
+
### 使用
|
16
15
|
|
16
|
+
```
|
17
|
+
require 'dian_ping'
|
17
18
|
dp = DianPing.new(key: 'Your key', secret: 'Your secret')
|
18
|
-
|
19
|
+
|
20
|
+
# 搜索商户
|
21
|
+
# 搜索上海有优惠卷的商家
|
22
|
+
dp.has_coupon.city('上海').find
|
23
|
+
|
24
|
+
# 分页
|
25
|
+
dp.city('上海').page(1).find
|
26
|
+
|
27
|
+
# 获取指定商户信息
|
28
|
+
dp.shop('2951611')
|
29
|
+
|
30
|
+
# 获取指定商户最新点评片断
|
31
|
+
dp.reviews('2951611')
|
32
|
+
|
33
|
+
# 获取支持商户搜索的最新城市列表
|
34
|
+
dp.cities
|
35
|
+
|
36
|
+
# 获取支持商户搜索的最新分类列表
|
37
|
+
dp.categories
|
38
|
+
|
39
|
+
# 获取支持商户搜索的最新城市下属区域列表
|
40
|
+
dp.regions('上海')
|
41
|
+
|
42
|
+
# 获取支持在线预订的全部商户ID列表
|
43
|
+
dp.reservations('上海')
|
44
|
+
|
45
|
+
# 获取当前在线的全部团购ID列表
|
46
|
+
dp.deals('上海')
|
47
|
+
|
48
|
+
# 获取指定团购信息
|
49
|
+
dp.deal('1-5097286')
|
50
|
+
|
51
|
+
# 通过api地址调用
|
52
|
+
dp.get('/v1/deal/get_deals_by_business_id', {city: '上海', business_id: '2951611'})
|
19
53
|
|
20
54
|
```
|
55
|
+
|
56
|
+
### Rails
|
57
|
+
|
58
|
+
* 在Gemfile添加gem
|
59
|
+
* 执行bundle exec rake dian_ping:install
|
60
|
+
* 在config/dian_ping.yml补全
|
61
|
+
* 使用DP.进行调用
|
62
|
+
|
63
|
+
|
data/lib/dian_ping.rb
CHANGED
@@ -6,7 +6,7 @@ require 'dianping/parameter'
|
|
6
6
|
class DianPing
|
7
7
|
include HTTParty
|
8
8
|
|
9
|
-
VERSION = '0.0
|
9
|
+
VERSION = '0.1.0'
|
10
10
|
|
11
11
|
attr_accessor :key, :secret
|
12
12
|
|
@@ -16,7 +16,15 @@ class DianPing
|
|
16
16
|
@key, @secret = opts.values_at(:key, :secret)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
# @param route [String] 请求的URL
|
20
|
+
# @param param [Hash] 传递的参数
|
21
|
+
# @return [Hash]
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# dp = DianPing.new(key: 'Your key', secret: 'Your secret')
|
25
|
+
# dp.get('/v1/reservation/get_all_id_list', {city: '上海'})
|
26
|
+
#
|
27
|
+
def get(route, param = {})
|
20
28
|
param[:sign] = signature(param)
|
21
29
|
param[:appkey] = @key
|
22
30
|
self.class.get route, query: param
|
data/lib/dianping/parameter.rb
CHANGED
@@ -22,11 +22,24 @@ class DianPing
|
|
22
22
|
client.get(route, self)
|
23
23
|
end
|
24
24
|
|
25
|
+
# 商户类
|
26
|
+
|
27
|
+
# 搜索商户
|
28
|
+
# @example
|
29
|
+
# DP.has_coupon.city('上海').find
|
30
|
+
def find
|
31
|
+
get '/v1/business/find_businesses'
|
32
|
+
end
|
33
|
+
|
25
34
|
# 获取指定商户信息
|
35
|
+
# @example
|
36
|
+
# DP.business('2951611')
|
37
|
+
# DP.shop('2951611')
|
26
38
|
def business(id)
|
27
39
|
add :business_id, id
|
28
40
|
get '/v1/business/get_single_business'
|
29
41
|
end
|
42
|
+
alias_method :shop, :business
|
30
43
|
|
31
44
|
# 获取指定商户最新点评片断
|
32
45
|
def reviews(id)
|
@@ -34,6 +47,11 @@ class DianPing
|
|
34
47
|
get '/v1/review/get_recent_reviews'
|
35
48
|
end
|
36
49
|
|
50
|
+
# 获取支持商户搜索的最新城市列表
|
51
|
+
def cities
|
52
|
+
get '/v1/metadata/get_cities_with_businesses'
|
53
|
+
end
|
54
|
+
|
37
55
|
# 获取支持商户搜索的最新分类列表
|
38
56
|
def categories(city = nil)
|
39
57
|
add :city, city
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dian_ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zires
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -112,7 +112,8 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- README.md
|
114
114
|
homepage: https://github.com/zires/dian-ping
|
115
|
-
licenses:
|
115
|
+
licenses:
|
116
|
+
- MIT
|
116
117
|
metadata: {}
|
117
118
|
post_install_message:
|
118
119
|
rdoc_options: []
|