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.



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

def initialize(client); super; end

Instance Method Details

#create(opts) ⇒ Object



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

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/#{CGI.escape(name)}", sched_opts)
end

#delete(id) ⇒ Object



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

def delete(id)
  client.delete("/schedules/#{CGI.escape(id)}")
end

#info(id) ⇒ Object



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

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

#listObject



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

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