easy_wechat 0.1.3 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5cb4283e2aa2451356d46392ba3260585b49bcb4a57d2e9cbb78964754335e2
4
- data.tar.gz: f684c3d9b9809e1f5d504989e6ccb98110b9dacb05debbfe3d9f9d328d187dea
3
+ metadata.gz: 5e2af1c17c25a328079203cbd8c82bdf9e8f11365c35da169fd1b38fb7b855b5
4
+ data.tar.gz: 3a73e8b129d26b56c930515929ccaa002c19a1ab6cbbf343c21e7d76cc4669d5
5
5
  SHA512:
6
- metadata.gz: b95b94c2179eeb420fcc7bcbb4f90851d9b589d47a73da60c31b1dbb6eb5b96dc53b82d8ac205faeba0f716ec1fa8771d0245ce05ef67d62f50e445c7d53ac42
7
- data.tar.gz: b3fb434e830ef7035120a683094fe0ac9a345774db32447e58f2db72ee05a766648f6ed472461864192410e24eb7bb04b79f0bccbe15b71b00f7af12e0e72153
6
+ metadata.gz: ff4da1cb7fd1e297d5620a0ac78a297242c40bd14c61d41195e3e02af231daf4ca07cb8eb29fc3c1ac6ef6bd90591af06334bc5ca80820561fda9899317e3bf6
7
+ data.tar.gz: 834409eecc816689a3a2813f07d63151ed675f809c03f2ee408b26998e94e1ade858d40d94a530be7aa2af230379b3f1a1092bd6d921dcf7d95e7555bd6b9d1c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_wechat (0.1.3)
4
+ easy_wechat (0.1.9)
5
5
  activesupport
6
6
  http-form_data
7
7
  httpx
@@ -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 = if media.is_a?(String) ? HTTP::FormData::File.new(media) : meida
61
- resp = HTTPX.plugin(:multipart).post(UPLOADIMG_URL, params: { access_token: access_token }, form: { media: file })
62
-
63
- r = ::JSON.parse(resp.body, quirks_mode: true)
64
- yield r if block_given?
65
- r
66
- end
67
-
68
- # 获取永久素材的列表
69
- # https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Get_materials_list.html
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
@@ -1,3 +1,3 @@
1
1
  module EasyWechat
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.9"
3
3
  end
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.3
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-10 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpx