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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da6705b6eb7d999d2db9500dea1f9294e09eb2c6
4
- data.tar.gz: a6bf1512d7719944b911d747147934e60becc60e
3
+ metadata.gz: 33f947199073cf79f1181b91783809cd4da37da5
4
+ data.tar.gz: 525bd4dfe1e4203098bdf72ff62e2dc5860ea11a
5
5
  SHA512:
6
- metadata.gz: b1fe76f4385f08056a6dd8e324dd003d6cf456a6df1a14140c2dbb31e8da091633aaaa76fccef376e554f0d7244f5765d474b6b92911a9fb95cb2b82d3b38109
7
- data.tar.gz: 31350e69258e0ab661537c57eb13af46fa8d9c9f9da95e3f8fd4f4cfa838dd56dfb5b57141f3dbbd12d8bd770777063ac18a406b7740e127c918acd3d6839067
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
- JD Open Platform client for ruby. Rails3+ is supported.
4
+ 京东开放平台 JOS Ruby SDK
5
5
 
6
- ## NOTICE
6
+ ## 感谢
7
7
 
8
- ## Installation
8
+ 代码参考了 [open_taobao][], 非常感谢 Ryan
9
9
 
10
- Add this line to your application's Gemfile:
10
+ ## 京东开放平台
11
+
12
+ ## 安装
13
+
14
+ 添加下列代码到 Gemfile 文件
11
15
 
12
16
  gem 'open_jd'
13
17
 
14
- If you want to use [patron][] as http client instead of Net::HTTP, add line below to your Gemfile
18
+ 如果使用 [patron][] 代替 Net::HTTP, 请在 Gemfile 中添加下列代码
15
19
 
16
20
  gem 'patron'
17
21
 
18
- And then execute:
22
+ 执行 bundle 安装:
19
23
 
20
24
  $ bundle
21
25
 
22
- Or install it yourself as:
26
+ 或者使用 gem 命令安装:
23
27
 
24
28
  $ gem install open_jd
25
29
 
26
- ## Usage
30
+ ## 使用
27
31
 
28
- ### Rails with yaml file configured
32
+ ### Rails 使用 yaml 配置文件
29
33
 
30
- Run generator to generate config file:
34
+ 运行 generator 创建配置文件:
31
35
 
32
36
  $ rails g open_jd:install
37
+
38
+ 上述命令会在 config 目录创建 jd.yml 配置文件
33
39
 
34
- It will generate a `jd.yml` file under your Rails' config dir.
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
- The `app_key` and `secret_key` are avaliable by `ENV['JD_API_KEY']`, `ENV['JD_SECRET_KEY']` out of the box if you use same keys for other jd related gems, e.g. omniauth-taobao.
42
+ 注意: `app_key`, `secret_key`, `endpoint` 为必填项
40
43
 
41
- call `OpenJd.get` or `OpenJd.post`,with jd parameters:
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
- The return data will be converted to a Hash automatically.
54
+ 返回值为 Hash 格式.
50
55
 
51
- Also `OpenJd.get!` and `OpenJd.post!` are avaliable, which will raise an `OpenJd::Error` if a `error_response` receieved.
56
+ 另外也可以使用 `OpenJd.get!` `OpenJd.post!` 在发生错误时会抛出 `OpenJd::Error`.
52
57
 
53
- ### plain ruby
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
- ### get query string
73
+ ### 查看请求字符串
69
74
 
70
- If you want the query string with some params just pass the params to OpenJd.url() the same as OpenJd.get().
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
@@ -1,3 +1,3 @@
1
1
  module OpenJd
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
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.3
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