mini_program 0.8.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05df7b4f084319a75fc963019972756115c411396b79802018ee99b83acbaa94
4
- data.tar.gz: dfe7902f53cfbdb97221590333547446c60c8c4435fd2e2151097808f6b8e975
3
+ metadata.gz: 275a02cf0094d560e0cfda755e2d273993705bae8116bf8dd5c278349dec5028
4
+ data.tar.gz: 6540428d127a5591e2f24fe6ddb09d437e3c5917308964df9a18eab8c53d37cb
5
5
  SHA512:
6
- metadata.gz: d5bc5b20e832b7307ff6131844de01274d4020c9dde92d96d1a410248b18dd142c210181ac916715194500e1ab933ba78562f40ee1200e21efa02a6526fce1d3
7
- data.tar.gz: 2336e3a632dab9dd4e6fab8d7e8febd5206f04f91fd4aad15c758f2c02f2d3a92ee627f4d9ba17d7eda93114a28919b2a7aa1235158bb51698752794c0e945b8
6
+ metadata.gz: 44b7ba7bb6f918b84d21ddfc19235ea768ec6e6e236da5e961c6ebb26ff7d968cda32155318169a68df8b481f20d11df78cef1247d60c1b83bd218137dd62049
7
+ data.tar.gz: ec86f477b4522f01337e781878d7977ec9f73e8a438f6fb7d70ae3a046db455abe6d2907dda0b85f3de96ec687af903e5b5601d3c5d49efaf731368f9c04edd9
data/README.md CHANGED
@@ -32,7 +32,7 @@ mp = MiniProgram::Client.new
32
32
  # code 是在小程序端调用 wx.login 拿到的
33
33
  result = mp.login(code)
34
34
  if result.success?
35
- open_id = result.data[:openid]
35
+ openid = result.data[:openid]
36
36
  session_key = result.data[:session_key]
37
37
  end
38
38
  ```
@@ -83,12 +83,12 @@ msg = MiniProgram::Msg.new(:progress, {
83
83
  detail: "测试已完成"
84
84
  })
85
85
 
86
- # send_to 的参数可以是 openid(字符串),或者是带有 open_id 方法的对象,返回 MiniProgram::ServiceResult
86
+ # send_to 的参数可以是 openid(字符串),或者是带有 openid 方法的对象,返回 MiniProgram::ServiceResult
87
87
  result = msg.send_to("ogT7J5YddGnll-ippRvJq62Nv5W0")
88
88
 
89
89
  # or
90
90
  user = User.first
91
- user.open_id # => ogT7J5YddGnll-ippRvJq62Nv5W0
91
+ user.openid # => ogT7J5YddGnll-ippRvJq62Nv5W0
92
92
  result = msg.send_to(user)
93
93
 
94
94
  if result.success?
@@ -52,7 +52,7 @@ module MiniProgram
52
52
 
53
53
  result = JSON.parse(response)
54
54
 
55
- if result["errcode"].to_s != "0"
55
+ if result["errcode"] && result["errcode"].to_s != "0"
56
56
  logger.error <<~ERROR
57
57
  Get access token failed.
58
58
  api: #{api}
@@ -80,7 +80,7 @@ module MiniProgram
80
80
 
81
81
  result = JSON.parse(response)
82
82
 
83
- if result["errcode"].to_s != "0"
83
+ if result["errcode"] && result["errcode"].to_s != "0"
84
84
  logger.error <<~ERROR
85
85
  Get session key failed.
86
86
  api: #{api}
@@ -94,11 +94,11 @@ module MiniProgram
94
94
 
95
95
  # 发送订阅消息
96
96
  # @param [MiniProgram::Msg] msg
97
- # @param [String] to 用户的open id
97
+ # @param [String] to 用户的openid
98
98
  def send_msg(msg, to: )
99
- open_id = to.try(:open_id) || to
99
+ openid = to.try(:openid) || to
100
100
 
101
- payload = msg.as_json.merge!(touser: open_id)
101
+ payload = msg.as_json.merge!(touser: openid)
102
102
 
103
103
  # 获取 access_token
104
104
  get_token_result = get_access_token
@@ -123,7 +123,7 @@ module MiniProgram
123
123
  # 现在小程序的模板消息功能关闭了,就只剩下发送模板消息到公众号这个功能了
124
124
  #
125
125
  def send_uniform_msg(msg, to: )
126
- open_id = to.try(:open_id) || to
126
+ openid = to.try(:openid) || to
127
127
 
128
128
  payload = msg.as_json
129
129
 
@@ -134,7 +134,7 @@ module MiniProgram
134
134
 
135
135
  api = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=#{get_token_result["access_token"]}"
136
136
  result = post(api, {
137
- touser: open_id,
137
+ touser: openid,
138
138
  mp_template_msg: payload
139
139
  })
140
140
 
@@ -152,7 +152,7 @@ module MiniProgram
152
152
  login_result = login(code)
153
153
  return login_result if login_result.failure?
154
154
 
155
- open_id = login_result.data[:openid]
155
+ openid = login_result.data[:openid]
156
156
  session_key = login_result.data[:session_key]
157
157
 
158
158
  data = decrypt_phone_data(encrypted_data, iv, session_key)
@@ -162,7 +162,7 @@ module MiniProgram
162
162
  MiniProgram::ServiceResult.new(
163
163
  success: true,
164
164
  data: {
165
- open_id: open_id,
165
+ openid: openid,
166
166
  phone_num: phone_num
167
167
  })
168
168
  end
@@ -1,3 +1,3 @@
1
1
  module MiniProgram
2
- VERSION = '0.8.0'
2
+ VERSION = '0.12.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_program
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2021-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails