class RDStation::Webhooks
Public Class Methods
new(authorization:)
click to toggle source
# File lib/rdstation/webhooks.rb, line 6 def initialize(authorization:) @authorization = authorization end
Public Instance Methods
all()
click to toggle source
# File lib/rdstation/webhooks.rb, line 10 def all retryable_request(@authorization) do |authorization| response = self.class.get(base_url, headers: authorization.headers) ApiResponse.build(response) end end
by_uuid(uuid)
click to toggle source
# File lib/rdstation/webhooks.rb, line 17 def by_uuid(uuid) retryable_request(@authorization) do |authorization| response = self.class.get(base_url(uuid), headers: authorization.headers) ApiResponse.build(response) end end
create(payload)
click to toggle source
# File lib/rdstation/webhooks.rb, line 24 def create(payload) retryable_request(@authorization) do |authorization| response = self.class.post(base_url, headers: authorization.headers, body: payload.to_json) ApiResponse.build(response) end end
delete(uuid)
click to toggle source
# File lib/rdstation/webhooks.rb, line 38 def delete(uuid) retryable_request(@authorization) do |authorization| response = self.class.delete(base_url(uuid), headers: authorization.headers) return webhook_deleted_message unless response.body RDStation::ErrorHandler.new(response).raise_error end end
update(uuid, payload)
click to toggle source
# File lib/rdstation/webhooks.rb, line 31 def update(uuid, payload) retryable_request(@authorization) do |authorization| response = self.class.put(base_url(uuid), headers: authorization.headers, body: payload.to_json) ApiResponse.build(response) end end
Private Instance Methods
base_url(path = '')
click to toggle source
# File lib/rdstation/webhooks.rb, line 53 def base_url(path = '') "https://api.rd.services/integrations/webhooks/#{path}" end
webhook_deleted_message()
click to toggle source
# File lib/rdstation/webhooks.rb, line 49 def webhook_deleted_message { message: 'Webhook deleted successfuly!' } end