Class: Xfrtuc::Schedule
- Inherits:
-
ApiEndpoint
- Object
- ApiEndpoint
- Xfrtuc::Schedule
- Defined in:
- lib/xfrtuc.rb
Instance Method Summary collapse
- #create(opts) ⇒ Object
- #delete(id) ⇒ Object
- #info(id) ⇒ Object
-
#initialize(client) ⇒ Schedule
constructor
A new instance of Schedule.
- #list ⇒ Object
Constructor Details
#initialize(client) ⇒ Schedule
Returns a new instance of Schedule.
191 192 193 |
# File 'lib/xfrtuc.rb', line 191 def initialize(client) super end |
Instance Method Details
#create(opts) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/xfrtuc.rb', line 203 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
228 229 230 |
# File 'lib/xfrtuc.rb', line 228 def delete(id) client.delete("/schedules/#{CGI.escape(id)}") end |
#info(id) ⇒ Object
195 196 197 |
# File 'lib/xfrtuc.rb', line 195 def info(id) client.get("/schedules/#{id}") end |
#list ⇒ Object
199 200 201 |
# File 'lib/xfrtuc.rb', line 199 def list client.get("/schedules") end |