Class: UmengMsg::Subject
- Inherits:
-
Object
- Object
- UmengMsg::Subject
- Defined in:
- lib/umeng_msg/subject.rb
Constant Summary collapse
- CAST_TYPE =
%w|unicast listcast filecast broadcast groupcast customizedcast|
- PUSH_URL =
'http://msg.umeng.com/api/send'- CHECK_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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#file_id ⇒ Object
readonly
Returns the value of attribute file_id.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#ret ⇒ Object
readonly
Returns the value of attribute ret.
-
#task_id ⇒ Object
readonly
Returns the value of attribute task_id.
Instance Method Summary collapse
- #cancel ⇒ Object
- #check ⇒ Object
-
#initialize(platform, **options) ⇒ Subject
constructor
A new instance of Subject.
- #push ⇒ Object
- #upload ⇒ Object
Constructor Details
#initialize(platform, **options) ⇒ Subject
Returns a new instance of Subject.
13 14 15 16 17 18 19 20 |
# File 'lib/umeng_msg/subject.rb', line 13 def initialize(platform, **) @platform = platform @payload = Params.push_params(platform, **) @content = ['content'] @file_id, @task_id = nil @ret = { push: nil, check: nil, cancel: nil, upload: nil } @error_code = { push: nil, check: nil, cancel: nil, upload: nil } end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def content @content end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def error_code @error_code end |
#file_id ⇒ Object (readonly)
Returns the value of attribute file_id.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def file_id @file_id end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def payload @payload end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def platform @platform end |
#ret ⇒ Object (readonly)
Returns the value of attribute ret.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def ret @ret end |
#task_id ⇒ Object (readonly)
Returns the value of attribute task_id.
6 7 8 |
# File 'lib/umeng_msg/subject.rb', line 6 def task_id @task_id end |
Instance Method Details
#cancel ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/umeng_msg/subject.rb', line 41 def cancel @cancel_payload = Params.cancel_params(@platform, @task_id) sign = Sign.generate @platform, CANCEL_URL, @cancel_payload begin parse_res RestClient.post("#{CANCEL_URL}?sign=#{sign}", @cancel_payload.to_json, content_type: :json, accept: :json) rescue => e parse_res e.response end end |
#check ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/umeng_msg/subject.rb', line 31 def check @check_payload = Params.check_params(@platform, @task_id) sign = Sign.generate @platform, CHECK_URL, @check_payload begin parse_res RestClient.post("#{CHECK_URL}?sign=#{sign}", @check_payload.to_json, content_type: :json, accept: :json) rescue => e parse_res e.response end end |
#push ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/umeng_msg/subject.rb', line 22 def push sign = Sign.generate @platform, PUSH_URL, @payload begin parse_res RestClient.post("#{PUSH_URL}?sign=#{sign}", @payload.to_json, content_type: :json, accept: :json) rescue => e parse_res e.response end end |
#upload ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/umeng_msg/subject.rb', line 51 def upload @upload_payload = Params.upload_params(@platform, @content) sign = Sign.generate @platform, CANCEL_URL, @upload_payload begin parse_res RestClient.post("#{UPLOAD_URL}?sign=#{sign}", @upload_payload.to_json, content_type: :json, accept: :json) rescue => e parse_res e.response end end |