class JPush::Report
Constants
- MAX_DURATION
- TIME_FORMAT
- TIME_UNIT
Public Instance Methods
messages(msg_ids)
click to toggle source
GET /v3/messages 消息统计
# File lib/jpush/report.rb, line 51 def messages(msg_ids) msg_ids = [msg_ids].flatten url = base_url + '/messages' params = { msg_ids: msg_ids.join(',') } Http::Client.get(@jpush, url, params: params) end
messages_detail(msg_ids)
click to toggle source
GET /v3/messages/detail 消息统计详情(VIP 专属接口,新) docs.jiguang.cn/jpush/server/push/rest_api_v3_report/#vip_1
# File lib/jpush/report.rb, line 63 def messages_detail(msg_ids) msg_ids = [msg_ids].flatten url = base_url + '/messages/detail' params = { msg_ids: msg_ids.join(',') } Http::Client.get(@jpush, url, params: params) end
received(msg_ids)
click to toggle source
GET /v3/received 送达统计
# File lib/jpush/report.rb, line 13 def received(msg_ids) msg_ids = [msg_ids].flatten url = base_url + '/received' params = { msg_ids: msg_ids.join(',') } Http::Client.get(@jpush, url, params: params) end
received_detail(msg_ids)
click to toggle source
GET /v3/received/detail 送达统计 docs.jiguang.cn/jpush/server/push/rest_api_v3_report/#_7
# File lib/jpush/report.rb, line 25 def received_detail(msg_ids) msg_ids = [msg_ids].flatten url = base_url + '/received/detail' params = { msg_ids: msg_ids.join(',') } Http::Client.get(@jpush, url, params: params) end
status_message(msg_id: , registration_ids: , date: nil)
click to toggle source
GET /v3/status/message 送达状态查询 Status API 用于查询已推送的一条消息在一组设备上的送达状态。 docs.jiguang.cn/jpush/server/push/rest_api_v3_report/#_11
# File lib/jpush/report.rb, line 38 def status_message(msg_id: , registration_ids: , date: nil) registration_ids = [registration_ids].flatten url = base_url + 'status/message' body = { msg_id: msg_id.to_i, registration_ids: registration_ids, date: date }.select { |_, value| !value.nil? } Http::Client.post(@jpush, url, body: body) end
users(time_unit, start, duration)
click to toggle source
GET /v3/users 用户统计
# File lib/jpush/report.rb, line 74 def users(time_unit, start, duration) start = start.strftime(TIME_FORMAT[time_unit.downcase.to_sym]) duration = build_duration(time_unit.downcase.to_sym, duration) params = { time_unit: time_unit.upcase, start: start, duration: duration } url = base_url + '/users' Http::Client.get(@jpush, url, params: params) end
Private Instance Methods
base_url()
click to toggle source
# File lib/jpush/report.rb, line 88 def base_url 'https://report.jpush.cn/v3/' end
build_duration(time_unit, duration)
click to toggle source
# File lib/jpush/report.rb, line 92 def build_duration(time_unit, duration) return 1 if duration < 0 duration > MAX_DURATION[time_unit] ? MAX_DURATION[time_unit] : duration end