/
product_service.rb
97 lines (77 loc) · 2.27 KB
/
product_service.rb
1
2
3
4
5
6
7
8
9
10
11
12
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
47
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
87
88
89
90
91
92
93
94
95
96
97
module PowaApi
class ProductService < PowaService
def self.get_published_products(publish_token, batch_number = nil)
client = Savon.client wsdl
response = client.request :get_published_products do
soap.xml do |xml|
xml.soapenv(:Envelope, namespaces) do |xml|
header_block(xml)
xml.soapenv(:Body) do |xml|
xml.urn(:GetPublishedProductsRequest) do |xml|
xml.publishToken publish_token
xml.batchNumber batch_number if batch_number
end
end
end
end
end
end
def self.get_published_products_by_sku(*skus)
client = Savon.client wsdl
response = client.request :get_published_products_by_sku do
soap.xml do |xml|
xml.soapenv(:Envelope, namespaces) do |xml|
header_block(xml)
xml.soapenv(:Body) do |xml|
xml.urn(:GetProductsBySkuRequest) do |xml|
xml.skuList do |xml|
skus.each do |sku|
xml.sku sku
end
end
end
end
end
end
end
end
def self.get_products(batch_number = nil)
client = Savon.client wsdl
response = client.request :get_products do
soap.xml do |xml|
xml.soapenv(:Envelope, namespaces) do |xml|
header_block(xml)
xml.soapenv(:Body) do |xml|
xml.urn(:GetProductsRequest) do |xml|
xml.batchNumber batch_number if batch_number
end
end
end
end
end
end
def self.get_products_by_sku(*skus)
client = Savon.client wsdl
response = client.request :get_products_by_sku do
soap.xml do |xml|
xml.soapenv(:Envelope, namespaces) do |xml|
header_block(xml)
xml.soapenv(:Body) do |xml|
xml.urn(:GetProductsBySkuRequest) do |xml|
xml.skuList do |xml|
skus.each do |sku|
xml.sku sku
end
end
end
end
end
end
end
end
private
def self.wsdl
base_url + "ProductService?wsdl"
end
end
end