easy_wechat 0.1.3 → 0.1.9
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/Gemfile.lock +1 -1
- data/lib/easy_wechat/client.rb +46 -37
- data/lib/easy_wechat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e2af1c17c25a328079203cbd8c82bdf9e8f11365c35da169fd1b38fb7b855b5
|
4
|
+
data.tar.gz: 3a73e8b129d26b56c930515929ccaa002c19a1ab6cbbf343c21e7d76cc4669d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4da1cb7fd1e297d5620a0ac78a297242c40bd14c61d41195e3e02af231daf4ca07cb8eb29fc3c1ac6ef6bd90591af06334bc5ca80820561fda9899317e3bf6
|
7
|
+
data.tar.gz: 834409eecc816689a3a2813f07d63151ed675f809c03f2ee408b26998e94e1ade858d40d94a530be7aa2af230379b3f1a1092bd6d921dcf7d95e7555bd6b9d1c
|
data/Gemfile.lock
CHANGED
data/lib/easy_wechat/client.rb
CHANGED
@@ -11,6 +11,7 @@ module EasyWechat
|
|
11
11
|
ADD_NEWS_URL = "https://api.weixin.qq.com/cgi-bin/material/add_news"
|
12
12
|
GET_USER_SUMMARY_URL = "https://api.weixin.qq.com/datacube/getusersummary"
|
13
13
|
GET_USER_CUMULATE_URL = "https://api.weixin.qq.com/datacube/getusercumulate"
|
14
|
+
GET_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
|
14
15
|
|
15
16
|
def initialize
|
16
17
|
end
|
@@ -53,47 +54,55 @@ module EasyWechat
|
|
53
54
|
r
|
54
55
|
end
|
55
56
|
|
57
|
+
# 新增永久图文素材
|
58
|
+
# https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
|
59
|
+
def add_news(articles)
|
60
|
+
payload = { articles: articles }
|
61
|
+
|
62
|
+
resp = HTTPX.post(ADD_NEWS_URL, params: { access_token: access_token }, json: payload)
|
63
|
+
|
64
|
+
r = ::JSON.parse(resp.body, quirks_mode: true)
|
65
|
+
yield r if block_given?
|
66
|
+
r
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_ticket(type)
|
70
|
+
resp = HTTPX.get(GET_TICKET_URL, params: { access_token: access_token, type: type })
|
71
|
+
|
72
|
+
r = ::JSON.parse(resp.body, quirks_mode: true)
|
73
|
+
yield r if block_given?
|
74
|
+
r
|
75
|
+
end
|
76
|
+
|
77
|
+
# 获取永久素材的列表
|
78
|
+
# https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Get_materials_list.html
|
79
|
+
def batchget_material(type = "image", offset = 0, count = 20)
|
80
|
+
# TODO: 检查参数完整性
|
81
|
+
# TODO: 检查参数合法性
|
82
|
+
payload = { type: type, offset: offset, count: count }
|
83
|
+
|
84
|
+
resp = HTTPX.post(BATCHGET_MATERIAL_URL, params: { access_token: access_token }, json: payload)
|
85
|
+
|
86
|
+
r = ::JSON.parse(resp.body, quirks_mode: true)
|
87
|
+
yield r if block_given?
|
88
|
+
r
|
89
|
+
end
|
90
|
+
|
56
91
|
# 上传图文消息内的图片获取URL
|
57
92
|
# https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
|
58
93
|
def uploadimg(media)
|
94
|
+
# media path or Tempfile
|
59
95
|
# https://honeyryderchuck.gitlab.io/httpx/wiki/Multipart-Uploads.html#notes
|
60
|
-
file =
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
def batchget_material(type = "image", offset = 0, count = 20)
|
71
|
-
# TODO: 检查参数完整性
|
72
|
-
# TODO: 检查参数合法性
|
73
|
-
payload = { type: type, offset: offset, count: count }
|
74
|
-
|
75
|
-
resp = HTTPX.post(BATCHGET_MATERIAL_URL, params: { access_token: access_token }, json: payload)
|
76
|
-
|
77
|
-
r = ::JSON.parse(resp.body, quirks_mode: true)
|
78
|
-
yield r if block_given?
|
79
|
-
r
|
80
|
-
end
|
81
|
-
|
82
|
-
# 新增永久图文素材
|
83
|
-
# https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Adding_Permanent_Assets.html
|
84
|
-
def add_news(articles)
|
85
|
-
payload = { articles: articles }
|
86
|
-
|
87
|
-
resp = HTTPX.post(ADD_NEWS_URL, params: { access_token: access_token }, json: payload)
|
88
|
-
|
89
|
-
r = ::JSON.parse(resp.body, quirks_mode: true)
|
90
|
-
yield r if block_given?
|
91
|
-
r
|
92
|
-
end
|
93
|
-
|
94
|
-
def menu_create
|
95
|
-
raise NotImplementedError
|
96
|
-
end
|
96
|
+
file = HTTP::FormData::File.new(media)
|
97
|
+
resp = HTTPX.plugin(:multipart).post(UPLOADIMG_URL, params: { access_token: access_token }, form: { media: file })
|
98
|
+
|
99
|
+
r = ::JSON.parse(resp.body, quirks_mode: true)
|
100
|
+
yield r if block_given?
|
101
|
+
r
|
102
|
+
end
|
103
|
+
|
104
|
+
def menu_create
|
105
|
+
raise NotImplementedError
|
97
106
|
end
|
98
107
|
end
|
99
108
|
end
|
data/lib/easy_wechat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_wechat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 42up
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpx
|