guanyi-erp 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/GuanyiErp.gemspec +38 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/guanyi_erp.rb +100 -0
- data/lib/guanyi_erp/config.rb +49 -0
- data/lib/guanyi_erp/request.rb +35 -0
- data/lib/guanyi_erp/version.rb +3 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 131bafce593f3b0976b57498cadb8e4584600856
|
4
|
+
data.tar.gz: 3456cef7232b206978aa51090cc4c6bba565dde6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0332e79006486b46bc8de3879af7b96473f0b1fb4eeec1bd5bb8f8703e603db09a48d410b3da71408c1766cc72a3a7b40727feec4f279e9dec8390de7e08a279
|
7
|
+
data.tar.gz: a3aa1a09a72ebef2f27f69a3a8cadf361a298f7a7ea054f1865b131c85487d57243153ff355ea9bb9c3114ae233da34d8b1636d61eb647dd2749c2c6abf4094c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at xi.liu@abcomb.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/GuanyiErp.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'guanyi_erp/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "guanyi-erp"
|
8
|
+
spec.version = GuanyiErp::VERSION
|
9
|
+
spec.authors = ["liuxi"]
|
10
|
+
spec.email = ["15201280641@qq.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{管易ERP}
|
13
|
+
spec.description = %q{管易ERP api ruby gem}
|
14
|
+
spec.homepage = "https://github.com/mumaoxi/GuanyiErp"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
36
|
+
spec.add_development_dependency "faraday", "~> 0.9"
|
37
|
+
spec.add_development_dependency "rails","~> 3.2"
|
38
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 木卯溪
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 liuxi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# GuanyiErp
|
2
|
+
管易erp api
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'guanyi-erp'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install guanyi-erp
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### config/guanyi_erp.yml
|
23
|
+
```yml
|
24
|
+
development:
|
25
|
+
app_key: testkey
|
26
|
+
secret: mySecret
|
27
|
+
session_key: mySessionKey
|
28
|
+
api_base_path: http://demo.guanyierp.com/erpapi/rest/erp_open
|
29
|
+
production:
|
30
|
+
app_key: a
|
31
|
+
secret: a
|
32
|
+
session_key: b
|
33
|
+
api_base_path: c
|
34
|
+
test:
|
35
|
+
app_key: a
|
36
|
+
secret: a
|
37
|
+
session_key: b
|
38
|
+
api_base_path: c
|
39
|
+
```
|
40
|
+
|
41
|
+
###库存查询(gy.erp.stock.get)
|
42
|
+
```ruby
|
43
|
+
GuanyiErp.api_erp_stock_get({item_code: 'mx1115', sku_code: 'mx115-BK'})
|
44
|
+
```
|
45
|
+
|
46
|
+
###订单新增(gy.erp.trade.add)
|
47
|
+
```ruby
|
48
|
+
GuanyiErp.api_erp_trade_add(
|
49
|
+
{platform_code: '1', #平台订单号(必填防止重复导单)
|
50
|
+
shop_code: 'UD', #ERP店铺编码
|
51
|
+
express_code: 'EMS', #物流编码
|
52
|
+
warehouse_code: 'C001c', #仓库编码
|
53
|
+
cod: false, #是否货到付款
|
54
|
+
vip_code: '001',
|
55
|
+
deal_datetime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
56
|
+
pay_datetime: Time.now.strftime('%Y-%m-%d %H:%M:%S'), #付款时间
|
57
|
+
receiver_name: '木卯',
|
58
|
+
receiver_address: '测试地址',
|
59
|
+
receiver_mobile: '15201280641',
|
60
|
+
receiver_phone: '15201280641',
|
61
|
+
receiver_province: '河北省',
|
62
|
+
receiver_city: '石家庄市',
|
63
|
+
receiver_district: '桥东区',
|
64
|
+
post_fee: 12, #物流费
|
65
|
+
discount_fee: 5, #让利金额
|
66
|
+
invoices: [],
|
67
|
+
# payments: [{
|
68
|
+
# pay_type_code: '1012014021233754645',
|
69
|
+
# paytime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
|
70
|
+
# payment: 100.1,
|
71
|
+
# account: '',
|
72
|
+
# pay_code: ''
|
73
|
+
# }],
|
74
|
+
details: [
|
75
|
+
{
|
76
|
+
item_code: 'mx1115',
|
77
|
+
sku_code: 'mx115-BK',
|
78
|
+
price: '98',
|
79
|
+
qty: 2
|
80
|
+
}
|
81
|
+
] #商品信息
|
82
|
+
})
|
83
|
+
```
|
84
|
+
###订单查询(gy.erp.trade.get)
|
85
|
+
```ruby
|
86
|
+
GuanyiErp.api_erp_trade_get({platform_code: '1',receiver_mobile:'15201280641'})
|
87
|
+
```
|
88
|
+
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/GuanyiErp. 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.
|
93
|
+
|
94
|
+
|
95
|
+
## License
|
96
|
+
|
97
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
98
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "guanyi_erp"
|
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
|
data/bin/setup
ADDED
data/lib/guanyi_erp.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "guanyi_erp/version"
|
3
|
+
require 'yaml'
|
4
|
+
require 'guanyi_erp/config'
|
5
|
+
require 'guanyi_erp/request'
|
6
|
+
require 'faraday'
|
7
|
+
require 'rails'
|
8
|
+
require 'digest'
|
9
|
+
|
10
|
+
module GuanyiErp
|
11
|
+
|
12
|
+
API_GY_ERP_STOCK_GET = 'gy.erp.stock.get' #库存查询
|
13
|
+
API_GY_ERP_TRADE_ADD = 'gy.erp.trade.add' #订单新增
|
14
|
+
API_GY_ERP_TRADE_GET = 'gy.erp.trade.get' #订单查询
|
15
|
+
|
16
|
+
|
17
|
+
module_function
|
18
|
+
|
19
|
+
#库存查询(gy.erp.stock.get)
|
20
|
+
#+page_no+ Number 非必填 页码 1
|
21
|
+
#+page_size+ Number 非必填 每页大小 10
|
22
|
+
#+item_code+ String 非必填 商品代码
|
23
|
+
#+sku_code+ String 非必填 规格代码
|
24
|
+
#+warehouse_code+ String 非必填 仓库code
|
25
|
+
#参考文档 http://gop.guanyierp.com/interface/gy.erp.stock.get.htm
|
26
|
+
def api_erp_stock_get(params={})
|
27
|
+
GuanyiErp::Request.post({method: API_GY_ERP_STOCK_GET}.merge(params))
|
28
|
+
end
|
29
|
+
|
30
|
+
#订单新增(gy.erp.trade.add)
|
31
|
+
# +order_type_code+ String 订单类型code
|
32
|
+
# +refund+ Number 0-非退款 ,1--退款(退款中); 退款状态
|
33
|
+
# +cod+ Boolean 货到付款
|
34
|
+
# +order_settlement_code+ String 结算方式code
|
35
|
+
# +platform_code+ String 平台单号(必填:防止重复导入erp,这里填写系统的订单号)
|
36
|
+
# +shop_code+ String 是 店铺code
|
37
|
+
# +express_code+ String 是 物流公司code
|
38
|
+
# +warehouse_code+ String 是 仓库code
|
39
|
+
# +vip_code+ String 是 会员code
|
40
|
+
# +vip_name+ String 会员名称
|
41
|
+
# +receiver_name+ String 收货人
|
42
|
+
# +receiver_address+ String 收货地址
|
43
|
+
# +receiver_zip+ String 收货邮编
|
44
|
+
# +receiver_mobile+ String 手机和电话必填一项 收货人手机
|
45
|
+
# +receiver_phone+ String 手机和电话必填一项 收货人电话
|
46
|
+
# +receiver_province+ String 收货人省份
|
47
|
+
# +receiver_city+ String 收货人城市
|
48
|
+
# +receiver_district+ String 收货人区域
|
49
|
+
# +tag_code+ String 标记code
|
50
|
+
# +deal_datetime+ String 是 2015-03-17 15:03:45 拍单时间
|
51
|
+
# +pay_datetime+ String 2015-03-17 15:03:45 付款时间
|
52
|
+
# +business_man_code+ String 业务员code
|
53
|
+
# +post_fee+ Price 0.0 物流费用
|
54
|
+
# +cod_fee+ Price 到付服务费
|
55
|
+
# +discount_fee+ Price 让利金额
|
56
|
+
# +plan_delivery_date+ Date 预计发货日期
|
57
|
+
# +buyer_memo+ String 买家留言
|
58
|
+
# +seller_memo+ String 卖家备注
|
59
|
+
# +seller_memo+_late String 二次备注
|
60
|
+
# +vipIdCard+ String 身份证号
|
61
|
+
# +vipRealName+ String 真实姓名
|
62
|
+
# +vipEmail+ String 电子邮箱
|
63
|
+
# +invoices+ List 是 发票信息数组
|
64
|
+
# +details+ List 商品信息数组
|
65
|
+
# +payments+ List 是 支付信息数组
|
66
|
+
#参考文档 http://gop.guanyierp.com/interface/gy.erp.trade.add.htm
|
67
|
+
def api_erp_trade_add(params={})
|
68
|
+
GuanyiErp::Request.post({method: API_GY_ERP_TRADE_ADD}.merge(params))
|
69
|
+
end
|
70
|
+
|
71
|
+
#订单查询(gy.erp.trade.get)
|
72
|
+
# +page_no+ Number 1 页码
|
73
|
+
# +page_size+ Number 10 每页大小
|
74
|
+
# +start_date+ DateTime 开始时间
|
75
|
+
# +end_date+ DateTime 结束时间
|
76
|
+
# +date_type+ Number 默认为0, 0、创建时间 1、拍单时间 2、付款时间 时间类型
|
77
|
+
# +order_state+ Number 默认为0, 0、全部 1、未审核 2、已审核 订单类型
|
78
|
+
# +warehouse_code+ String 仓库代码
|
79
|
+
# +shop_code+ String 店铺代码
|
80
|
+
# +vip_name+ String 会员名称
|
81
|
+
# +platform_code+ String 平台单号
|
82
|
+
# +receiver_mobile+ String 收件手机
|
83
|
+
def api_erp_trade_get(params={})
|
84
|
+
GuanyiErp::Request.post({method: API_GY_ERP_TRADE_GET}.merge(params))
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
if File.exists?('config/guanyi_erp.yml')
|
90
|
+
erp = YAML.load_file('config/guanyi_erp.yml')[ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"]
|
91
|
+
GuanyiErp::Config.app_key = erp["app_key"]
|
92
|
+
GuanyiErp::Config.session_key = erp["session_key"]
|
93
|
+
GuanyiErp::Config.secret = erp["secret"]
|
94
|
+
GuanyiErp::Config.api_base_path = erp["api_base_path"]
|
95
|
+
else
|
96
|
+
puts "\n\n=========================================================\n\n" +
|
97
|
+
" You haven't made a config/guanyi_erp.yml file.\n\n You should. \n\n The weibo gem will work much better if you do\n\n" +
|
98
|
+
" Please set Weibo::Config.api_key and \n Weibo::Config.api_secret\n somewhere in your initialization process\n\n" +
|
99
|
+
"=========================================================\n\n"
|
100
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module GuanyiErp
|
2
|
+
module Config
|
3
|
+
|
4
|
+
def self.app_key=(val)
|
5
|
+
@@app_key = val
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.app_key
|
9
|
+
@@app_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.secret=(val)
|
13
|
+
@@secret = val
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.secret
|
17
|
+
@@secret
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.session_key=(val)
|
21
|
+
@@session_key = val
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.session_key
|
25
|
+
@@session_key
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.api_base_path=(val)
|
29
|
+
@@api_base_path = val
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.api_bash_path
|
33
|
+
@@api_base_path
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.api_host
|
37
|
+
api_bash_path.scan(/(https.*.com)(\/.*)/) { |host, url|
|
38
|
+
return host
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.api_path
|
43
|
+
api_bash_path.scan(/(https.*.com)(\/.*)/) { |host, url|
|
44
|
+
return url
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module GuanyiErp
|
2
|
+
class Request
|
3
|
+
|
4
|
+
def self.post(params)
|
5
|
+
|
6
|
+
response = Faraday.new(:url => GuanyiErp::Config.api_host).post do |req|
|
7
|
+
req.url GuanyiErp::Config.api_path
|
8
|
+
req.headers['Content-Type'] = 'application/json'
|
9
|
+
body_hash = {
|
10
|
+
appkey: GuanyiErp::Config.app_key,
|
11
|
+
sessionkey: GuanyiErp::Config.session_key
|
12
|
+
}.merge(params)
|
13
|
+
body_hash = body_hash.merge({sign: sign(body_hash)})
|
14
|
+
puts body_hash.to_json
|
15
|
+
req.body= body_hash.to_json
|
16
|
+
end
|
17
|
+
body = parse_json(response.body)
|
18
|
+
return nil unless body
|
19
|
+
body
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.parse_json(json_data_str)
|
24
|
+
begin
|
25
|
+
return JSON.parse(json_data_str)
|
26
|
+
rescue
|
27
|
+
end
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.sign(body_hash)
|
32
|
+
Digest::MD5.hexdigest("#{GuanyiErp::Config.secret}#{body_hash.to_json}#{GuanyiErp::Config.secret}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guanyi-erp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- liuxi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-19 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.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
83
|
+
description: "管易ERP api ruby gem"
|
84
|
+
email:
|
85
|
+
- 15201280641@qq.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- GuanyiErp.gemspec
|
95
|
+
- LICENSE
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/guanyi_erp.rb
|
102
|
+
- lib/guanyi_erp/config.rb
|
103
|
+
- lib/guanyi_erp/request.rb
|
104
|
+
- lib/guanyi_erp/version.rb
|
105
|
+
homepage: https://github.com/mumaoxi/GuanyiErp
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata:
|
109
|
+
allowed_push_host: https://rubygems.org
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.8
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: "管易ERP"
|
130
|
+
test_files: []
|