Sha256: 8caed0a4852eda1b495019037111297fe535380b6e670e6c747f89c4fd1087bf

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

# frozen_string_literal: true

require_relative "client"
require_relative "object"

module Mergent
  class Schedule < Mergent::Object
    ATTRS = %i[id queue cron rrule dtstart type description request created_at].freeze

    ATTRS.each do |name|
      define_method(name) do
        @_data[name]
      end
    end

    def self.create(params = {})
      data = Client.post(
        "schedules",
        { queue: Mergent::Object::DEFAULT_QUEUE }.merge(params)
      )
      new(data)
    end

    def self.update(id, params)
      data = Client.patch("schedules/#{id}", params)
      new(data)
    end

    def self.delete(id)
      Client.delete("schedules/#{id}")
      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mergent-1.0.0 lib/mergent/schedule.rb