Class: JPush::PushClient
- Inherits:
-
Object
- Object
- JPush::PushClient
- Defined in:
- lib/jpush/push_client.rb
Constant Summary collapse
- @@PUSH_API_URL =
'https://api.jpush.cn/v3/push'- @@VALIDATE =
'/validate'- @@_timeToLive =
60 * 60 * 24
Instance Method Summary collapse
-
#initialize(maxRetryTimes) ⇒ PushClient
constructor
A new instance of PushClient.
- #sendPush(payload) ⇒ Object
-
#validate(payload) ⇒ Object
The API is used only to verify push call whether can succeed, lies in the difference with the push of API: not to send any message to user.
Constructor Details
#initialize(maxRetryTimes) ⇒ PushClient
Returns a new instance of PushClient.
15 16 17 |
# File 'lib/jpush/push_client.rb', line 15 def initialize(maxRetryTimes) @httpclient = JPush::NativeHttpClient.new(maxRetryTimes) end |
Instance Method Details
#sendPush(payload) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/jpush/push_client.rb', line 22 def sendPush(payload) json_data = JSON.generate(payload.toJSON) result = JPush::PushResult.new wrapper = @httpclient.sendPost(@@PUSH_API_URL, json_data) result.fromResponse(wrapper) return result end |
#validate(payload) ⇒ Object
The API is used only to verify push call whether can succeed, lies in the difference with the push of API: not to send any message to user.
35 36 37 38 39 40 41 |
# File 'lib/jpush/push_client.rb', line 35 def validate(payload) json_data = JSON.generate(payload.toJSON) result = JPush::PushResult.new wrapper = @httpclient.sendPost(@@PUSH_API_URL + @@VALIDATE, json_data) result.fromResponse(wrapper) return result end |