igetui-ruby-nolock 1.2.2
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 +7 -0
- data/.gitignore +46 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +136 -0
- data/Rakefile +6 -0
- data/igetui-ruby.gemspec +23 -0
- data/lib/igetui/client.rb +9 -0
- data/lib/igetui/message.rb +26 -0
- data/lib/igetui/pusher.rb +163 -0
- data/lib/igetui/template/base_template.rb +70 -0
- data/lib/igetui/template/link_template.rb +60 -0
- data/lib/igetui/template/notification_template.rb +66 -0
- data/lib/igetui/template/noty_pop_load_template.rb +90 -0
- data/lib/igetui/template/transmission_template.rb +40 -0
- data/lib/igetui/template.rb +5 -0
- data/lib/igetui/validate.rb +126 -0
- data/lib/igetui/version.rb +3 -0
- data/lib/igetui.rb +36 -0
- data/lib/igetui_ruby.rb +1 -0
- data/lib/protobuf/GtReq.pb.rb +399 -0
- data/test/pusher_test.rb +128 -0
- metadata +68 -0
data/test/pusher_test.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require './lib/igetui'
|
3
|
+
|
4
|
+
class PusherTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
# before run test, you need to change the variables in setup method.
|
7
|
+
def setup
|
8
|
+
@app_id = 'YOUR APP ID'
|
9
|
+
@app_key = 'YOUR APP KEY'
|
10
|
+
@master_secret = 'YOUR MASTER SECRET'
|
11
|
+
@cid_1 = 'CLIENT ID ONE'
|
12
|
+
@cid_2 = 'CLIENT ID TWO'
|
13
|
+
|
14
|
+
@pusher = IGeTui.pusher(@app_id, @app_key, @master_secret)
|
15
|
+
@client_1 = IGeTui::Client.new(@cid_1)
|
16
|
+
@client_2 = IGeTui::Client.new(@cid_2)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_status
|
20
|
+
ret = @pusher.get_client_id_status(@cid_1)
|
21
|
+
assert_equal ret["result"], "Online"
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_to_single_noty_pop_load
|
25
|
+
single_message = IGeTui::SingleMessage.new
|
26
|
+
single_message.data = noty_pop_load_template
|
27
|
+
ret = @pusher.push_message_to_single(single_message, @client_1)
|
28
|
+
assert_equal ret["result"], "ok"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_to_single_notification
|
32
|
+
single_message = IGeTui::SingleMessage.new
|
33
|
+
single_message.data = notification_template
|
34
|
+
ret = @pusher.push_message_to_single(single_message, @client_1)
|
35
|
+
assert_equal ret["result"], "ok"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_to_single_link_notification
|
39
|
+
single_message = IGeTui::SingleMessage.new
|
40
|
+
single_message.data = link_template
|
41
|
+
ret = @pusher.push_message_to_single(single_message, @client_1)
|
42
|
+
assert_equal ret["result"], "ok"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_to_single_transmission
|
46
|
+
single_message = IGeTui::SingleMessage.new
|
47
|
+
single_message.data = transmission_template
|
48
|
+
ret = @pusher.push_message_to_single(single_message, @client_1)
|
49
|
+
assert_equal ret["result"], "ok"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_to_list_transmission
|
53
|
+
list_message = IGeTui::ListMessage.new
|
54
|
+
list_message.data = transmission_template
|
55
|
+
client_list = [@client_1, @client_2]
|
56
|
+
content_id = @pusher.get_content_id(list_message)
|
57
|
+
ret = @pusher.push_message_to_list(content_id, client_list)
|
58
|
+
assert_equal ret["result"], "ok"
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_to_app_notification
|
62
|
+
app_message = IGeTui::AppMessage.new
|
63
|
+
app_message.data = notification_template
|
64
|
+
app_message.app_id_list = [@app_id]
|
65
|
+
# app_message.province_list = ['浙江', '上海']
|
66
|
+
# app_message.tag_list = ['开心']
|
67
|
+
ret = @pusher.push_message_to_app(app_message)
|
68
|
+
assert_equal ret["result"], "ok"
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def set_template_base_info(template)
|
74
|
+
template.logo = 'push.png'
|
75
|
+
template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
|
76
|
+
template.title = '测试标题'
|
77
|
+
template.text = '测试文本'
|
78
|
+
end
|
79
|
+
|
80
|
+
def link_template
|
81
|
+
template = IGeTui::LinkTemplate.new
|
82
|
+
set_template_base_info(template)
|
83
|
+
template.url = "http://www.baidu.com"
|
84
|
+
template.set_push_info("open", 4, "message", "")
|
85
|
+
template
|
86
|
+
end
|
87
|
+
|
88
|
+
def notification_template
|
89
|
+
template = IGeTui::NotificationTemplate.new
|
90
|
+
set_template_base_info(template)
|
91
|
+
template.set_push_info("open", 4, "message", "")
|
92
|
+
template
|
93
|
+
end
|
94
|
+
|
95
|
+
def transmission_template
|
96
|
+
template = IGeTui::TransmissionTemplate.new
|
97
|
+
# Notice: content should be string.
|
98
|
+
content = {
|
99
|
+
"action" => "notification",
|
100
|
+
"title" => "标题aaa",
|
101
|
+
"content" => "内容",
|
102
|
+
"type" => "Article",
|
103
|
+
"id" => "1234"
|
104
|
+
}
|
105
|
+
|
106
|
+
content = content.to_s.gsub(":", "").gsub("=>", ":")
|
107
|
+
template.transmission_content = content
|
108
|
+
puts template.transmission_content
|
109
|
+
template.set_push_info("test", 1, "test1", "")
|
110
|
+
template
|
111
|
+
end
|
112
|
+
|
113
|
+
# attr_accessor :load_icon, :load_title, :load_url
|
114
|
+
def noty_pop_load_template
|
115
|
+
template = IGeTui::NotyPopLoadTemplate.new
|
116
|
+
set_template_base_info(template)
|
117
|
+
template.pop_title = "弹框标题"
|
118
|
+
template.pop_text = "弹框内容"
|
119
|
+
template.pop_image = ""
|
120
|
+
template.pop_button_1 = "下载"
|
121
|
+
template.pop_button_2 = "取消"
|
122
|
+
template.load_icon = "file://icon.png"
|
123
|
+
template.load_title = "下载内容"
|
124
|
+
template.load_url = "http://gdown.baidu.com/data/wisegame/c95836e06c224f51/weixinxinqing_5.apk"
|
125
|
+
template
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: igetui-ruby-nolock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yone hsiung
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ruby-sdk of igetui.com push notification service
|
14
|
+
email:
|
15
|
+
- 'QQ: 171842474'
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files:
|
19
|
+
- README.md
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- igetui-ruby.gemspec
|
28
|
+
- lib/igetui.rb
|
29
|
+
- lib/igetui/client.rb
|
30
|
+
- lib/igetui/message.rb
|
31
|
+
- lib/igetui/pusher.rb
|
32
|
+
- lib/igetui/template.rb
|
33
|
+
- lib/igetui/template/base_template.rb
|
34
|
+
- lib/igetui/template/link_template.rb
|
35
|
+
- lib/igetui/template/notification_template.rb
|
36
|
+
- lib/igetui/template/noty_pop_load_template.rb
|
37
|
+
- lib/igetui/template/transmission_template.rb
|
38
|
+
- lib/igetui/validate.rb
|
39
|
+
- lib/igetui/version.rb
|
40
|
+
- lib/igetui_ruby.rb
|
41
|
+
- lib/protobuf/GtReq.pb.rb
|
42
|
+
- test/pusher_test.rb
|
43
|
+
homepage: https://github.com/YoneHsiung/igetui-ruby.git
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.5.2
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: igetui.com ruby sdk
|
67
|
+
test_files:
|
68
|
+
- test/pusher_test.rb
|