Class: UmengPusher::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/umeng_pusher/client.rb

Constant Summary collapse

CAST_TYPE =
%w|unicast listcast filecast broadcast groupcast customizedcast|
SEND_URL =
"http://msg.umeng.com/api/send"
STATUS_URL =
"http://msg.umeng.com/api/status"
CANCEL_URL =
"http://msg.umeng.com/api/cancel"
UPLOAD_URL =
"http://msg.umeng.com/upload"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform, options, debug_mode = true) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/umeng_pusher/client.rb', line 14

def initialize(platform, options, debug_mode = true)
  @platform = platform
  @options = options
  @debug_mode = debug_mode
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def content
  @content
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def error_code
  @error_code
end

#file_idObject (readonly)

Returns the value of attribute file_id.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def file_id
  @file_id
end

#payloadObject (readonly)

Returns the value of attribute payload.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def payload
  @payload
end

#platformObject (readonly)

Returns the value of attribute platform.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def platform
  @platform
end

#retObject (readonly)

Returns the value of attribute ret.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def ret
  @ret
end

#task_idObject (readonly)

Returns the value of attribute task_id.



7
8
9
# File 'lib/umeng_pusher/client.rb', line 7

def task_id
  @task_id
end

Instance Method Details

#cancelObject



36
37
38
# File 'lib/umeng_pusher/client.rb', line 36

def cancel
  post(CANCEL_URL, Params.cancel_params(@platform, @options[:task_id]))
end

#sendObject

unicast-单播 listcast-列播,要求不超过500个device_token broadcast-广播 filecast-文件播,多个device_token可通过文件形式批量发送 groupcast-组播,按照filter筛选用户群,请参照filter参数 customizedcast,通过alias进行推送,包括以下两种case:

-alias:对单个或者多个alias进行推送
-file_id:将alias存放到文件后,根据file_id来推送


28
29
30
# File 'lib/umeng_pusher/client.rb', line 28

def send
  post(SEND_URL, Params.send_params(@platform, @options))
end

#statusObject



32
33
34
# File 'lib/umeng_pusher/client.rb', line 32

def status
  post(STATUS_URL, Params.status_params(@platform, @options[:task_id]))
end

#uploadObject



40
41
42
# File 'lib/umeng_pusher/client.rb', line 40

def upload
  post(UPLOAD_URL, Params.upload_params(@platform, @options))
end