kuaidi100_rails 0.1.2 → 0.1.3
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/lib/kuaidi100_rails/version.rb +1 -1
- data/lib/kuaidi100_rails.rb +33 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f15f0948eed71f6b753b5e89416605fa56802078
|
4
|
+
data.tar.gz: 7c7dca4e0d5e7ed8c2aacac5aa3138d031a64065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef6fc5589a22fe16db776751b12b8de2f8aba22abc5393c057758fa35c503e9bf975aa5d4c08f400416ee8968a5a688fa7a9155f020711cc5ee03cbd60bce6a9
|
7
|
+
data.tar.gz: 03eff8f3fe74ac8ee7c26444caa4728113671e57d4b4aa0dab45e63dbbd4f1ca1221a5295062a4324f8a7023bd34b46acdfd584924d78bd5f07e2af03e0f81b3
|
data/lib/kuaidi100_rails.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require "kuaidi100_rails/version"
|
2
3
|
require 'open-uri'
|
3
4
|
require 'net/http'
|
@@ -7,6 +8,26 @@ require 'faraday'
|
|
7
8
|
module Kuaidi100Rails
|
8
9
|
API_URL = 'http://api.kuaidi100.com/api'
|
9
10
|
SUBSCRIBE_URL = 'http://www.kuaidi100.com/poll'
|
11
|
+
EXPRESS_KEYWORDS = {yuantong: '圆通',
|
12
|
+
shunfeng: '顺丰',
|
13
|
+
bjemstckj: '北京EMS',
|
14
|
+
ems: 'ems',
|
15
|
+
shentong: '申通',
|
16
|
+
yunda: '韵达',
|
17
|
+
zhongtong: '中通',
|
18
|
+
huitongkuaidi: '汇通',
|
19
|
+
debangwuliu: '德邦',
|
20
|
+
zhaijisong: '宅急送',
|
21
|
+
tiantian: '天天',
|
22
|
+
guotongkuaidi: '国通',
|
23
|
+
zengyisudi: '增益',
|
24
|
+
suer: '速尔',
|
25
|
+
ztky: '中铁物流',
|
26
|
+
zhongtiewuliu: '中铁快运',
|
27
|
+
ganzhongnengda: '能达',
|
28
|
+
youshuwuliu: '优速',
|
29
|
+
quanfengkuaidi: '全峰',
|
30
|
+
jd: '京东'}
|
10
31
|
|
11
32
|
class << self
|
12
33
|
attr_accessor :API_KEY
|
@@ -30,6 +51,11 @@ module Kuaidi100Rails
|
|
30
51
|
end
|
31
52
|
end
|
32
53
|
|
54
|
+
#cn_name to en_code
|
55
|
+
def company_code(cn_name)
|
56
|
+
EXPRESS_KEYWORDS.select { |k, v| cn_name.to_s.downcase.include?(v.to_s.downcase) }.keys[0].to_s
|
57
|
+
end
|
58
|
+
|
33
59
|
#subscribe express
|
34
60
|
#===Parameters==
|
35
61
|
#+com+ company code
|
@@ -54,9 +80,13 @@ module Kuaidi100Rails
|
|
54
80
|
p body
|
55
81
|
|
56
82
|
response = Faraday.new(:url => SUBSCRIBE_URL).post do |req|
|
57
|
-
req.headers['Content-Type'] = 'application/
|
58
|
-
req.params[:schema] = 'json'
|
59
|
-
req.params[:param] = body.to_json
|
83
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
84
|
+
# req.params[:schema] = 'json'
|
85
|
+
# req.params[:param] = body.to_json
|
86
|
+
req.body={
|
87
|
+
schema: 'json',
|
88
|
+
param: body.to_json
|
89
|
+
}
|
60
90
|
end
|
61
91
|
|
62
92
|
hash = SHash.new(JSON.parse(response.body))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuaidi100_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|