# 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