Sha256: 08be3e32b092132d85cdca6d8151b41b5d27163e162cdcd7e16755070d37e26e
Contents?: true
Size: 1.22 KB
Versions: 13
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require_relative '../api_resource' module ErpIntegration module Fulfil module Resources class SalesOrder < 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 # 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
13 entries across 13 versions & 1 rubygems