Class: ChannelAdvisor::Services::InventoryService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/channeladvisor/services/inventory_service.rb

Class Method Summary collapse

Class Method Details

.pingObject


7
8
9
10
11
# File 'lib/channeladvisor/services/inventory_service.rb', line 7

def ping
  client.request :ping do
    soap.header = soap_header
  end
end

.update_inventory_item_quantity_and_price(item_info) ⇒ Object

ping


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/channeladvisor/services/inventory_service.rb', line 13

def update_inventory_item_quantity_and_price(item_info)
  soap_body = {
    "ins0:accountID" => creds(:account_id),
    "ins0:itemQuantityAndPrice" => {
      "ins0:Sku" => item_info[:sku]
    }
  }

  item_quantity_and_price = soap_body["ins0:itemQuantityAndPrice"]

  if quantity_info = item_info[:quantity_info]
    item_quantity_and_price["ins0:QuantityInfo"] = {
      "ins0:UpdateType" => quantity_info[:update_type],
      "ins0:Total"      => quantity_info[:total]
    }
  end

  if price_info = item_info[:price_info]
    item_quantity_and_price["ins0:PriceInfo"] = {
      "ins0:Cost"                   => price_info[:cost],
      "ins0:RetailPrice"            => price_info[:retail_price],
      "ins0:StartingPrice"          => price_info[:starting_price],
      "ins0:ReservePrice"           => price_info[:reserve_price],
      "ins0:TakeItPrice"            => price_info[:take_it_price],
      "ins0:SecondChanceOfferPrice" => price_info[:second_chance_offer_price],
      "ins0:StorePrice"             => price_info[:store_price]
    }
  end

  client.request :update_inventory_item_quantity_and_price do
    soap.header = soap_header
    soap.body = soap_body
  end
end

.update_inventory_item_quantity_and_price_list(quantity_and_price_list) ⇒ Object

update_inventory_item_quantity_and_price


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/channeladvisor/services/inventory_service.rb', line 48

def update_inventory_item_quantity_and_price_list(quantity_and_price_list)
  soap_body = {
    "ins0:accountID" => creds(:account_id),
    "ins0:itemQuantityAndPriceList" => {
      "ins0:InventoryItemQuantityAndPrice" => []
    }
  }

  quantity_and_price_list.each do |item|
    item_quantity_and_price = {"ins0:Sku" => item[:sku]}

    if quantity_info = item[:quantity_info]
      item_quantity_and_price["ins0:QuantityInfo"] = {
        "ins0:UpdateType" => item[:quantity_info][:update_type],
        "ins0:Total"      => item[:quantity_info][:total]
      }
    end

    if price_info = item[:price_info]
      item_quantity_and_price["ins0:PriceInfo"] = {
        "ins0:Cost"                   => price_info[:cost],
        "ins0:RetailPrice"            => price_info[:retail_price],
        "ins0:StartingPrice"          => price_info[:starting_price],
        "ins0:ReservePrice"           => price_info[:reserve_price],
        "ins0:TakeItPrice"            => price_info[:take_it_price],
        "ins0:SecondChanceOfferPrice" => price_info[:second_chance_offer_price],
        "ins0:StorePrice"             => price_info[:store_price]
      }
    end

    soap_body["ins0:itemQuantityAndPriceList"]["ins0:InventoryItemQuantityAndPrice"] << item_quantity_and_price
  end


  client.request :update_inventory_item_quantity_and_price_list do
    soap.header = soap_header
    soap.body = soap_body
  end
end