Sha256: 2b88a90abe98efcdf6edbde9f2b0cbfb5cdec3c9f009c49219890f077480f0dc

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require_relative '../api_resource'

module ErpIntegration
  module Fulfil
    module Resources
      class CustomerShipmentReturn < ApiResource
        self.model_name = 'stock.shipment.out.return'

        def generate_shipping_label(id)
          client.put("model/#{model_name}/#{id}/generate_shipping_labels")
          true
        # 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

        def create_default_package(id)
          client.put("model/#{model_name}/#{id}/create_default_packages")
        end

        def create_package(id, options)
          client.put("model/#{model_name}/#{id}", options)
        end

        def receive!(id)
          client.put("model/#{model_name}/#{id}/receive")
          true
        rescue Faraday::ParsingError
          true
        end

        def mark_as_done!(id)
          client.put("model/#{model_name}/#{id}/done")
          true
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
erp_integration-0.57.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.56.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.55.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.54.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.53.1 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.53.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.52.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb
erp_integration-0.50.0 lib/erp_integration/fulfil/resources/customer_shipment_return.rb