Sha256: dfab9fcbbf53d9ca58181454096f72bfc2f54129d20e0b948a54152da35c29fa

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module Crowdin
  module ApiResources
    module Webhooks
      def list_webhooks(query = {}, project_id = config.project_id)
        project_id || raise_project_id_is_required_error

        request = Web::Request.new(
          self,
          :get,
          "/projects/#{project_id}/webhooks",
          query
        )

        request.perform
      end

      def add_webhook(query = {}, project_id = config.project_id)
        project_id || raise_project_id_is_required_error

        request = Web::Request.new(
          self,
          :post,
          "/projects/#{project_id}/webhooks",
          query
        )

        request.perform
      end

      def get_webhook(webhook_id = nil, project_id = config.project_id)
        webhook_id || raise_parameter_is_required_error(:webhook_id)
        project_id || raise_project_id_is_required_error

        request = Web::Request.new(
          self,
          :get,
          "/projects/#{project_id}/webhooks/#{webhook_id}"
        )

        request.perform
      end

      def delete_webhook(webhook_id = nil, project_id = config.project_id)
        webhook_id || raise_parameter_is_required_error(:webhook_id)
        project_id || raise_project_id_is_required_error

        request = Web::Request.new(
          self,
          :delete,
          "/projects/#{project_id}/webhooks/#{webhook_id}"
        )

        request.perform
      end

      def edit_screenshot(webhook_id = nil, query = {}, project_id = config.project_id)
        webhook_id || raise_parameter_is_required_error(:webhook_id)
        project_id || raise_project_id_is_required_error

        request = Web::Request.new(
          self,
          :patch,
          "/projects/#{project_id}/webhooks/#{webhook_id}",
          query
        )

        request.perform
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
crowdin-api-1.2.1 lib/crowdin-api/api-resources/webhooks.rb
crowdin-api-1.2.0 lib/crowdin-api/api-resources/webhooks.rb