Sha256: 1893a715548ee1c829202551172155d2abbed81f0acfb57f86b3ffbb1acff63a
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
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) begin client.put("model/sale.sale/#{id}/cancel") rescue Faraday::Error::ParsingError # 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. end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_integration-0.3.3 | lib/erp_integration/fulfil/resources/order.rb |