Commit d7d569be by lanrion

创建二维码 添加 scene_str 参数

parent bfb7dcef
......@@ -13,10 +13,13 @@ module WeixinAuthorize
end
# 永久二维码
def create_qr_limit_scene(scene_id)
# options: scene_id, scene_str
def create_qr_limit_scene(options)
scene_id = options[:scene_id]
scene_str = options[:scene_str]
post_url = "#{qrcode_base_url}/create"
qrcode_infos = {action_name: "QR_LIMIT_SCENE"}
qrcode_infos = qrcode_infos.merge(action_info(scene_id))
qrcode_infos = qrcode_infos.merge(action_info(scene_id, scene_str))
http_post(post_url, qrcode_infos)
end
......@@ -31,8 +34,11 @@ module WeixinAuthorize
"/qrcode"
end
def action_info(scene_id)
{action_info: {scene: {scene_id: scene_id}}}
def action_info(scene_id, scene_str=nil)
scene_info = {}
scene_info[:scene_id] = scene_id
scene_info[:scene_str] = scene_str if !scene_str.nil?
{action_info: {scene: scene_info}}
end
end
......
......@@ -8,13 +8,13 @@ describe WeixinAuthorize::Api::Qrcode do
end
it "#create_qr_limit_scene" do
response = $client.create_qr_limit_scene("1234")
response = $client.create_qr_limit_scene(scene_id: 1234, scene_str: "wechat")
expect(response.code).to eq(WeixinAuthorize::OK_CODE)
expect(response.result.keys).to eq(["ticket", "url"])
end
it "#return_qr_url" do
response = $client.create_qr_limit_scene("1234")
response = $client.create_qr_limit_scene(scene_id: 1234, scene_str: "wechat")
qr_url = $client.qr_code_url(response.result["ticket"])
expect(response.code).to eq(WeixinAuthorize::OK_CODE)
expect(qr_url).to match(/(\S+\.(com|net|org|edu|gov)(\/\S+)?)/)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment