Sha256: 21918ca9251ce7abb8a6f0cf26e9d88bb0eab7915f6943b4cde1da3d2a300d7d

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

require_relative '../api_resource'

module ErpIntegration
  module Fulfil
    module Resources
      class Order < ApiResource
        self.model_name = 'sale.sale'

        # Allows cancelling the entire sales order in Fulfil.
        # @param id [Integer|String] The ID of the to be cancelled order.
        # @return [boolean] Whether the sales order was cancelled successfully or not.
        def cancel(id)
          client.put("model/sale.sale/#{id}/cancel")
          true

        # Fulfil will return an 400 (a.k.a. "Bad Request") status code when a sales order couldn't
        # be cancelled. If a sales order isn't cancellable by design, no exception should be raised.
        #
        # See the Fulfil's documentation for more information:
        # https://developers.fulfil.io/rest_api/model/sale.sale/#cancel-a-sales-order
        rescue ErpIntegration::HttpError::BadRequest
          false
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
erp_integration-0.3.2 lib/erp_integration/fulfil/resources/order.rb
erp_integration-0.3.1 lib/erp_integration/fulfil/resources/order.rb
erp_integration-0.3.0 lib/erp_integration/fulfil/resources/order.rb