Class: Xiaomi::Push::Services::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/xiaomi/push/services/job.rb

Overview

定时任务类 API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Job

Returns a new instance of Job.



12
13
14
# File 'lib/xiaomi/push/services/job.rb', line 12

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextClient

Returns the current value of context.

Returns:

  • (Client)

    the current value of context



9
10
11
# File 'lib/xiaomi/push/services/job.rb', line 9

def context
  @context
end

Instance Method Details

#destory(job_id) ⇒ Hash

删除定时任务

Parameters:

  • job_id (String)

    任务 id

Returns:

  • (Hash)

    小米返回数据结构



29
30
31
32
# File 'lib/xiaomi/push/services/job.rb', line 29

def destory(job_id)
  url = @context.build_uri('schedule_job/delete')
  @context.post(url, { job_id: job_id })
end

#exist?(job_id) ⇒ Hash

检测定时任务是否存在

Parameters:

  • job_id (String)

    任务 id

Returns:

  • (Hash)

    小米返回数据结构



20
21
22
23
# File 'lib/xiaomi/push/services/job.rb', line 20

def exist?(job_id)
  url = @context.build_uri('schedule_job/exist')
  @context.post(url, { job_id: job_id })
end