Class: Gemgento::API::SOAP::Sales::OrderShipment

Inherits:
Object
  • Object
show all
Defined in:
lib/gemgento/api/soap/sales/order_shipment.rb

Class Method Summary collapse

Class Method Details

.add_comment(shipment_comment, email = nil, include_in_email = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 7

def self.add_comment(shipment_comment, email = nil, include_in_email = nil)
  message = {
      shipment_increment_id: shipment_comment.shipment.increment_id,
      comment: shipment_comment.comment,
      email: email,
      include_in_email: include_in_email
  }
  response = MagentoApi.create_call(:sales_order_shipment_add_comment, message)

  return response.success?
end

.add_track(shipment_track) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 19

def self.add_track(shipment_track)
  message = {
      shipment_increment_id: shipment_track.shipment.increment_id,
      carrier: shipment_track.carrier_code,
      title: shipment_track.title,
      track_number: shipment_track.number
  }
  response = MagentoApi.create_call(:sales_order_shipment_add_track, message)

  return response.success?
end

.create(shipment) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 31

def self.create(shipment)
  message = {
      order_increment_id: shipment.order.increment_id,
      email: shipment.email ? 1 : 0,
      comment: shipment.comment,
      include_comment: shipment.include_comment ? 1 : 0
  }

  if shipment.shipment_items.any?
    message[:items_qty] = { item: compose_items_qty(shipment.shipment_items) }
  end

  response = MagentoApi.create_call(:sales_order_shipment_create, message)

  if response.success?
    return response.body[:shipment_increment_id]
  else
    return false
  end
end

.get_carriers(order_increment_id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 52

def self.get_carriers(order_increment_id)
  message = {
      order_increment_id: order_increment_id,
  }
  response = MagentoApi.create_call(:sales_order_shipment_get_carriers, message)

  if response.success?
    if response.body[:result][:item].nil?
      return response.body[:result]
    else
      response.body[:result][:item]
    end
  else
    return false
  end
end

.info(shipment_increment_id) ⇒ Object



69
70
71
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 69

def self.info(shipment_increment_id)
  MagentoApi.create_call(:sales_order_shipment_info, shipment_increment_id: shipment_increment_id)
end

.listObject



73
74
75
76
77
78
79
80
81
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 73

def self.list
  response = MagentoApi.create_call(:sales_order_shipment_list)

  if response.success?
    return response.body[:result]
  else
    return false
  end
end

.remove_track(shipment_increment_id, track_id) ⇒ Object



83
84
85
86
87
88
89
90
91
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 83

def self.remove_track(shipment_increment_id, track_id)
  message = {
      shipment_increment_id: shipment_increment_id,
      track_id: track_id
  }
  response = MagentoApi.create_call(:sales_order_shipment_remove_track, message)

  return response.success?
end

.send_info(shipment_increment_id, comment = '') ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/gemgento/api/soap/sales/order_shipment.rb', line 93

def self.send_info(shipment_increment_id, comment = '')
  message = {
      shipment_increment_id: shipment_increment_id,
      comment: comment
  }
  response = MagentoApi.create_call(:sales_order_shipment_send_info, message)

  return response.success?
end