Class: IGeTui::Pusher
- Inherits:
-
Object
- Object
- IGeTui::Pusher
- Defined in:
- lib/igetui/pusher.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_key ⇒ Object
readonly
Returns the value of attribute app_key.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#master_secret ⇒ Object
readonly
Returns the value of attribute master_secret.
Instance Method Summary collapse
- #cancel_content_id(content_id) ⇒ Object
- #get_client_id_status(client_id) ⇒ Object
- #get_content_id(message) ⇒ Object
-
#initialize(host, app_id, app_key, master_secret) ⇒ Pusher
constructor
A new instance of Pusher.
- #push_message_to_app(message) ⇒ Object
- #push_message_to_list(content_id, clients) ⇒ Object
- #push_message_to_single(message, client) ⇒ Object
- #stop(content_id) ⇒ Object
Constructor Details
#initialize(host, app_id, app_key, master_secret) ⇒ Pusher
Returns a new instance of Pusher.
5 6 7 8 9 10 |
# File 'lib/igetui/pusher.rb', line 5 def initialize(host, app_id, app_key, master_secret) @host = host @app_id = app_id @app_key = app_key @master_secret = master_secret end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
3 4 5 |
# File 'lib/igetui/pusher.rb', line 3 def app_id @app_id end |
#app_key ⇒ Object (readonly)
Returns the value of attribute app_key.
3 4 5 |
# File 'lib/igetui/pusher.rb', line 3 def app_key @app_key end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/igetui/pusher.rb', line 3 def host @host end |
#master_secret ⇒ Object (readonly)
Returns the value of attribute master_secret.
3 4 5 |
# File 'lib/igetui/pusher.rb', line 3 def master_secret @master_secret end |
Instance Method Details
#cancel_content_id(content_id) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/igetui/pusher.rb', line 104 def cancel_content_id(content_id) data = { 'action' => 'cancleContentIdAction', 'contentId' => content_id, } ret = http_post_json(data) ret['result'] == 'ok' end |
#get_client_id_status(client_id) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/igetui/pusher.rb', line 78 def get_client_id_status(client_id) data = { 'action' => 'getClientIdStatusAction', 'appkey' => app_key, 'appId' => app_id, 'clientId' => client_id } http_post_json(data) end |
#get_content_id(message) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/igetui/pusher.rb', line 89 def get_content_id() template = .data data = { 'action' => 'getContentIdAction', 'appkey' => app_key, 'clientData' => template.get_client_data(self), 'transmissionContent' => template.transmission_content, 'isOffline' => .is_offline, 'offlineExpireTime' => .offline_expire_time, 'pushType' => template.get_push_type } ret = http_post_json(data) ret['result'] == 'ok' ? ret['contentId'] : '' end |
#push_message_to_app(message) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/igetui/pusher.rb', line 48 def () template = .data data = { 'action' => 'pushMessageToAppAction', 'appkey' => app_key, 'clientData' => template.get_client_data(self), 'transmissionContent' => template.transmission_content, 'isOffline' => .is_offline, 'offlineExpireTime' => .offline_expire_time, 'appIdList' => .app_id_list, 'phoneTypeList' => .phone_type_list, 'provinceList' => .province_list, 'tagList' => .tag_list, 'type' => 2, 'pushType' => template.get_push_type } http_post_json(data) end |
#push_message_to_list(content_id, clients) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/igetui/pusher.rb', line 30 def (content_id, clients) target_list = clients.inject([]) do |list, cilent| list << { 'appId' => app_id, 'clientId' => cilent.client_id } end # seems that we miss 'pushType' data = { 'action' => 'pushMessageToListAction', 'appkey' => app_key, 'contentId' => content_id, 'needDetails' => true, 'targetList' => target_list, 'type' => 2 } http_post_json(data) end |
#push_message_to_single(message, client) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/igetui/pusher.rb', line 12 def (, client) template = .data data = { 'action' => 'pushMessageToSingleAction', 'appkey' => app_key, 'clientData' => template.get_client_data(self), 'transmissionContent' => template.transmission_content, 'isOffline' => .is_offline, 'offlineExpireTime' => .offline_expire_time, 'appId' => app_id, 'clientId' => client.client_id, 'type' => 2, #default is message 'pushType' => template.get_push_type } http_post_json(data) end |
#stop(content_id) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/igetui/pusher.rb', line 67 def stop(content_id) data = { 'action' => 'stopTaskAction', 'appkey' => @appKey, 'contentId' => content_id } ret = http_post_json(data) ret['result'] == 'ok' end |