Sha256: 4b943b37b4b6dbf24701cacbaff9bd87da3705eb05f99ccf56e9dae1670627fb
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module ErpIntegration module Orders # The `FulfilOrder` handles all interaction with sales orders in Fulfil. class FulfilOrder extend Forwardable def_delegator 'ErpIntegration', :config # 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 private def client @client ||= Clients::FulfilClient.new( api_key: config.fulfil_api_key, merchant_id: config.fulfil_merchant_id ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_integration-0.2.0 | lib/erp_integration/orders/fulfil_order.rb |