fengqiao 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +26 -0
- data/README.md +66 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fengqiao.gemspec +44 -0
- data/lib/fengqiao.rb +14 -0
- data/lib/fengqiao/request.rb +29 -0
- data/lib/fengqiao/service.rb +57 -0
- data/lib/fengqiao/version.rb +3 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f79483c19e69ae79f2fb27ea91c028098a44ef2e9aedde67fa89730bfd66cce
|
4
|
+
data.tar.gz: e82499fe0c780a9f1fcac675cec2da9b34492eaf7e8644a10e9eaffb221627e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e60ae90f91fca13ed921d3d7b1e4a8da366ea9134e89aa370c7059af2e097b447742dc26847098000697ecb982064e175740924288082dfb19bd1b8a58fbefb9
|
7
|
+
data.tar.gz: 983cb420c3878da26eb4e714c4b9439fde4c09666f1564f426d4df69b99602cf4f506027a810680dd6af12f231e34bf5bec9866355c7a1d3e5332cce36fb7c49
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fengqiao (0.1.0)
|
5
|
+
faraday (~> 0.15)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
faraday (0.15.4)
|
11
|
+
multipart-post (>= 1.2, < 3)
|
12
|
+
minitest (5.11.3)
|
13
|
+
multipart-post (2.1.1)
|
14
|
+
rake (10.5.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.17)
|
21
|
+
fengqiao!
|
22
|
+
minitest (~> 5.0)
|
23
|
+
rake (~> 10.0)
|
24
|
+
|
25
|
+
BUNDLED WITH
|
26
|
+
1.17.2
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Fengqiao
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fengqiao`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'fengqiao'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fengqiao
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Config
|
26
|
+
|
27
|
+
```
|
28
|
+
Fengqiao.code = ''
|
29
|
+
Fengqiao.check_word = ''
|
30
|
+
Fengqiao.custid = ''
|
31
|
+
```
|
32
|
+
|
33
|
+
下订单接口
|
34
|
+
```
|
35
|
+
Fengqiao::Service.new.order(order_id, *args)
|
36
|
+
```
|
37
|
+
|
38
|
+
订单结果查询接口
|
39
|
+
```
|
40
|
+
Fengqiao::Service.new.query_search(order_id')
|
41
|
+
```
|
42
|
+
|
43
|
+
订单取消接口
|
44
|
+
```
|
45
|
+
Fengqiao::Service.new.order_cancel(order_id)
|
46
|
+
```
|
47
|
+
|
48
|
+
路由查询接口
|
49
|
+
```
|
50
|
+
Fengqiao::Service.new.route(order_id)
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fengqiao. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
63
|
+
|
64
|
+
## Code of Conduct
|
65
|
+
|
66
|
+
Everyone interacting in the Fengqiao project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fengqiao/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fengqiao"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/fengqiao.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "fengqiao/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fengqiao"
|
8
|
+
spec.version = Fengqiao::VERSION
|
9
|
+
spec.authors = ["menghuanwd"]
|
10
|
+
spec.email = ["651019063@qq.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{顺丰接口}
|
13
|
+
spec.description = %q{顺丰接口}
|
14
|
+
spec.homepage = "https://github.com/menghuanwd/fengqiao"
|
15
|
+
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
+
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
25
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
26
|
+
else
|
27
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_dependency "faraday", "~> 0.15"
|
40
|
+
|
41
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
42
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
43
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
44
|
+
end
|
data/lib/fengqiao.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "fengqiao/version"
|
2
|
+
require "fengqiao/request"
|
3
|
+
require "fengqiao/service"
|
4
|
+
|
5
|
+
module Fengqiao
|
6
|
+
class Error < StandardError; end
|
7
|
+
# Your code goes here...
|
8
|
+
|
9
|
+
SEND_GATEWAY = 'https://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService'
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :code, :check_word, :custid
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
require 'digest'
|
3
|
+
require 'base64'
|
4
|
+
require 'faraday'
|
5
|
+
|
6
|
+
module Fengqiao
|
7
|
+
class Request
|
8
|
+
def initialize(req_xml)
|
9
|
+
@req_xml = req_xml
|
10
|
+
end
|
11
|
+
|
12
|
+
def do
|
13
|
+
puts @req_xml
|
14
|
+
|
15
|
+
str = @req_xml + Fengqiao.check_word
|
16
|
+
|
17
|
+
verifyCode = Digest::MD5.base64digest(str)
|
18
|
+
|
19
|
+
data = { xml: @req_xml, verifyCode: verifyCode }
|
20
|
+
|
21
|
+
res = ::Faraday.new(url: SEND_GATEWAY).post do |req|
|
22
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
23
|
+
req.body = data
|
24
|
+
end
|
25
|
+
|
26
|
+
REXML::Document.new res.body
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Fengqiao
|
2
|
+
class Service
|
3
|
+
def order(orderid, express_type, pay_method, j_company, j_contact, j_tel, j_address, d_company, d_address, d_contact, d_tel)
|
4
|
+
doc = package('OrderService', 'Order', 'orderid' => orderid,
|
5
|
+
'express_type' => express_type,
|
6
|
+
'is_docall' => '1',
|
7
|
+
'j_company' => j_company,
|
8
|
+
'j_contact' => j_contact,
|
9
|
+
'j_tel' => j_tel,
|
10
|
+
'j_address' => j_address,
|
11
|
+
'd_company' => d_company,
|
12
|
+
'd_contact' => d_contact,
|
13
|
+
'd_tel' => d_tel,
|
14
|
+
'd_address' => d_address,
|
15
|
+
'pay_method' => pay_method,
|
16
|
+
'custid' => Fengqiao.custid
|
17
|
+
)
|
18
|
+
|
19
|
+
result = Request.new(doc.to_s).do
|
20
|
+
puts result
|
21
|
+
end
|
22
|
+
|
23
|
+
def query_search(orderid)
|
24
|
+
doc = package('OrderSearchService', 'OrderSearch', 'orderid' => orderid)
|
25
|
+
|
26
|
+
result = Request.new(doc.to_s).do
|
27
|
+
puts result
|
28
|
+
end
|
29
|
+
|
30
|
+
def order_confirm(orderid)
|
31
|
+
doc = package('OrderConfirmService', 'OrderConfirm', 'orderid' => orderid, 'dealtype' => '2')
|
32
|
+
|
33
|
+
result = Request.new(doc.to_s).do
|
34
|
+
puts result
|
35
|
+
end
|
36
|
+
|
37
|
+
def route(orderid)
|
38
|
+
doc = package('RouteService', 'RouteRequest', 'tracking_type' => '2', 'method_type' => '1', 'tracking_number' => orderid)
|
39
|
+
|
40
|
+
result = Request.new(doc.to_s).do
|
41
|
+
puts result
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def package(service, title, *args)
|
47
|
+
doc = REXML::Document.new
|
48
|
+
element = doc.add_element('Request', 'service' => service, 'lang' => 'zh-CN')
|
49
|
+
head = element.add_element('Head')
|
50
|
+
head.add_text Fengqiao.code
|
51
|
+
body = element.add_element('Body')
|
52
|
+
body.add_element(title, *args)
|
53
|
+
|
54
|
+
doc
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fengqiao
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- menghuanwd
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: 顺丰接口
|
70
|
+
email:
|
71
|
+
- 651019063@qq.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- fengqiao.gemspec
|
85
|
+
- lib/fengqiao.rb
|
86
|
+
- lib/fengqiao/request.rb
|
87
|
+
- lib/fengqiao/service.rb
|
88
|
+
- lib/fengqiao/version.rb
|
89
|
+
homepage: https://github.com/menghuanwd/fengqiao
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata:
|
93
|
+
allowed_push_host: https://rubygems.org
|
94
|
+
homepage_uri: https://github.com/menghuanwd/fengqiao
|
95
|
+
source_code_uri: https://github.com/menghuanwd/fengqiao
|
96
|
+
changelog_uri: https://github.com/menghuanwd/fengqiao
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.0.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: 顺丰接口
|
116
|
+
test_files: []
|