Sha256: 01038a5d4b8e88351b14708ef38c6986804a1b4e6dfa27c23ad3566724a65514

Contents?: true

Size: 1.47 KB

Versions: 46

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

require_relative '../api_resource'

module ErpIntegration
  module Fulfil
    module Resources
      class Webhook < ApiResource
        self.model_name = 'ir.webhook'

        # Archives the webhook with the given ID.
        # @param id [Integer] The ID of the webhook to archive.
        # @return [Boolean] Whether the webhook was archived successfully or not.
        def archive(id)
          client.put("model/#{model_name}/archive", [[id]])
          true
        rescue ErpIntegration::HttpError::BadRequest
          false
        # Workaround: Fulfil api does not return a json when status code is 200
        # (a.k.a. "Ok") and faraday is having an error when trying to parse it.
        # Let's skip the parse error and move on.
        rescue Faraday::ParsingError
          true
        end

        # Restores the webhook with the given ID.
        # @param id [Integer] The ID of the webhook to be restored.
        # @return [Boolean] Whether the webhook was restored successfully or not.
        def restore(id)
          client.put("model/#{model_name}/restore", [[id]])
          true
        rescue ErpIntegration::HttpError::BadRequest
          false
        # Workaround: Fulfil api does not return a json when status code is 200
        # (a.k.a. "Ok") and faraday is having an error when trying to parse it.
        # Let's skip the parse error and move on.
        rescue Faraday::ParsingError
          true
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
erp_integration-0.61.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.58.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.60.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.59.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.57.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.56.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.55.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.54.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.53.1 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.53.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.52.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.50.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.49.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.48.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.43.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.42.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.41.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.40.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.39.0 lib/erp_integration/fulfil/resources/webhook.rb
erp_integration-0.38.0 lib/erp_integration/fulfil/resources/webhook.rb