fastlane-plugin-wechat 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4f7163ab8d591543852bcfbe325094bc8776806c66df86a37f500ad268af79fd
4
+ data.tar.gz: d0b1b754b06eea5d0ca9588207748f020dcf782fdb5c782315a869825d3c1d7f
5
+ SHA512:
6
+ metadata.gz: 80ed4ef10565f18c51689c305353760f8aec686bc0b475d2a39bd2e61990a3c2ab396cfe9afd37717d8ed3194daee268cdd4125e490dc8f81f4f420785c7ad09
7
+ data.tar.gz: 3124e1beade42d0ee9b6dfc8ec06447afa604c5958a1096885a5704666ffb6835529040500be26b5019ab9da4ff2b14bff5b25ac8f3106f189ae9f3ac3422aca
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 xiongzenghui <zxcvb1234001@163.com>
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/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # wechat plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-wechat)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-wechat`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin wechat
11
+ ```
12
+
13
+ ## About wechat
14
+
15
+ this is a wechat api wrapper
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## Example
20
+
21
+ ### 1. text 文本 类型
22
+
23
+ ```ruby
24
+ wechat(
25
+ access_token: 'your wechat api token', # 注意: 这个 token 必须每次重新请求获取, 不能长时间使用
26
+ agentid: 'your wechat api agentid',
27
+ recievers: ['xiongzenghui'],
28
+ msgtype: 'text',
29
+ text: 'welcome to fastlane ~',
30
+ send_message_url: "http://smsc.in.xxx.com/message/send?userid=wangfei"
31
+ )
32
+ ```
33
+
34
+ ![](images/Snip20190801_11.png)
35
+
36
+ ### 2. markdown 类型
37
+
38
+ ```ruby
39
+ wechat(
40
+ access_token_url: 'http://smsc.in.xxx.com/token',
41
+ agentid: 'your wechat api agentid',
42
+ secret: 'your wechat api secret',
43
+ recievers: ['xiongzenghui'],
44
+ msgtype: 'markdown',
45
+ text: "实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意.\n >类型:<font color=\"comment\">用户反馈</font>\n >普通用户反馈:<font color=\"comment\">117例</font>\n >VIP用户反馈:<font color=\"comment\">15例</font>",
46
+ send_message_url: "http://smsc.in.xxx.com/message/send?userid=xiongzenghui"
47
+ )
48
+ ```
49
+
50
+ ![](images/Snip20190801_12.png)
51
+
52
+ ### 3. news 图文类型
53
+
54
+ ```ruby
55
+ wechat(
56
+ access_token_url: 'http://smsc.in.xxx.com/token',
57
+ agentid: 'your wechat api agentid',
58
+ secret: 'your wechat api secret',
59
+ recievers: ['xiongzenghui'],
60
+ msgtype: 'news',
61
+ articles: [{
62
+ "title" => "中秋节礼品领取",
63
+ "description" => "今年中秋节公司有豪礼相送",
64
+ "url" => "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png",
65
+ "picurl" => "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
66
+ }],
67
+ send_message_url: "http://smsc.in.xxx.com/message/send?userid=xiongzenghui"
68
+ )
69
+ ```
70
+
71
+ ![](images/Snip20190801_13.png)
72
+
73
+
74
+
75
+ ## Run tests for this plugin
76
+
77
+ To run both the tests, and code style validation, run
78
+
79
+ ```
80
+ rake
81
+ ```
82
+
83
+ To automatically fix many of the styling issues, use
84
+ ```
85
+ rubocop -a
86
+ ```
87
+
88
+ ## Issues and Feedback
89
+
90
+ For any other issues and feedback about this plugin, please submit it to this repository.
91
+
92
+ ## Troubleshooting
93
+
94
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
95
+
96
+ ## Using _fastlane_ Plugins
97
+
98
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
99
+
100
+ ## About _fastlane_
101
+
102
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/wechat/version'
2
+
3
+ module Fastlane
4
+ module Wechat
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Wechat.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,199 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/wechat_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class WechatAction < Action
7
+ require 'net/https'
8
+ require 'json'
9
+
10
+ def self.run(params)
11
+ access_token = params[:access_token]
12
+ access_token_url = params[:access_token_url]
13
+ agentid = params[:agentid]
14
+ secret = params[:secret]
15
+ recievers = params[:recievers]
16
+ send_message_url = params[:send_message_url]
17
+ msgtype = params[:msgtype]
18
+ text = params[:text]
19
+ articles = params[:articles]
20
+
21
+ unless access_token
22
+ access_token = request_access_token(access_token_url, agentid, secret)
23
+ UI.important "[WechatAction] request access_token: #{access_token}"
24
+ end
25
+
26
+ msg_uri = URI(send_message_url)
27
+ headers = {
28
+ 'token' => access_token,
29
+ 'agentid' => agentid,
30
+ 'Content-Type' => 'application/json'
31
+ }
32
+ body = {}
33
+ body['touser'] = recievers.join('|')
34
+ body['msgtype'] = msgtype
35
+
36
+ # 1、文本类型
37
+ # {
38
+ # "msgtype": "text",
39
+ # "text": {
40
+ # "content": "广州今日天气:29度,大部分多云,降雨概率:60%",
41
+ # "mentioned_list":["wangqing","@all"],
42
+ # "mentioned_mobile_list":["13800001111","@all"]
43
+ # }
44
+ # }
45
+ if msgtype == 'text'
46
+ body['text'] = {
47
+ 'content' => text
48
+ }
49
+ end
50
+
51
+ # 2、markdown类型
52
+ # {
53
+ # "msgtype": "markdown",
54
+ # "markdown": {
55
+ # "content": "实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。\n
56
+ # >类型:<font color=\"comment\">用户反馈</font> \n
57
+ # >普通用户反馈:<font color=\"comment\">117例</font> \n
58
+ # >VIP用户反馈:<font color=\"comment\">15例</font>"
59
+ # }
60
+ # }
61
+ if msgtype == 'markdown'
62
+ body['markdown'] = {
63
+ "content" => text
64
+ }
65
+ end
66
+
67
+
68
+ # 3、图片类型
69
+ # {
70
+ # "msgtype": "image",
71
+ # "image": {
72
+ # "base64": "DATA",
73
+ # "md5": "MD5"
74
+ # }
75
+ # }
76
+ if msgtype == 'image'
77
+ body['image'] = {
78
+ 'content' => text
79
+ }
80
+ end
81
+
82
+ # 4、图文类型
83
+ # {
84
+ # "msgtype": "news",
85
+ # "news": {
86
+ # "articles" : [
87
+ # {
88
+ # "title" : "中秋节礼品领取",
89
+ # "description" : "今年中秋节公司有豪礼相送",
90
+ # "url" : "URL",
91
+ # "picurl" : "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
92
+ # }
93
+ # ]
94
+ # }
95
+ # }
96
+ if msgtype == 'news'
97
+ body['news'] = {
98
+ 'articles' => articles
99
+ }
100
+ end
101
+
102
+ # UI.success(body)
103
+ req = Net::HTTP::Post.new(msg_uri, headers)
104
+ req.body = body.to_json
105
+ Net::HTTP.new(msg_uri.host, msg_uri.port).start do |http|
106
+ http.request(req)
107
+ end
108
+ end
109
+
110
+ def self.request_access_token(url, agentid, secret)
111
+ token_uri = URI(url)
112
+ req = Net::HTTP::Get.new(token_uri)
113
+ req['agentid'] = agentid.to_s
114
+ req['secret'] = secret.to_s
115
+ res = Net::HTTP.start(token_uri.hostname, token_uri.port) do |http|
116
+ http.request(req)
117
+ end
118
+ JSON.parse(res.body)["access_token"]
119
+ end
120
+
121
+ def self.description
122
+ "this is a wechat api wrapper"
123
+ end
124
+
125
+ def self.details
126
+ "send message via enterprice wechat server api"
127
+ end
128
+
129
+ def self.authors
130
+ ["xiongzenghui"]
131
+ end
132
+
133
+ def self.available_options
134
+ [
135
+ FastlaneCore::ConfigItem.new(
136
+ key: :access_token,
137
+ description: "wechat access token",
138
+ type: String,
139
+ optional: true,
140
+ conflicting_options: [:access_token_url, :secret]
141
+ ),
142
+ FastlaneCore::ConfigItem.new(
143
+ key: :access_token_url,
144
+ description: "request wechat access token url",
145
+ type: String,
146
+ optional: true
147
+ ),
148
+ FastlaneCore::ConfigItem.new(
149
+ key: :agentid,
150
+ description: "agentid param for request wechat access token",
151
+ type: String,
152
+ optional: true
153
+ ),
154
+ FastlaneCore::ConfigItem.new(
155
+ key: :secret,
156
+ description: "secret param for request wechat access token",
157
+ type: String,
158
+ optional: true
159
+ ),
160
+ FastlaneCore::ConfigItem.new(
161
+ key: :recievers,
162
+ description: "how many man to receive this message",
163
+ type: Array,
164
+ optional: false
165
+ ),
166
+ FastlaneCore::ConfigItem.new(
167
+ key: :text,
168
+ description: "wechat message text",
169
+ type: String,
170
+ optional: true,
171
+ ),
172
+ FastlaneCore::ConfigItem.new(
173
+ key: :msgtype,
174
+ description: "wechat message type, eg: markdown、text、image、news",
175
+ type: String,
176
+ optional: false
177
+ ),
178
+ FastlaneCore::ConfigItem.new(
179
+ key: :send_message_url,
180
+ description: "send message to wechat server api url",
181
+ type: String,
182
+ optional: false
183
+ ),
184
+ FastlaneCore::ConfigItem.new(
185
+ key: :articles,
186
+ description: "news articles",
187
+ type: Array,
188
+ optional: true,
189
+ conflicting_options: [:text]
190
+ )
191
+ ]
192
+ end
193
+
194
+ def self.is_supported?(platform)
195
+ true
196
+ end
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class WechatHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::WechatHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the wechat plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Wechat
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-wechat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - xiongzenghui
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.128.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.128.0
139
+ description:
140
+ email: zxcvb1234001@163.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/wechat.rb
148
+ - lib/fastlane/plugin/wechat/actions/wechat_action.rb
149
+ - lib/fastlane/plugin/wechat/helper/wechat_helper.rb
150
+ - lib/fastlane/plugin/wechat/version.rb
151
+ homepage: https://github.com/xzhhe/fastlane-plugin-wechat
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.0.4
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: this is a wechat api wrapper
174
+ test_files: []