Class: Magento::Shipment

Inherits:
Base
  • Object
show all
Defined in:
lib/magento/shipment.rb

Overview

www.magentocommerce.com/wiki/doc/webservices-api/api/sales_order_shipment 100 Requested shipment not exists. 101 Invalid filters given. Details in error message. 102 Invalid data given. Details in error message. 103 Requested order not exists. 104 Requested tracking not exists. 105 Tracking not deleted. Details in error message.

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods included from Base::ClassMethods

#api_path, #commit

Methods included from Base::InstanceMethods

#id, #id=, #initialize, #method_missing, #object_attributes=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods

Class Method Details

.add_comment(*args) ⇒ Object

sales_order_shipment.addComment Add new comment to shipment

Return: boolean

Arguments:

string shipmentIncrementId - shipment increment id string comment - shipment comment boolean email - send e-mail flag (optional) boolean includeInEmail - include comment in e-mail flag (optional)



67
68
69
# File 'lib/magento/shipment.rb', line 67

def add_comment(*args)
  commit('addComment', *args)
end

.add_track(*args) ⇒ Object

sales_order_shipment.addTrack Add new tracking number

Return: int

Arguments:

string shipmentIncrementId - shipment increment id string carrier - carrier code string title - tracking title string trackNumber - tracking number



82
83
84
# File 'lib/magento/shipment.rb', line 82

def add_track(*args)
  commit('addTrack', *args)
end

.api_pathObject



132
133
134
# File 'lib/magento/shipment.rb', line 132

def api_path
  "order_shipment"
end

.create(*args) ⇒ Object

sales_order_shipment.create Create new shipment for order

Return: string - shipment increment id

Arguments:

string orderIncrementId - order increment id array itemsQty - items qty to ship as associative array (order_item_id ⇒ qty) string comment - shipment comment (optional) boolean email - send e-mail flag (optional) boolean includeComment - include comment in e-mail flag (optional)



50
51
52
53
54
# File 'lib/magento/shipment.rb', line 50

def create(*args)
  id = commit("create", *args)
  record = info(id)
  record
end

.find(find_type, options = {}) ⇒ Object

Raises:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/magento/shipment.rb', line 115

def find(find_type, options = {})
  filters = {}
  options.each_pair { |k, v| filters[k] = {:eq => v} }
  results = list(filters)
  
  raise Magento::ApiError, "100  Requested shipment not exists." if results.blank?
  
  if find_type == :first
    info(results.first.increment_id)
  else
    results.collect do |s|
      info(s.increment_id)
    end
  end
  
end

.find_by_id(id) ⇒ Object



111
112
113
# File 'lib/magento/shipment.rb', line 111

def find_by_id(id)
  info(id)
end

.get_carriers(*args) ⇒ Object

sales_order_shipment.getCarriers Retrieve list of allowed carriers for order

Return: array

Arguments:

string orderIncrementId - order increment id



107
108
109
# File 'lib/magento/shipment.rb', line 107

def get_carriers(*args)
  commit('getCarriers', *args)
end

.info(*args) ⇒ Object

sales_order_shipment.info Retrieve shipment information

Return: array

Arguments:

string shipmentIncrementId - order shipment increment id



34
35
36
# File 'lib/magento/shipment.rb', line 34

def info(*args)
  new(commit("info", *args))
end

.list(*args) ⇒ Object

sales_order_shipment.list Retrieve list of shipments by filters

Return: array

Arguments:

array filters - filters for shipments list



19
20
21
22
23
24
# File 'lib/magento/shipment.rb', line 19

def list(*args)
  results = commit("list", *args)
  results.collect do |result|
    new(result)
  end
end

.remove_track(*args) ⇒ Object

sales_order_shipment.removeTrack Remove tracking number

Return: boolean

Arguments:

string shipmentIncrementId - shipment increment id int trackId - track id



95
96
97
# File 'lib/magento/shipment.rb', line 95

def remove_track(*args)
  commit('removeTrack', *args)
end