Sha256: 86cdd6638ee3512a3c9547bcef6032662e755add9b22c7a48ed41c0f4f76ef5a
Contents?: true
Size: 1.62 KB
Versions: 8
Compression:
Stored size: 1.62 KB
Contents
module Nova module API module Resource class Webhook < Nova::API::Base ALLOWED_ATTRIBUTES = %i[events url] attribute? :id, Dry::Types['coercible.integer'].optional attribute :events, Dry::Types['strict.array'].of(Dry::Types['coercible.string']) attribute :url, Dry::Types['coercible.string'] def self.endpoint '/api/webhooks' end def self.create(parameters) model = new parameters model.attributes.delete(:id) model.save end def self.update(id, parameters) model = new parameters.merge(id: id) model.update end def self.destroy(id) model = initialize_empty_model_with_id(self, id, events: []) model.destroy end def self.restore(id) model = initialize_empty_model_with_id(self, id, events: []) model.restore end def endpoint protect_operation_from_missing_value "/api/webhooks/#{id}" end def save if id.nil? do_post(self.class.endpoint, allowed_attributes) else do_patch("#{endpoint}", allowed_attributes) end end def update protect_operation_from_missing_value do_patch("#{endpoint}", allowed_attributes) end def destroy protect_operation_from_missing_value do_delete("#{endpoint}") end def restore protect_operation_from_missing_value do_patch("#{endpoint}/restore", {}) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems