wdt 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae2a64d22a6777fb3a2aa090d949ff458ae33b5d
4
+ data.tar.gz: 0c114898fece550bf8b2adc3f5c3e5b86e18be8a
5
+ SHA512:
6
+ metadata.gz: eff10992c51b54d7239b62ff4b98762b2b0a6651eb533c2d8c7bfb0788f8af49b7fa57d4b3c545ccb0179e43e26154ac2a8517ef8ff51c72efe21ffe4d7d687f
7
+ data.tar.gz: 66fe8263f1bbdc5c429310266ef6c1205973fcc04da1d8cbf5340d93cc664b96b0bc1a0d52cced6eff37fd23040e3ca9faf25a4b14be01df0867a533fdd6a551
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.tmproj
5
+ *~
6
+ .\#*
7
+ .bundle
8
+ .config
9
+ .yardoc
10
+ Gemfile.lock
11
+ InstalledFiles
12
+ \#*
13
+ _yardoc
14
+ coverage
15
+ doc/
16
+ lib/bundler/man
17
+ pkg
18
+ rdoc
19
+ spec/reports
20
+ test/tmp
21
+ test/version_tmp
22
+ tmp
23
+ tmtags
24
+ .test_queue_stats
25
+ .DS_Store
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ nguage: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+
7
+ script:
8
+ - bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wdt.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 xiaoronglv
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # 旺店通 API 封装
2
+
3
+ ![旺店通logo](http://7vzu2r.com1.z0.glb.clouddn.com/wdt.png)
4
+
5
+ 旺店通ERP系统覆盖线上电商以及线下实体店,涵盖订单管理,货品管理,仓库管理,采购管理,售后管理,会员管理等主要功能。此 Gem 主要封装了以下 API:
6
+
7
+ * 原始单推送(已完成)
8
+ * 待同步物流查询 (todo)
9
+ * 物流同步状态回写 (todo)
10
+ * 订单查询 (todo)
11
+ * 外部库存同步 (todo)
12
+ * 退换单查询 (todo)
13
+
14
+ ## Quick Start
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'wdt'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install wdt
29
+
30
+ ## Usage
31
+
32
+ [API methods][] are available as module methods (consuming module-level
33
+ configuration) or as client instance methods.
34
+
35
+ ```ruby
36
+ # Provide authentication credentials
37
+ Wdt.configure do |config|
38
+ config.sid = "9i7fz2xp1s7x"
39
+ config.appkey = "942w2atpk218"
40
+ config.appsecret = "sfx4ne1mvy1k"
41
+ config.endpoint = "http://v2.wangdian.com/"
42
+ config.shop_no = "123456"
43
+ end
44
+
45
+ # 推送订单至旺店通 erp
46
+
47
+
48
+ params = {
49
+ "tid" => "test00051",
50
+ "trade_status" => 30,
51
+ "pay_status" => 2,
52
+ "delivery_term" => 1,
53
+ "trade_time" => "2015-01-01 10:00:00",
54
+ "pay_time" => "",
55
+ "buyer_nick" => "mytest",
56
+ "buyer_email" => "",
57
+ "pay_id" => "1212121",
58
+ "pay_account" => "pay@pay.com",
59
+ "receiver_name" => "测试者",
60
+ "receiver_province" => "北京",
61
+ "receiver_city" => "北京市",
62
+ "receiver_district" => "昌平区",
63
+ "receiver_address" => "天通苑",
64
+ "receiver_mobile" => "15345543211",
65
+ "receiver_telno" => "",
66
+ "receiver_zip" => "",
67
+ "logistics_type" => "-1",
68
+ "invoice_type" => 1,
69
+ "invoice_title" => "测试抬头",
70
+ "buyer_message" => "买家留言",
71
+ "seller_memo" => "卖家备注",
72
+ "seller_flag" => "0",
73
+ "post_amount" => "10",
74
+ "cod_amount" => 0,
75
+ "ext_cod_fee" => 0,
76
+ "paid" => 20,
77
+ "order_list" => [
78
+ {
79
+ "oid" => "test0005-011",
80
+ "num" => 2,
81
+ "price" => 10,
82
+ "status" => 30,
83
+ "refund_status" => 0,
84
+ "goods_id" => "1001",
85
+ "spec_id" => "1001",
86
+ "goods_no" => "test001",
87
+ "spec_no" => "test001-01",
88
+ "goods_name" => "测试用例1",
89
+ "spec_name" => "规格01",
90
+ "adjust_amount" => 0,
91
+ "discount" => 10,
92
+ "share_discount" => 0,
93
+ "cid" => ""
94
+ }
95
+ ]
96
+ }
97
+
98
+ Wdt.push_trade(params)
99
+
100
+ ```
101
+ or
102
+
103
+ ```ruby
104
+ # 创建一个 client 对象
105
+ client = Wdt::Client.new(
106
+ sid: "9i7fz2xp1s7x"
107
+ appkey: "942w2atpk218"
108
+ appsecret: "sfx4ne1mvy1k"
109
+ endpoint: "http://www.xxxx.com"
110
+ shop_no: "123456"
111
+ )
112
+
113
+ # 推送订单至旺店通 erp
114
+ client.push_trade(params)
115
+ ```
116
+
117
+ ## Contributing
118
+
119
+ 1. Fork it ( https://github.com/xiaoronglv/wdt/fork )
120
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
121
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
122
+ 4. Push to the branch (`git push origin my-new-feature`)
123
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+
9
+ task :default => :test
data/bin/.keep ADDED
File without changes
data/changelog.md ADDED
File without changes
data/lib/wdt.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'wdt/error'
2
+ require 'wdt/version'
3
+ require 'wdt/response'
4
+ require 'wdt/authentication'
5
+ require 'wdt/configuration'
6
+ require 'wdt/client'
7
+
8
+
9
+ module Wdt
10
+ extend Wdt::Configuration
11
+
12
+ # Alias for Wdt::Client.new
13
+ #
14
+ # @return [Wdt::Client]
15
+ def self.client(options={})
16
+ Wdt::Client.new(options)
17
+ end
18
+
19
+ # Delegate to Wdt::Client
20
+ def self.method_missing(method, *args, &block)
21
+ return super unless client.respond_to?(method)
22
+ client.send(method, *args, &block)
23
+ end
24
+
25
+ # Delegate to Wdt::Client
26
+ def self.respond_to?(method, include_all=false)
27
+ return client.respond_to?(method, include_all) || super
28
+ end
29
+ end
@@ -0,0 +1,83 @@
1
+ require 'digest'
2
+ require 'json'
3
+
4
+ module Wdt
5
+ module Authentication
6
+ # 对请求的参数进行签名
7
+
8
+ SEPARATOR1 = '-'
9
+ SEPARATOR2 = ':'
10
+ SEPARATOR3 = ';'
11
+
12
+ #
13
+ def sign(params)
14
+ # 添加系统级参数
15
+ params = params.merge(
16
+ appkey: @appkey,
17
+ sid: @sid,
18
+ timestamp: Time.now.to_i
19
+ )
20
+
21
+ # 将 hash 的 key 全部转化为 string
22
+ params = stringify_keys(params)
23
+
24
+ # 去掉参数中的 sign 参数
25
+ params.delete("sign")
26
+
27
+ # 添加参数签名
28
+ signature = get_signature(params)
29
+
30
+ params.merge!("sign" => signature)
31
+ end
32
+
33
+ def get_signature(params)
34
+ data = ""
35
+ params.sort.each do |key, value|
36
+ key = key.to_s
37
+ value = value.to_s
38
+
39
+ if data.size > 0
40
+ data << SEPARATOR3
41
+ end
42
+
43
+ data << len_foo(key, 2)
44
+ data << SEPARATOR1
45
+ data << key
46
+ data << SEPARATOR2
47
+ data << len_foo(value, 4)
48
+ data << SEPARATOR1
49
+ data << value
50
+ end
51
+
52
+ Digest::MD5.hexdigest("#{data}#{appsecret}")
53
+ end
54
+
55
+ # 把 hash 的 key 从 symbol 转化为 string
56
+ # params {:a=>1, :b=>{:c=>2}}
57
+ # return {"a"=>1, "b"=>{"c"=>2}}
58
+ def stringify_keys(obj)
59
+ return obj.reduce({}) do |memo, (k, v)|
60
+ memo.tap { |m| m[k.to_s] = stringify_keys(v) }
61
+ end if obj.is_a? Hash
62
+
63
+ return obj.reduce([]) do |memo, v|
64
+ memo << stringify_keys(v); memo
65
+ end if obj.is_a? Array
66
+
67
+ obj
68
+ end
69
+
70
+ private
71
+
72
+ # 返回 key or value 长度占位符
73
+ # fix_len 占位固定长度
74
+ def len_foo(str, fix_len)
75
+ ret = str.size.to_s
76
+ if ret.size >= fix_len
77
+ ret
78
+ else
79
+ "#{'0' * (fix_len - ret.size)}#{ret}"
80
+ end
81
+ end
82
+ end
83
+ end
data/lib/wdt/client.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'rest_client'
2
+ require 'wdt/client/shipments'
3
+ require 'wdt/client/stocks'
4
+ require 'wdt/client/trades'
5
+
6
+ module Wdt
7
+ # @private
8
+ class Client
9
+ include Wdt::Authentication
10
+ include Wdt::Client::Trades
11
+ include Wdt::Client::Shipments
12
+ include Wdt::Client::Stocks
13
+
14
+ attr_accessor *Configuration::VALID_OPTIONS_KEYS
15
+
16
+ # Creates a new API
17
+ def initialize(options={})
18
+ options = Wdt.options.merge(options)
19
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
20
+ send("#{key}=", options[key])
21
+ end
22
+ end
23
+
24
+ def config
25
+ conf = {}
26
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
27
+ conf[key] = send key
28
+ end
29
+ conf
30
+ end
31
+
32
+ # Make a HTTP GET request
33
+ def get(url, options = {})
34
+ request :get, url, options
35
+ end
36
+
37
+ # Make a HTTP POST request
38
+ def post(url, options = {})
39
+ request :post, url, options
40
+ end
41
+
42
+ # Make a HTTP delete request
43
+ def delete(url, options = {})
44
+ request :delete, url, options
45
+ end
46
+
47
+ # Make a HTTP PUT request
48
+ def put(url, options = {})
49
+ request :put, url, options
50
+ end
51
+
52
+ # Make a HTTP HEAD request
53
+ def head(url, options = {})
54
+ request :head, url, options
55
+ end
56
+
57
+ # Make a HTTP PATCH request
58
+ def patch(url, options = {})
59
+ request :patch, url, options
60
+ end
61
+
62
+ # Executes the request, checking if it was successfull.
63
+ def request(method, path, payload)
64
+ payload = sign(payload)
65
+ response = RestClient::Request.execute(
66
+ :method => method,
67
+ :url => endpoint + path,
68
+ :payload => payload,
69
+ :timeout => 10,
70
+ :open_timeout => 10
71
+ )
72
+
73
+ response_hash = JSON.parse response
74
+ Response.new(response_hash)
75
+ end
76
+ end
77
+ end
78
+
@@ -0,0 +1,29 @@
1
+ module Wdt
2
+ class Client
3
+ # 物流接口
4
+ module Shipments
5
+
6
+ # 待同步物流查询
7
+ #
8
+ # @param limit [Integer] 最多返回几条。最大数值为100
9
+ def query_shipments(limit, options={})
10
+ limit = 100 if limit > 100
11
+ response = post "/openapi2/logistics_sync_query.php", options.merge(limit: limit)
12
+ respone
13
+ end
14
+
15
+
16
+ # 物流同步状态回写
17
+ #
18
+ # @param rec_ic, [Integer] 回写的记录id
19
+ # @param status, [Integer] 回写状态 0-成功 1-失败
20
+ # @param message, [String] 相关描述信息,可在erp的物流同步界⾯面看到
21
+ def ack_shipments(rec_id, status, message)
22
+ options = options.merge( rec_id: rec_id.to_i, status: status.to_i, message: message.to_s)
23
+ response = post "/openapi2/logistics_sync_ack.php", options
24
+ response
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module Wdt
2
+ class Client
3
+ # 库存接口
4
+ module Stocks
5
+ # todo 同步库存
6
+ # todo 查询旺店通的库存
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,81 @@
1
+ module Wdt
2
+ class Client
3
+ # 订单推送 和 订单查询接口
4
+ module Trades
5
+
6
+ # 原始单推送接口
7
+ # 是一个订单的基本信息
8
+ #
9
+ # options example
10
+ # {
11
+ # "tid" => "test0005",
12
+ # "trade_status" => 30,
13
+ # "pay_status" => 2,
14
+ # "delivery_term" => 1,
15
+ # "trade_time" => "2015-01-01 10:00:00",
16
+ # "pay_time" => "",
17
+ # "buyer_nick" => "mytest",
18
+ # "buyer_email" => "",
19
+ # "pay_id" => "1212121",
20
+ # "pay_account" => "pay@pay.com",
21
+ # "receiver_name" => "测试者",
22
+ # "receiver_province" => "北京",
23
+ # "receiver_city" => "北京市",
24
+ # "receiver_district" => "昌平区",
25
+ # "receiver_address" => "天通苑",
26
+ # "receiver_mobile" => "15345543211",
27
+ # "receiver_telno" => "",
28
+ # "receiver_zip" => "",
29
+ # "logistics_type" => "-1",
30
+ # "invoice_type" => 1,
31
+ # "invoice_title" => "测试抬头",
32
+ # "buyer_message" => "买家留言",
33
+ # "seller_memo" => "卖家备注",
34
+ # "seller_flag" => "0",
35
+ # "post_amount" => "10",
36
+ # "cod_amount" => 0,
37
+ # "ext_cod_fee" => 0,
38
+ # "paid" => 20,
39
+ # "order_list" => [
40
+ # {
41
+ # "oid" => "test0005-01",
42
+ # "num" => 2,
43
+ # "price" => 10,
44
+ # "status" => 30,
45
+ # "refund_status" => 0,
46
+ # "goods_id" => "1001",
47
+ # "spec_id" => "1001",
48
+ # "goods_no" => "test001",
49
+ # "spec_no" => "test001-01",
50
+ # "goods_name" => "测试用例1",
51
+ # "spec_name" => "规格01",
52
+ # "adjust_amount" => 0,
53
+ # "discount" => 10,
54
+ # "share_discount" => 0,
55
+ # "cid" => ""
56
+ # }
57
+ # ]
58
+ # }
59
+ def push_trade(options={})
60
+ params = {
61
+ shop_no: shop_no,
62
+ trade_list: [ options ].to_json
63
+ }
64
+
65
+
66
+ # 请求参数的完整结构
67
+ #
68
+ # {
69
+ # shop_no: ""
70
+ # sid: ""
71
+ # appkey: ""
72
+ # timestamp: ""
73
+ # sign: ""
74
+ # trade_list: [trade_info, trade_info, trade_info].to_json
75
+ # }
76
+ response = post "/openapi2/trade_push.php", params
77
+ response
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,81 @@
1
+ module Wdt
2
+ # Defines constants and methods related to configuration
3
+ module Configuration
4
+ # An array of Wangdiantong keys in the options hash when configuring a {Wdt::API}
5
+ VALID_OPTIONS_KEYS = [
6
+ :sid,
7
+ :appkey,
8
+ :appsecret,
9
+ :endpoint,
10
+ :shop_no,
11
+ :format,
12
+ :user_agent
13
+ ].freeze
14
+
15
+
16
+ # By default, don't set a seller ID
17
+ DEFAULT_SID = nil
18
+
19
+ # By default, don't set an application key.
20
+ DEFAULT_APP_KEY = nil
21
+
22
+ # todo 补充旺店通默认的 endpoint
23
+ # The endpoint that will be used to connect if none is set
24
+ #
25
+ # @note There is no reason to use any other endpoint at this time
26
+ DEFAULT_ENDPOINT = 'https://api..com/v1/'.freeze
27
+
28
+
29
+ # The response format appended to the path and sent in the 'Accept' header if none is set
30
+ #
31
+ # @note JSON is the only available format at this time
32
+ DEFAULT_FORMAT = :json
33
+
34
+ # By defalut, don't set a shop number
35
+ DEFAULT_SHOP_NO = nil
36
+
37
+ # By default, don't set a app secret
38
+ DEFAULT_APP_SECRET = nil
39
+
40
+ # The user agent that will be sent to the API endpoint if none is set
41
+ DEFAULT_USER_AGENT = "Wang Dian Tong Ruby Gem #{Wdt::VERSION}".freeze
42
+
43
+
44
+ # An array of valid request/response formats
45
+ #
46
+ # @note Not all methods support the XML format.
47
+ VALID_FORMATS = [
48
+ :json].freeze
49
+
50
+ # @private
51
+ attr_accessor *VALID_OPTIONS_KEYS
52
+
53
+ # When this module is extended, set all configuration options to their default values
54
+ def self.extended(base)
55
+ base.reset
56
+ end
57
+
58
+ # Convenience method to allow configuration options to be set in a block
59
+ def configure
60
+ yield self
61
+ end
62
+
63
+ # Create a hash of options and their values
64
+ def options
65
+ VALID_OPTIONS_KEYS.inject({}) do |option, key|
66
+ option.merge!(key => send(key))
67
+ end
68
+ end
69
+
70
+ # Reset all configuration options to defaults
71
+ def reset
72
+ self.sid = DEFAULT_SID
73
+ self.appkey = DEFAULT_APP_KEY
74
+ self.appsecret = DEFAULT_APP_SECRET
75
+ self.endpoint = DEFAULT_ENDPOINT
76
+ self.shop_no = DEFAULT_SHOP_NO
77
+ self.format = DEFAULT_FORMAT
78
+ self.user_agent = DEFAULT_USER_AGENT
79
+ end
80
+ end
81
+ end
data/lib/wdt/error.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Wdt
2
+ # Custom error class for rescuing from all 'Wang dian tong' errors
3
+ class Error < StandardError; end
4
+
5
+ # Raised when 'Wang dian tong' returns the HTTP status code 400
6
+ class BadRequest < Error; end
7
+
8
+ # Raised when 'Wang dian tong' returns the HTTP status code 404
9
+ class NotFound < Error; end
10
+
11
+ # Raised when 'Wang dian tong' returns the HTTP status code 429
12
+ class TooManyRequests < Error; end
13
+
14
+ # Raised when 'Wang dian tong' returns the HTTP status code 500
15
+ class InternalServerError < Error; end
16
+
17
+ # Raised when 'Wang dian tong' returns the HTTP status code 502
18
+ class BadGateway < Error; end
19
+
20
+ # Raised when 'Wang dian tong' returns the HTTP status code 503
21
+ class ServiceUnavailable < Error; end
22
+
23
+ # Raised when 'Wang dian tong' returns the HTTP status code 504
24
+ class GatewayTimeout < Error; end
25
+
26
+ # Raised when a subscription payload hash is invalid
27
+ class InvalidSignature < Error; end
28
+
29
+ # Raised when 'Wang dian tong' returns the HTTP status code 429
30
+ class RateLimitExceeded < Error; end
31
+ end
@@ -0,0 +1,11 @@
1
+ module Wdt
2
+ class Response
3
+ attr_accessor :code, :message, :raw_data
4
+
5
+ def initialize(response_hash)
6
+ self.code = response_hash["code"]
7
+ self.message = response_hash["message"]
8
+ self.raw_data = response_hash
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Wdt
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require 'wdt'
@@ -0,0 +1,41 @@
1
+ require 'test_helper'
2
+
3
+ class AuthenticationTest < Test::Unit::TestCase
4
+ def setup
5
+ @client = Wdt::Client.new(
6
+ sid: "test",
7
+ appkey: "apptest",
8
+ appsecret: 12345
9
+ )
10
+ end
11
+
12
+ def test_get_signature
13
+ params = {
14
+ "sid" => "test",
15
+ "appkey" => "apptest",
16
+ "timestamp" => "1420084800",
17
+ "status" => 10,
18
+ "img_url" => 0,
19
+ "page_no" => 0,
20
+ "page_size" =>40,
21
+ "start_time" =>"2015-01-01 10:00:00",
22
+ "end_time" =>"2015-01-01 11:00:00"
23
+ }
24
+
25
+ signature = @client.send(:get_signature, params)
26
+
27
+ assert_equal "2b37a8699574550f6f9905fef0398cd1", signature
28
+
29
+ end
30
+
31
+ def test_len_foo
32
+ assert_equal "01", @client.send(:len_foo, "a", 2)
33
+ end
34
+
35
+ def test_stringify_keys
36
+ symbol_hash = {a: 1, b: 2, c: {age: 12}}
37
+ string_hash = {"a"=>1, "b"=>2, "c"=>{"age"=>12}}
38
+
39
+ assert_equal string_hash, @client.stringify_keys(symbol_hash)
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class ShipmentsTest < Test::Unit::TestCase
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class StocksTest < Test::Unit::TestCase
4
+
5
+ end
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class TradesTest < Test::Unit::TestCase
5
+
6
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class ClientTest < Test::Unit::TestCase
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class ConfigurationTest < Test::Unit::TestCase
4
+ def test_config
5
+ client = Wdt::Client.new
6
+
7
+ assert_equal nil, client.sid
8
+ assert_equal nil, client.appkey
9
+ assert_equal nil, client.appsecret
10
+ assert_equal nil, client.shop_no
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ class ResponseTest < Test::Unit::TestCase
4
+ def test_initialize
5
+ response = Wdt::Response.new(
6
+ "code" => 0,
7
+ "message" => "Isaiah is major Hebrew prophet",
8
+ "new_count" => 1,
9
+ "chg_count" => 0
10
+ )
11
+
12
+ assert_equal 0, response.code
13
+ assert_equal "Isaiah is major Hebrew prophet", response.message
14
+ assert_not_nil response.raw_data
15
+ end
16
+ end
data/wdt.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wdt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wdt"
8
+ spec.version = Wdt::VERSION
9
+ spec.authors = ["xiaoronglv"]
10
+ spec.email = ["xiaorong.ruby+rubygem@gmail.com"]
11
+ spec.summary = %q{ Wan dian tong erp API wrapper Gem}
12
+ spec.description = %q{Wan dian tong erp API Wapper Gem}
13
+ spec.homepage = "https://github.com/xiaoronglv/wdt"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency('rest-client', '>= 1.6')
25
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wdt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - xiaoronglv
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ description: Wan dian tong erp API Wapper Gem
56
+ email:
57
+ - xiaorong.ruby+rubygem@gmail.com
58
+ executables:
59
+ - ".keep"
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/.keep
70
+ - changelog.md
71
+ - lib/wdt.rb
72
+ - lib/wdt/authentication.rb
73
+ - lib/wdt/client.rb
74
+ - lib/wdt/client/shipments.rb
75
+ - lib/wdt/client/stocks.rb
76
+ - lib/wdt/client/trades.rb
77
+ - lib/wdt/configuration.rb
78
+ - lib/wdt/error.rb
79
+ - lib/wdt/response.rb
80
+ - lib/wdt/version.rb
81
+ - test/test_helper.rb
82
+ - test/wdt/authentication_test.rb
83
+ - test/wdt/client/shipments.rb
84
+ - test/wdt/client/stocks_test.rb
85
+ - test/wdt/client/trades_test.rb
86
+ - test/wdt/client_test.rb
87
+ - test/wdt/configuration_test.rb
88
+ - test/wdt/response_test.rb
89
+ - wdt.gemspec
90
+ homepage: https://github.com/xiaoronglv/wdt
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Wan dian tong erp API wrapper Gem
114
+ test_files:
115
+ - test/test_helper.rb
116
+ - test/wdt/authentication_test.rb
117
+ - test/wdt/client/shipments.rb
118
+ - test/wdt/client/stocks_test.rb
119
+ - test/wdt/client/trades_test.rb
120
+ - test/wdt/client_test.rb
121
+ - test/wdt/configuration_test.rb
122
+ - test/wdt/response_test.rb