mini_program 0.7.0 → 0.11.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: 531964b9adaef42289c3a113f8ab443d0cdef8e21768c039978a3c331c99918b
4
- data.tar.gz: 32c3cfc3299844288904f8ef4650ee13a960f05a9a3c28c1fa6782bf68dbcdd2
3
+ metadata.gz: 33eb5ef599719b87fa6f41511075a9a63583aa0a09b7889cf198fff54b23ad9d
4
+ data.tar.gz: 5c7384b8a9b7f8b87476e3a4f9664a2011106eadbb02e4727ae3ee5a40074396
5
5
  SHA512:
6
- metadata.gz: 29d604fdfe44aa2f0f48b04d91724d0af1bde9350197510a9e4342232fec99557c4353e7bf9539d6ee0a95120bb6cc86254362564e68d6f019d4b5910ddd2f03
7
- data.tar.gz: 30d0ffd3efbe1f28067297a48b0c6a859e07c5c58cad5f7adf1becba25d350bf7b91f5fc7e210fd740ac2669d5559faa559b7b9ec578b1d677fc679486854a60
6
+ metadata.gz: 5926356805f658544866838ac1f5222aeb463fe97d35d8fd2c1bfec31f9238f5089b530c8e8b594e4328c1ff527372aa24d4116878f792ad180e6323dd6cd638
7
+ data.tar.gz: 3d6a4b3e3250b1639c53c211854c41616d24959f830816e70a2d097db58d7eef8b0323d9e1cd6bab48ac9819cb3f11886c984d7810cfc712570c1fdac50f37a5
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}
@@ -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.7.0'
2
+ VERSION = '0.11.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_program
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ian