wx_ext 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: 203fdbfdf2af62627187c6032990c5197801c986
4
- data.tar.gz: d5b91a0de4da6424b4a7eb3dce028b3ddcc83b2c
3
+ metadata.gz: 23c3940298003a23d43bbd1ff4ee9af7211a3221
4
+ data.tar.gz: d62ae090872a99c079048c344418b25c5fb0bf6b
5
5
  SHA512:
6
- metadata.gz: 5321d5ffd737870b445b26493bbfe6c64c440d41a05b9af6224d99264896993fcc861ff6aa191942a9428a910421e5ed5ac0b7955cc93e4a18fb20235a93f00f
7
- data.tar.gz: 0185ceab9c0dc273315275f3a88d9c596698e3c274ce55066b85f27f78b0c0447f58ed0e594e70034a72aa11e0e7ed4a6321af85525b5d545fadb9c1fcf23e1c
6
+ metadata.gz: a92c4ac504ebe1b2d8602cc5d7cd094d302bdd925c5d57c37c2fe036364be52618dd33dbbfcb98361d065fd49b3ec2af3bd57e00e29b4b0e375177c015ef5381
7
+ data.tar.gz: bceaf355c71931d988c0d9879a5234be4cf6408c794fb53888b5e1789ba095f0c53959bb689ac76949895ae77078dc01c4eb81d5d4d64c79e7fea3a959c39199
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'rest_client'
4
+ require 'wx_ext/helper'
4
5
 
5
6
  module WxExt
6
7
  # Weixin api
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
data/lib/wx_ext/api/js.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'digest'
4
+ require 'wx_ext/helper'
4
5
 
5
6
  module WxExt
6
7
  # Weixin api
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -1,5 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ require 'wx_ext/helper'
4
+
3
5
  module WxExt
4
6
  # Weixin api
5
7
  #
@@ -40,7 +42,7 @@ module WxExt
40
42
  # @param [Enumerable<String>] access_token
41
43
  # @param [Enumerable<String>] next_openid
42
44
  # @return [Hash] Json based hash.
43
- def user_list(access_token, next_openid)
45
+ def user_list(access_token, next_openid=nil)
44
46
  url = 'https://api.weixin.qq.com/cgi-bin/user/get'\
45
47
  "?access_token=#{access_token}"
46
48
  url += "&next_openid=#{next_openid}" if next_openid
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module WxExt
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
@@ -2,4 +2,25 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe WxExt::Api::CustomerService do
5
+ before(:all) do
6
+ @app_id = 'app_id'
7
+ @access_token_hash = WxExt::Api::Base.get_access_token('app_id', 'app_secret')
8
+ @access_token = @access_token_hash['access_token']
9
+ end
10
+
11
+ it 'should reply text msg to user' do
12
+ res_hash = WxExt::Api::CustomerService.reply_msg(@access_token, 'oK_Xnt2a9LAh0cbYuBGFSPxnvu1w', 'text', { content: 'Hello World' })
13
+ puts '=' * 20
14
+ puts res_hash
15
+ expect(res_hash['errcode']).to eql(0)
16
+ end
17
+
18
+ it 'should reply img msg to user' do
19
+ file = File.new(File.join(WxExt.spec, "test.png"), 'rb')
20
+ file_hash = WxExt::Api::Base.upload_media(@access_token, 'image', file)
21
+ res_hash = WxExt::Api::CustomerService.reply_msg(@access_token, 'oK_Xnt2a9LAh0cbYuBGFSPxnvu1w', 'image', { media_id: file_hash['media_id'] })
22
+ puts '=' * 20
23
+ puts res_hash
24
+ expect(res_hash['errcode']).to eql(0)
25
+ end
5
26
  end
@@ -2,4 +2,56 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe WxExt::Api::Menu do
5
+ before(:all) do
6
+ @app_id = 'app_id'
7
+ @access_token_hash = WxExt::Api::Base.get_access_token('app_id', 'app_secret')
8
+ @access_token = @access_token_hash['access_token']
9
+ end
10
+
11
+ it 'should create menu and then del it' do
12
+ menu_hash = {
13
+ button: [
14
+ {
15
+ type: 'click',
16
+ name: '今日歌曲',
17
+ key: 'V1001_TODAY_MUSIC'
18
+ },
19
+ {
20
+ name: '菜单',
21
+ sub_button: [
22
+ {
23
+ type: 'view',
24
+ name: '搜索',
25
+ url: 'http://www.soso.com/'
26
+ },
27
+ {
28
+ type: 'view',
29
+ name: '视频',
30
+ url: 'http://v.qq.com/'
31
+ },
32
+ {
33
+ type: 'click',
34
+ name: '赞一下我们',
35
+ key: 'V1001_GOOD'
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ }
41
+ create_hash = WxExt::Api::Menu.create_menu(@access_token, menu_hash)
42
+ puts '=' * 20
43
+ puts create_hash
44
+ expect(create_hash['errcode']).to eql(0)
45
+ end
46
+
47
+ it 'should get all menus and then del it' do
48
+ res_hash = WxExt::Api::Menu.menus(@access_token)
49
+ puts '=' * 20
50
+ puts res_hash
51
+ expect(res_hash['menu']).not_to be_empty
52
+
53
+ del_hash = WxExt::Api::Menu.del_menu(@access_token)
54
+ expect(del_hash['errcode']).to eql(0)
55
+ puts del_hash
56
+ end
5
57
  end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe WxExt::Api::Semantic do
5
+ before(:all) do
6
+ @app_id = 'app_id'
7
+ @access_token_hash = WxExt::Api::Base.get_access_token('app_id', 'app_secret')
8
+ @access_token = @access_token_hash['access_token']
9
+ end
10
+
11
+ it 'should 发送语义理解请求' do
12
+ semantic_hash = {
13
+ query: '查一下明天从北京到上海的南航机票',
14
+ city: '北京',
15
+ category: 'flight,hotel',
16
+ appid: @app_id,
17
+ uid: 'oK_Xnt2a9LAh0cbYuBGFSPxnvu1w'
18
+ }
19
+ hash = WxExt::Api::Semantic.semantic_search(@access_token, semantic_hash)
20
+ puts hash
21
+ expect(hash['errcode']).to eql(0)
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe WxExt::Api::TemplateMsg do
5
+ before(:all) do
6
+ @app_id = 'app_id'
7
+ @access_token_hash = WxExt::Api::Base.get_access_token('app_id', 'app_secret')
8
+ @access_token = @access_token_hash['access_token']
9
+ end
10
+
11
+ #it 'should get js config' do
12
+ # config_hash = WxExt::Api::Base.get_jsapi_config(@access_token, '', @app_id)
13
+ # expect(config_hash[:app_id]).to eql(@app_id)
14
+ #end
15
+ end
@@ -8,8 +8,35 @@ describe WxExt::Api::User do
8
8
  @access_token = @access_token_hash['access_token']
9
9
  end
10
10
 
11
- #it 'should get js config' do
12
- # config_hash = WxExt::Api::Base.get_jsapi_config(@access_token, '', @app_id)
13
- # expect(config_hash[:app_id]).to eql(@app_id)
14
- #end
11
+ it 'should get user list' do
12
+ user_list_hash = WxExt::Api::User.user_list(@access_token)
13
+ puts '-' * 20
14
+ puts user_list_hash
15
+ expect(user_list_hash['total'].to_s).to match(/\d*/)
16
+ end
17
+
18
+ it 'should get user info of oK_Xnt2a9LAh0cbYuBGFSPxnvu1w' do
19
+ user_hash = WxExt::Api::User.get_user_base_info(@access_token, 'oK_Xnt2a9LAh0cbYuBGFSPxnvu1w')
20
+ puts '-' * 20
21
+ puts user_hash
22
+ expect(user_hash['sex'].to_s).to match(/\d*/)
23
+ end
24
+
25
+ it 'should get user info of 南' do
26
+ user_list_hash = WxExt::Api::User.user_list(@access_token)
27
+ user_list_hash['data']['openid'].each do |openid|
28
+ user_hash = WxExt::Api::User.get_user_base_info(@access_token, openid)
29
+ if user_hash['nickname'] == '南'
30
+ puts '-' * 20
31
+ # oK_Xnt2a9LAh0cbYuBGFSPxnvu1w
32
+ puts user_hash
33
+ end
34
+ end
35
+ expect(user_list_hash['total'].to_s).to match(/\d*/)
36
+ end
37
+
38
+ it 'should remark nickname of 南' do
39
+ remark_hash = WxExt::Api::User.change_remark(@access_token, 'oK_Xnt2a9LAh0cbYuBGFSPxnvu1w', 'good boy')
40
+ expect(remark_hash['errcode']).to eql(0)
41
+ end
15
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wx_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - flowerwrong