open_jd 0.0.3 → 0.0.4
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 +27 -22
- data/lib/open_jd/version.rb +1 -1
- data/open_jd.gemspec +0 -2
- metadata +1 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33f947199073cf79f1181b91783809cd4da37da5
|
4
|
+
data.tar.gz: 525bd4dfe1e4203098bdf72ff62e2dc5860ea11a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7a8704d38670b9dfc197dbf31f95f04ea906613bcece2f6b98fda4c5e2b21cdde947188f3600d79919c0a4bec7ecf6796b214c87344951252933863b01ea1d
|
7
|
+
data.tar.gz: 85c28a66a1542f276d572290ad9f57b42e3d2fd8d47cfeda48913d3d409d06c37af4c3214a63e82a794beb356b744ec7a10af254da0e54ed63973519bb4941de
|
data/README.md
CHANGED
@@ -1,56 +1,61 @@
|
|
1
1
|
OpenJd
|
2
2
|
==========
|
3
3
|
|
4
|
-
|
4
|
+
京东开放平台 JOS Ruby SDK
|
5
5
|
|
6
|
-
##
|
6
|
+
## 感谢
|
7
7
|
|
8
|
-
|
8
|
+
代码参考了 [open_taobao][], 非常感谢 Ryan
|
9
9
|
|
10
|
-
|
10
|
+
## 京东开放平台
|
11
|
+
|
12
|
+
## 安装
|
13
|
+
|
14
|
+
添加下列代码到 Gemfile 文件
|
11
15
|
|
12
16
|
gem 'open_jd'
|
13
17
|
|
14
|
-
|
18
|
+
如果使用 [patron][] 代替 Net::HTTP, 请在 Gemfile 中添加下列代码
|
15
19
|
|
16
20
|
gem 'patron'
|
17
21
|
|
18
|
-
|
22
|
+
执行 bundle 安装:
|
19
23
|
|
20
24
|
$ bundle
|
21
25
|
|
22
|
-
|
26
|
+
或者使用 gem 命令安装:
|
23
27
|
|
24
28
|
$ gem install open_jd
|
25
29
|
|
26
|
-
##
|
30
|
+
## 使用
|
27
31
|
|
28
|
-
### Rails
|
32
|
+
### Rails 使用 yaml 配置文件
|
29
33
|
|
30
|
-
|
34
|
+
运行 generator 创建配置文件:
|
31
35
|
|
32
36
|
$ rails g open_jd:install
|
37
|
+
|
38
|
+
上述命令会在 config 目录创建 jd.yml 配置文件
|
33
39
|
|
34
|
-
|
35
|
-
Open the file and configure it with your jd info.
|
36
|
-
|
37
|
-
Notice: `app_key`, `secret_key`, `endpoint` must be included in your YAML file, otherwise OpenJd.load will fail.
|
40
|
+
打开这个文件并填写您在京东开放平台的相关信息
|
38
41
|
|
39
|
-
|
42
|
+
注意: `app_key`, `secret_key`, `endpoint` 为必填项
|
40
43
|
|
41
|
-
|
44
|
+
其中 `app_key` 和 `secret_key` 会注册为 `ENV['JD_API_KEY']`, `ENV['JD_SECRET_KEY']`
|
42
45
|
|
46
|
+
使用 `OpenJd.get` 或 `OpenJd.post`:
|
47
|
+
|
43
48
|
hash = OpenJd.post(
|
44
49
|
method: 'jingdong.ware.product.detail.search.list.get',
|
45
50
|
fields: { skuId: params[:id], isLoadWareScore: false, client: 'm' }
|
46
51
|
)
|
47
52
|
|
48
53
|
|
49
|
-
|
54
|
+
返回值为 Hash 格式.
|
50
55
|
|
51
|
-
|
56
|
+
另外也可以使用 `OpenJd.get!` 和 `OpenJd.post!` 在发生错误时会抛出 `OpenJd::Error`.
|
52
57
|
|
53
|
-
###
|
58
|
+
### 在 Ruby 代码中使用
|
54
59
|
|
55
60
|
OpenJd.config = {
|
56
61
|
'app_key' => 'test',
|
@@ -65,10 +70,9 @@ Also `OpenJd.get!` and `OpenJd.post!` are avaliable, which will raise an `OpenJd
|
|
65
70
|
fields: { skuId: params[:id], isLoadWareScore: false, client: 'm' }
|
66
71
|
)
|
67
72
|
|
68
|
-
###
|
73
|
+
### 查看请求字符串
|
69
74
|
|
70
|
-
|
71
|
-
The query string will change every time your executed because timestamps changed.
|
75
|
+
如果需要查看发出的请求字符串, 请使用 OpenJd.url 方法
|
72
76
|
|
73
77
|
OpenJd.url(
|
74
78
|
method: 'jingdong.ware.product.detail.search.list.get',
|
@@ -84,3 +88,4 @@ The query string will change every time your executed because timestamps changed
|
|
84
88
|
5. Create new Pull Request
|
85
89
|
|
86
90
|
[patron]: https://github.com/toland/patron
|
91
|
+
[open_taobao]: https://github.com/wongyouth/open_taobao
|
data/lib/open_jd/version.rb
CHANGED
data/open_jd.gemspec
CHANGED
@@ -19,7 +19,5 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_dependency 'multi_json', '>= 0'
|
20
20
|
gem.add_dependency 'faraday', '>= 0'
|
21
21
|
gem.add_development_dependency 'rspec', '>= 0'
|
22
|
-
gem.add_development_dependency 'debugger', '>= 0'
|
23
|
-
gem.add_development_dependency 'autotest', '>= 0'
|
24
22
|
gem.add_development_dependency 'rake', '>= 0'
|
25
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_jd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Hao
|
@@ -52,34 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: debugger
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: autotest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: rake
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|