Sha256: 9446fa0feb10d777bf8d9a6b0ed14c96965e67da70ea0dd9b699e7cfda4ebc48

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

module SpreeClient
  module API
    class V1
      # Stock Locations
      # @see SpreeClient::API:V1::Resource
      class StockLocations < Resources
        ENDPOINT = '/api/v1/stock_locations'
        RESOURCE = SpreeClient::Models::StockLocation
        NAME     = 'stock_location'

        # @return [SpreeClient::API::V1::StockMovements]
        def stock_movements(**args)
          stock_location_id = default_args.dig(:id) || args.dig(:stock_location_id)

          raise ArgumentError, 'Needs a stock location ID' unless stock_location_id

          @stock_movements ||= {}
          @stock_movements[stock_location_id.to_s.to_sym] ||= StockMovements.new **{ api: api, stock_location_id: stock_location_id }.merge(args)
        end

        # @return [SpreeClient::API::V1::StockItems]
        def stock_items(**args)
          stock_location_id = default_args.dig(:id) || args.dig(:stock_location_id)

          raise ArgumentError, 'Needs a stock location ID' unless stock_location_id

          @stock_items ||= {}
          @stock_items[stock_location_id.to_s.to_sym] ||= StockItems.new **{ api: api, stock_location_id: stock_location_id }.merge(args)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree-api-client-0.2.5 lib/spree_client/api/v1/stock_locations.rb
spree-api-client-0.2.4 lib/spree_client/api/v1/stock_locations.rb
spree-api-client-0.2.3 lib/spree_client/api/v1/stock_locations.rb
spree-api-client-0.2.2 lib/spree_client/api/v1/stock_locations.rb
spree-api-client-0.2.1 lib/spree_client/api/v1/stock_locations.rb