Class: Xfrtuc::Schedule

Inherits:
ApiEndpoint show all
Defined in:
lib/xfrtuc.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Schedule

Returns a new instance of Schedule.



140
# File 'lib/xfrtuc.rb', line 140

def initialize(client); super; end

Instance Method Details

#create(opts) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/xfrtuc.rb', line 150

def create(opts)
  name = opts.fetch :name
  callback_url = opts.fetch :callback_url
  hour = opts.fetch :hour
  days = opts.fetch(:days, Date::DAYNAMES)
  timezone = opts.fetch(:timezone, 'UTC')
  retain_weeks = opts.delete(:retain_weeks)
  retain_months = opts.delete(:retain_months)

  [ :name, :callback_url, :hour, :days, :timezone ].each { |key| opts.delete key }
  unless opts.empty?
    raise ArgumentError, "Unsupported option(s): #{opts.keys}"
  end

  sched_opts = { name: name,
                 callback_url: callback_url,
                 hour: hour,
                 days: days,
                 timezone: timezone }
  sched_opts[:retain_weeks] = retain_weeks unless retain_weeks.nil?
  sched_opts[:retain_months] = retain_months unless retain_months.nil?

  client.put("/schedules", sched_opts)
end

#delete(id) ⇒ Object



175
176
177
# File 'lib/xfrtuc.rb', line 175

def delete(id)
  client.delete("/schedules/#{URI.encode(id)}")
end

#info(id) ⇒ Object



142
143
144
# File 'lib/xfrtuc.rb', line 142

def info(id)
  client.get("/schedules/#{id}")
end

#listObject



146
147
148
# File 'lib/xfrtuc.rb', line 146

def list
  client.get("/schedules")
end