open_taobao 0.0.3 → 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 +7 -0
- data/CHNAGELOG.md +3 -0
- data/README.md +29 -10
- data/lib/generators/templates/taobao.yml +0 -3
- data/lib/open_taobao/open_taobao.rb +7 -4
- data/lib/open_taobao/version.rb +1 -1
- data/open_taobao.gemspec +1 -1
- data/spec/open_taobao_spec.rb +7 -10
- metadata +21 -40
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0d2cd1f2224327805d2a53d744fa6a2e48bde17
|
4
|
+
data.tar.gz: 902d65b7f744defc6380de2ac0f66037a20d17c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 281732d45349bbaf20424eb940c272d7494571d19f74605328e95dc37342040b4107c10e7d8868d30cb1136002f53aef10706d7c09f645502f2fedea8cc7873f
|
7
|
+
data.tar.gz: aefdde07064cc319103cf3203e371c233c8e142a3db835f800c6846a28aa3d0aaf0b137566531b1a67174000c61bbc4a96fc9d7a41f7416f8bf072226cd9303d
|
data/CHNAGELOG.md
ADDED
data/README.md
CHANGED
@@ -3,12 +3,19 @@ OpenTaobao [
|
39
48
|
|
40
|
-
|
49
|
+
The return data will be converted to a Hash automatically.
|
41
50
|
|
42
51
|
### plain ruby
|
43
52
|
|
44
53
|
OpenTaobao.config = {
|
45
54
|
'app_key' => 'test',
|
46
55
|
'secret_key' => 'test',
|
47
|
-
'pid' => 'test',
|
48
56
|
'endpoint' => "http://gw.api.tbsandbox.com/router/rest"
|
49
57
|
}
|
50
58
|
|
@@ -56,6 +64,17 @@ Run generate to complete install:
|
|
56
64
|
:parent_cid => 0
|
57
65
|
)
|
58
66
|
|
67
|
+
### get query string
|
68
|
+
|
69
|
+
If you want the query string with some params just pass the params to OpenTaobao.url() the same as OpenTaobao.get().
|
70
|
+
The query string will change every time your executed because timestamps changed.
|
71
|
+
|
72
|
+
OpenTaobao.url(
|
73
|
+
:method => "taobao.itemcats.get",
|
74
|
+
:fields => "cid,parent_id,name,is_parent",
|
75
|
+
:parent_cid => 0
|
76
|
+
)
|
77
|
+
|
59
78
|
## Contributing
|
60
79
|
|
61
80
|
1. Fork it
|
@@ -1,18 +1,15 @@
|
|
1
1
|
development:
|
2
2
|
app_key: 'test'
|
3
3
|
secret_key: 'test'
|
4
|
-
pid: 'test'
|
5
4
|
endpoint: "http://gw.api.tbsandbox.com/router/rest"
|
6
5
|
|
7
6
|
test:
|
8
7
|
app_key: 'test'
|
9
8
|
secret_key: 'test'
|
10
|
-
pid: 'test'
|
11
9
|
endpoint: "http://gw.api.tbsandbox.com/router/rest"
|
12
10
|
|
13
11
|
production:
|
14
12
|
app_key: 'YOUR-KEY'
|
15
13
|
secret_key: 'YOUR-KEY'
|
16
|
-
pid: 'YOUR-PID'
|
17
14
|
endpoint: "http://gw.api.taobao.com/router/rest"
|
18
15
|
|
@@ -34,7 +34,6 @@ module OpenTaobao
|
|
34
34
|
#
|
35
35
|
# app_key: "YOUR APP KEY"
|
36
36
|
# secret_key: "YOUR SECRET KEY"
|
37
|
-
# pid: "YOUR TAOBAOKE pid"
|
38
37
|
# endpoint: "TAOBAO GATEWAY API URL"
|
39
38
|
#
|
40
39
|
def load(config_file)
|
@@ -55,7 +54,7 @@ module OpenTaobao
|
|
55
54
|
# raise exception if config key missed in YAML file
|
56
55
|
def check_config
|
57
56
|
list = []
|
58
|
-
%w(app_key secret_key
|
57
|
+
%w(app_key secret_key endpoint).map do |k|
|
59
58
|
list << k unless config.has_key? k
|
60
59
|
end
|
61
60
|
|
@@ -74,7 +73,7 @@ module OpenTaobao
|
|
74
73
|
ENV['TAOBAO_API_KEY'] = config['app_key']
|
75
74
|
ENV['TAOBAO_SECRET_KEY'] = config['secret_key']
|
76
75
|
ENV['TAOBAO_ENDPOINT'] = config['endpoint']
|
77
|
-
ENV['TAOBAOKE_PID'] = config['pid']
|
76
|
+
ENV['TAOBAOKE_PID'] = config['pid'] # for compatible with v0.0.3
|
78
77
|
end
|
79
78
|
|
80
79
|
# Initialize http sesison
|
@@ -91,7 +90,11 @@ module OpenTaobao
|
|
91
90
|
|
92
91
|
# Return request signature with MD5 signature method
|
93
92
|
def sign(params)
|
94
|
-
Digest::MD5::hexdigest(
|
93
|
+
Digest::MD5::hexdigest(wrap_with_secret sorted_option_string(params)).upcase
|
94
|
+
end
|
95
|
+
|
96
|
+
def wrap_with_secret(s)
|
97
|
+
config['secret_key'] + s + config['secret_key']
|
95
98
|
end
|
96
99
|
|
97
100
|
# Return sorted request parameter by request key
|
data/lib/open_taobao/version.rb
CHANGED
data/open_taobao.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/open_taobao/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["wongyouth"]
|
6
6
|
gem.email = ["wongyouth@gmail.com"]
|
7
|
-
gem.description = %q{淘宝开放平台ruby版,支持Rails3}
|
7
|
+
gem.description = %q{淘宝开放平台ruby版,支持Rails3~}
|
8
8
|
gem.summary = %q{Open Taobao API for ruby}
|
9
9
|
gem.homepage = "http://github.com/wongyouth/open_taobao"
|
10
10
|
|
data/spec/open_taobao_spec.rb
CHANGED
@@ -5,45 +5,42 @@ require 'tempfile'
|
|
5
5
|
describe OpenTaobao do
|
6
6
|
ENDPOINT = "http://gw.api.tbsandbox.com/router/rest"
|
7
7
|
|
8
|
-
before(:each) do
|
9
|
-
@now = Time.parse('2012-10-29 23:30')
|
10
|
-
Time.stub(:now) { @now }
|
11
|
-
end
|
12
|
-
|
13
8
|
let(:config_file) do
|
14
9
|
file = Tempfile.new 'taobao.yml'
|
15
10
|
File.open file.path, 'w+' do |f|
|
16
11
|
f.write <<-EOS.gsub(/^ +/, '')
|
17
12
|
app_key: 'test'
|
18
13
|
secret_key: 'test'
|
19
|
-
pid: 'test'
|
20
14
|
endpoint: '#{ENDPOINT}'
|
21
15
|
EOS
|
22
16
|
end
|
23
17
|
file
|
24
18
|
end
|
25
19
|
|
20
|
+
before(:each) do
|
21
|
+
@now = Time.parse('2012-10-29 23:30')
|
22
|
+
Time.stub(:now) { @now }
|
23
|
+
OpenTaobao.load(config_file.path)
|
24
|
+
end
|
25
|
+
|
26
26
|
# we only need to load config file here once for all test
|
27
27
|
it "should load config file" do
|
28
|
-
OpenTaobao.load(config_file.path)
|
29
28
|
OpenTaobao.config.should == {
|
30
29
|
'app_key' => 'test',
|
31
30
|
'secret_key' => 'test',
|
32
|
-
'pid' => 'test',
|
33
31
|
'endpoint' => "http://gw.api.tbsandbox.com/router/rest"
|
34
32
|
}
|
35
33
|
end
|
36
34
|
|
37
35
|
it "should raise exception if config yaml does not include correct keys" do
|
38
36
|
OpenTaobao.config = {
|
39
|
-
'app_key' => 'test',
|
40
37
|
'secret_key' => 'test',
|
41
38
|
'endpoint' => "http://gw.api.tbsandbox.com/router/rest"
|
42
39
|
}
|
43
40
|
|
44
41
|
expect {
|
45
42
|
OpenTaobao.check_config
|
46
|
-
}.to raise_error('[
|
43
|
+
}.to raise_error('[app_key] not included in your yaml file.')
|
47
44
|
end
|
48
45
|
|
49
46
|
it "should merge with default options" do
|
metadata
CHANGED
@@ -1,113 +1,100 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open_taobao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- wongyouth
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: faraday
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: autotest
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
|
-
description: 淘宝开放平台ruby版,支持Rails3
|
97
|
+
description: 淘宝开放平台ruby版,支持Rails3~
|
111
98
|
email:
|
112
99
|
- wongyouth@gmail.com
|
113
100
|
executables: []
|
@@ -117,6 +104,7 @@ files:
|
|
117
104
|
- .gitignore
|
118
105
|
- .rspec
|
119
106
|
- .travis.yml
|
107
|
+
- CHNAGELOG.md
|
120
108
|
- Gemfile
|
121
109
|
- LICENSE
|
122
110
|
- README.md
|
@@ -132,33 +120,26 @@ files:
|
|
132
120
|
- spec/spec_helper.rb
|
133
121
|
homepage: http://github.com/wongyouth/open_taobao
|
134
122
|
licenses: []
|
123
|
+
metadata: {}
|
135
124
|
post_install_message:
|
136
125
|
rdoc_options: []
|
137
126
|
require_paths:
|
138
127
|
- lib
|
139
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
none: false
|
141
129
|
requirements:
|
142
|
-
- -
|
130
|
+
- - '>='
|
143
131
|
- !ruby/object:Gem::Version
|
144
132
|
version: '0'
|
145
|
-
segments:
|
146
|
-
- 0
|
147
|
-
hash: -1746376069650641682
|
148
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
134
|
requirements:
|
151
|
-
- -
|
135
|
+
- - '>='
|
152
136
|
- !ruby/object:Gem::Version
|
153
137
|
version: '0'
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
hash: -1746376069650641682
|
157
138
|
requirements: []
|
158
139
|
rubyforge_project:
|
159
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.0
|
160
141
|
signing_key:
|
161
|
-
specification_version:
|
142
|
+
specification_version: 4
|
162
143
|
summary: Open Taobao API for ruby
|
163
144
|
test_files:
|
164
145
|
- spec/open_taobao_spec.rb
|