Sha256: f06671c27ea5b801c770d20c2395d17fe476d5146bbf656e9d67c6b4da21bd88
Contents?: true
Size: 1.56 KB
Versions: 6
Compression:
Stored size: 1.56 KB
Contents
module RDStation class Webhooks include HTTParty include ::RDStation::RetryableRequest def initialize(authorization:) @authorization = authorization end def all retryable_request(@authorization) do |authorization| response = self.class.get(base_url, headers: authorization.headers) ApiResponse.build(response) end end def by_uuid(uuid) retryable_request(@authorization) do |authorization| response = self.class.get(base_url(uuid), headers: authorization.headers) ApiResponse.build(response) end end 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 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 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 private def webhook_deleted_message { message: 'Webhook deleted successfuly!' } end def base_url(path = '') "https://api.rd.services/integrations/webhooks/#{path}" end end end
Version data entries
6 entries across 6 versions & 1 rubygems