igetui-ruby 0.0.1 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c99084dc071b82bced2d791b76b564f28786be7c
4
- data.tar.gz: 8061bca4c3e0fad40e4a364f4f8aae582831e214
3
+ metadata.gz: 0a319bd46f4da1cc9a7f7353fafa089593d4bbcc
4
+ data.tar.gz: bdbec6bddecbac031c233557805ebc07895b8c61
5
5
  SHA512:
6
- metadata.gz: f6bb4a7b695936bc590c8cebad51fd3c82260c2e0de29149d9cf60ca6c10cca377f5a2aa8264ef7078d2d0a797f4cbdbd5570da86a98e6460fdb97e2e2fb8864
7
- data.tar.gz: dd9c7d27fa24d99e3f3348bc3db8ecde67976e0e808d4fcb13e9dda8afe8863a926b60e72115f24511a6eebb24bb307be6d607ab6ce760e65dc131856a6f4e1c
6
+ metadata.gz: 990a289e47e41c0e2b7b67823ffa5f393b55c04193f0e7cb64bc84fea6a4dbfe9b09ec82ce27ca258dbd4df22454dd0ecd2c42f587e2aaf24d6e5aa0c2491308
7
+ data.tar.gz: 1594b11228b9d46a888ca3da086c58c0ce387a69cbe510cdce0e8400c50f7ec5a10ddbb0eff72ecbfdda810eb821fef6dd3db27a2ff777855f65fd7d854589da
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Victor Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,24 +1,124 @@
1
- # Igetui::Ruby
1
+ # IGeTui::Ruby
2
2
 
3
- TODO: Write a gem description
3
+ [个推](http://www.igetui.com/)服务端 ruby-sdk
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'igetui-ruby'
9
+ ```ruby
10
+ gem 'igetui-ruby', require: 'IGeTui'
11
+ ```
10
12
 
11
13
  And then execute:
12
14
 
13
- $ bundle
15
+ ```bash
16
+ $ bundle
17
+ ```
14
18
 
15
19
  Or install it yourself as:
16
20
 
17
- $ gem install igetui-ruby
21
+ ```bash
22
+ $ gem install igetui-ruby
23
+ ```
18
24
 
19
25
  ## Usage
20
26
 
21
- TODO: Write usage instructions here
27
+ ### Push Message To Single
28
+
29
+ ```ruby
30
+ pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)
31
+
32
+ # 创建通知模板
33
+ template = IGeTui::NotificationTemplate.new
34
+ template.logo = 'push.png'
35
+ template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
36
+ template.title = '测试标题'
37
+ template.text = '测试文本'
38
+
39
+ # 创建单体消息
40
+ single_message = IGeTui::SingleMessage.new
41
+ single_message.data = template
42
+
43
+ # 创建客户端对象
44
+ client = IGeTui::Client.new(your_client_id)
45
+
46
+ # 发送一条通知到指定的客户端
47
+ ret = pusher.push_message_to_single(single_message, client)
48
+ p ret
49
+ ```
50
+
51
+ ### Push Message To List
52
+
53
+ ```ruby
54
+ pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)
55
+
56
+ # 创建一条透传消息
57
+ template = IGeTui::TransmissionTemplate.new
58
+ # Notice: content should be string.
59
+ content = {
60
+ action: "notification",
61
+ title: "标题aaa",
62
+ content: "内容",
63
+ type: "article",
64
+ id: "4274"
65
+ }
66
+ content = content.to_s.gsub(":", "").gsub("=>", ":")
67
+ template.transmission_content = content
68
+
69
+ # 创建群发消息
70
+ list_message = IGeTui::ListMessage.new
71
+ list_message.data = template
72
+
73
+ # 创建客户端对象
74
+ client_1 = IGeTui::Client.new(your_client_id_1)
75
+ client_2 = IGeTui::Client.new(your_client_id_2)
76
+ client_list = [client_1, client_2]
77
+
78
+ content_id = pusher.get_content_id(list_message)
79
+ ret = pusher.push_message_to_list(content_id, client_list)
80
+ ```
81
+
82
+ ### Push Message To App
83
+
84
+ ```ruby
85
+ pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)
86
+
87
+ # 创建通知模板
88
+ template = IGeTui::NotificationTemplate.new
89
+ template.logo = 'push.png'
90
+ template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
91
+ template.title = '测试标题'
92
+ template.text = '测试文本'
93
+
94
+ # 创建APP群发消息
95
+ app_message = IGeTui::AppMessage.new
96
+ app_message.data = template
97
+ app_message.app_id_list = [your_app_id]
98
+
99
+ # 发送一条通知到程序
100
+ ret = pusher.push_message_to_app(app_message)
101
+ p ret
102
+ ```
103
+
104
+ ### Custom Test
105
+
106
+ ```ruby
107
+ require 'rubygems'
108
+ require 'IGeTui'
109
+
110
+ @pusher = IGeTui.pusher(your_app_id, your_app_key, your_master_secret)
111
+ ret = @pusher.get_client_id_status(@cid_1)
112
+ p ret
113
+ ```
114
+
115
+ ### Auto Test
116
+
117
+ 运行测试之前,请先修改 test/pusher_test.rb 中的相关配置。
118
+
119
+ ```ruby
120
+ rake test
121
+ ```
22
122
 
23
123
  ## Contributing
24
124
 
@@ -0,0 +1,64 @@
1
+ module IGeTui
2
+ class LinkTemplate < BaseTemplate
3
+ attr_accessor :title, :text, :logo, :logo_url, :url
4
+ attr_accessor :is_ring, :is_vibrate, :is_clearable
5
+
6
+ def initialize
7
+ @title = ''
8
+ @text = ''
9
+ @logo = ''
10
+ @logo_url = ''
11
+ @transmission_type = 0
12
+ @transmission_content = ''
13
+ @is_ring = true
14
+ @is_vibrate = true
15
+ @is_clearable = false
16
+ super
17
+ end
18
+
19
+ def get_action_chain
20
+ # set actionchain
21
+ action_chain_1 = GtReq::ActionChain.new
22
+ action_chain_1.actionId = 1
23
+ action_chain_1.type = GtReq::ActionChain::Type::Goto
24
+ action_chain_1.next = 10000
25
+
26
+ # notification
27
+ action_chain_2 = GtReq::ActionChain.new
28
+ action_chain_2.actionId = 10000
29
+ action_chain_2.type = GtReq::ActionChain::Type::Notification
30
+ action_chain_2.title = title
31
+ action_chain_2.text = text
32
+ action_chain_2.logo = logo
33
+ action_chain_2.logoURL = logo_url
34
+ action_chain_2.ring = is_ring
35
+ action_chain_2.clearable = is_clearable
36
+ action_chain_2.buzz = is_vibrate
37
+ action_chain_2.next = 10010
38
+
39
+ # goto
40
+ action_chain_3 = GtReq::ActionChain.new
41
+ action_chain_3.actionId = 10010
42
+ action_chain_3.type = GtReq::ActionChain::Type::Goto
43
+ action_chain_3.next = 10030
44
+
45
+ # start web
46
+ action_chain_4 = GtReq::ActionChain.new
47
+ action_chain_4.actionId = 10030
48
+ action_chain_4.type = GtReq::ActionChain::Type::Startweb
49
+ action_chain_4.url = url
50
+ action_chain_4.next = 100
51
+
52
+ # end
53
+ action_chain_5 = GtReq::ActionChain.new
54
+ action_chain_5.actionId = 100
55
+ action_chain_5.type = GtReq::ActionChain::Type::Eoa
56
+
57
+ [action_chain_1, action_chain_2, action_chain_3, action_chain_4, action_chain_5]
58
+ end
59
+
60
+ def get_push_type
61
+ "NotifyMsg"
62
+ end
63
+ end
64
+ end
@@ -18,49 +18,49 @@ module IGeTui
18
18
 
19
19
  def get_action_chain
20
20
  # set actionchain
21
- actionChain1 = GtReq::ActionChain.new
22
- actionChain1.actionId = 1
23
- actionChain1.type = GtReq::ActionChain::Type::Goto
24
- actionChain1.next = 10000
21
+ action_chain_1 = GtReq::ActionChain.new
22
+ action_chain_1.actionId = 1
23
+ action_chain_1.type = GtReq::ActionChain::Type::Goto
24
+ action_chain_1.next = 10000
25
25
 
26
26
  # notification
27
- actionChain2 = GtReq::ActionChain.new
28
- actionChain2.actionId = 10000
29
- actionChain2.type = GtReq::ActionChain::Type::Notification
30
- actionChain2.title = title
31
- actionChain2.text = text
32
- actionChain2.logo = logo
33
- actionChain2.logoURL = logo_url
34
- actionChain2.ring = is_ring
35
- actionChain2.clearable = is_clearable
36
- actionChain2.buzz = is_vibrate
37
- actionChain2.next = 10010
27
+ action_chain_2 = GtReq::ActionChain.new
28
+ action_chain_2.actionId = 10000
29
+ action_chain_2.type = GtReq::ActionChain::Type::Notification
30
+ action_chain_2.title = title
31
+ action_chain_2.text = text
32
+ action_chain_2.logo = logo
33
+ action_chain_2.logoURL = logo_url
34
+ action_chain_2.ring = is_ring
35
+ action_chain_2.clearable = is_clearable
36
+ action_chain_2.buzz = is_vibrate
37
+ action_chain_2.next = 10010
38
38
 
39
39
  # goto
40
- actionChain3 = GtReq::ActionChain.new
41
- actionChain3.actionId = 10010
42
- actionChain3.type = GtReq::ActionChain::Type::Goto
43
- actionChain3.next = 10030
40
+ action_chain_3 = GtReq::ActionChain.new
41
+ action_chain_3.actionId = 10010
42
+ action_chain_3.type = GtReq::ActionChain::Type::Goto
43
+ action_chain_3.next = 10030
44
44
 
45
45
  # appStartUp
46
- appStartUp = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
46
+ app_start_up = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
47
47
 
48
48
  # start web
49
- actionChain4 = GtReq::ActionChain.new
50
- actionChain4.actionId = 10030
51
- actionChain4.type = GtReq::ActionChain::Type::Startapp
52
- actionChain4.appid = ''
53
- actionChain4.autostart = @transmission_type == 1
54
- actionChain4.appstartupid = appStartUp
55
- actionChain4.failedAction = 100
56
- actionChain4.next = 100
49
+ action_chain_4 = GtReq::ActionChain.new
50
+ action_chain_4.actionId = 10030
51
+ action_chain_4.type = GtReq::ActionChain::Type::Startapp
52
+ action_chain_4.appid = ''
53
+ action_chain_4.autostart = @transmission_type == 1
54
+ action_chain_4.appstartupid = app_start_up
55
+ action_chain_4.failedAction = 100
56
+ action_chain_4.next = 100
57
57
 
58
58
  # end
59
- actionChain5 = GtReq::ActionChain.new
60
- actionChain5.actionId = 100
61
- actionChain5.type = GtReq::ActionChain::Type::Eoa
59
+ action_chain_5 = GtReq::ActionChain.new
60
+ action_chain_5.actionId = 100
61
+ action_chain_5.type = GtReq::ActionChain::Type::Eoa
62
62
 
63
- [actionChain1, actionChain2, actionChain3, actionChain4, actionChain5]
63
+ [action_chain_1, action_chain_2, action_chain_3, action_chain_4, action_chain_5]
64
64
  end
65
65
 
66
66
  def get_push_type
@@ -8,30 +8,30 @@ module IGeTui
8
8
 
9
9
  def get_action_chain
10
10
  # set actionChain
11
- actionChain1 = GtReq::ActionChain.new
12
- actionChain1.actionId = 1
13
- actionChain1.type = GtReq::ActionChain::Type::Goto
14
- actionChain1.next = 10030
11
+ action_chain_1 = GtReq::ActionChain.new
12
+ action_chain_1.actionId = 1
13
+ action_chain_1.type = GtReq::ActionChain::Type::Goto
14
+ action_chain_1.next = 10030
15
15
 
16
16
  # appStartUp
17
- appStartUp = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
17
+ app_start_up = GtReq::AppStartUp.new(android: '', symbia: '', ios: '')
18
18
 
19
19
  # start up app
20
- actionChain2 = GtReq::ActionChain.new
21
- actionChain2.actionId = 10030
22
- actionChain2.type = GtReq::ActionChain::Type::Startapp
23
- actionChain2.appid = ''
24
- actionChain2.autostart = transmission_type == 1
25
- actionChain2.appstartupid = appStartUp
26
- actionChain2.failedAction = 100
27
- actionChain2.next = 100
20
+ action_chain_2 = GtReq::ActionChain.new
21
+ action_chain_2.actionId = 10030
22
+ action_chain_2.type = GtReq::ActionChain::Type::Startapp
23
+ action_chain_2.appid = ''
24
+ action_chain_2.autostart = transmission_type == 1
25
+ action_chain_2.appstartupid = app_start_up
26
+ action_chain_2.failedAction = 100
27
+ action_chain_2.next = 100
28
28
 
29
29
  # end
30
- actionChain3 = GtReq::ActionChain.new
31
- actionChain3.actionId = 100
32
- actionChain3.type = GtReq::ActionChain::Type::Eoa
30
+ action_chain_3 = GtReq::ActionChain.new
31
+ action_chain_3.actionId = 100
32
+ action_chain_3.type = GtReq::ActionChain::Type::Eoa
33
33
 
34
- [actionChain1, actionChain2, actionChain3]
34
+ [action_chain_1, action_chain_2, action_chain_3]
35
35
  end
36
36
 
37
37
  def get_push_type
@@ -1,3 +1,4 @@
1
1
  require 'igetui/template/base_template'
2
2
  require 'igetui/template/transmission_template'
3
+ require 'igetui/template/link_template'
3
4
  require 'igetui/template/notification_template'
@@ -1,3 +1,3 @@
1
1
  module IGeTui
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/test/pusher_test.rb CHANGED
@@ -28,6 +28,13 @@ class PusherTest < MiniTest::Unit::TestCase
28
28
  assert_equal ret["result"], "ok"
29
29
  end
30
30
 
31
+ def test_to_single_link_notification
32
+ single_message = IGeTui::SingleMessage.new
33
+ single_message.data = link_template
34
+ ret = @pusher.push_message_to_single(single_message, @client_1)
35
+ assert_equal ret["result"], "ok"
36
+ end
37
+
31
38
  def test_to_single_transmission
32
39
  single_message = IGeTui::SingleMessage.new
33
40
  single_message.data = transmission_template
@@ -56,12 +63,23 @@ class PusherTest < MiniTest::Unit::TestCase
56
63
 
57
64
  private
58
65
 
59
- def notification_template
60
- template = IGeTui::NotificationTemplate.new
66
+ def set_template_base_info(template)
61
67
  template.logo = 'push.png'
62
68
  template.logo_url = 'http://www.igetui.com/wp-content/uploads/2013/08/logo_getui1.png'
63
69
  template.title = '测试标题'
64
70
  template.text = '测试文本'
71
+ end
72
+
73
+ def link_template
74
+ template = IGeTui::LinkTemplate.new
75
+ set_template_base_info(template)
76
+ template.url = "http://www.baidu.com"
77
+ template
78
+ end
79
+
80
+ def notification_template
81
+ template = IGeTui::NotificationTemplate.new
82
+ set_template_base_info(template)
65
83
  template
66
84
  end
67
85
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: igetui-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -114,6 +114,7 @@ extra_rdoc_files:
114
114
  files:
115
115
  - ".gitignore"
116
116
  - Gemfile
117
+ - LICENSE
117
118
  - LICENSE.txt
118
119
  - README.md
119
120
  - Rakefile
@@ -124,6 +125,7 @@ files:
124
125
  - lib/igetui/pusher.rb
125
126
  - lib/igetui/template.rb
126
127
  - lib/igetui/template/base_template.rb
128
+ - lib/igetui/template/link_template.rb
127
129
  - lib/igetui/template/notification_template.rb
128
130
  - lib/igetui/template/transmission_template.rb
129
131
  - lib/igetui/validate.rb