diff --git a/lib/beyond_api/connection.rb b/lib/beyond_api/connection.rb index a35360e..2d8c73c 100644 --- a/lib/beyond_api/connection.rb +++ b/lib/beyond_api/connection.rb @@ -8,24 +8,25 @@ module Connection def get(path, params = {}) parsed_response agent.get(path, params) end - + def post(path, body = {}, params = {}) - response = agent.post(path, body) do |request| - request.params = params + response = agent.post(path, body) do |request| + request.params = params + request.body = parsed_body(body) + end + parsed_response(response) end - parsed_response(response) - end - def delete(path, params = {}) - parsed_response agent.delete(path, params) - end + def delete(path, params = {}) + parsed_response agent.delete(path, params) + end private def parsed_response(response) Response.new(response).handle end - + def parsed_body(body) Utils.camelize_keys(body) end diff --git a/lib/beyond_api/services/authentication/signer.rb b/lib/beyond_api/services/authentication/signer.rb new file mode 100644 index 0000000..2e67b2d --- /dev/null +++ b/lib/beyond_api/services/authentication/signer.rb @@ -0,0 +1,17 @@ +module BeyondApi + module Authentication + class Signer < BaseService + def all(params = {}) + get("signers", params) + end + + def create + post("signers") + end + + def destroy(id) + delete("signers/#{id}") + end + end + end +end diff --git a/lib/beyond_api/services/webhook/subscription.rb b/lib/beyond_api/services/webhook/subscription.rb new file mode 100644 index 0000000..349f80f --- /dev/null +++ b/lib/beyond_api/services/webhook/subscription.rb @@ -0,0 +1,27 @@ +module BeyondApi + module Webhook + class Subscription < BaseService + def all(params = {}) + get("webhook-subscriptions", params) + end + + def create(body) + post("webhook-subscriptions", body) + end + + def delete_all + all.dig(:embedded, :subscriptions).each do |subscription| + destroy(subscription[:id]) + end + end + + def destroy(id) + delete("webhook-subscriptions/#{id}") + end + + def find(id) + get("webhook-subscriptions/#{id}") + end + end + end +end