xsys 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/xsys/api.rb +10 -10
- data/lib/xsys/model/product.rb +2 -2
- data/lib/xsys/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b252c024a11ee752ec3a5d1813e8e21b495cfa8
|
4
|
+
data.tar.gz: db5c4e65a5e6f8af9ac8bb9afcdf86a55876683e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d912ba5c83dd2d4177cf2d1f1e217dc465fde8a1c16f11b14095949d5bb3d72802b36c1d3b4de12abdde3ddb46ac089fa530c971bbda91b171687fbe581154c0
|
7
|
+
data.tar.gz: 1efd2327767964bd3ac7e964930f3aa25213f1f32c86b3776489ca0a7e369279ce2b51937278e96c81517f2233a42b6f56b302fedc9838e7927ad9b14d555f62
|
data/CHANGELOG.md
CHANGED
data/lib/xsys/api.rb
CHANGED
@@ -6,7 +6,7 @@ module Xsys
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.get_price_lists(filters={})
|
9
|
-
get_request('/price_lists').map { |r| Model::PriceList.new(r) }
|
9
|
+
get_request('/price_lists')[:body].map { |r| Model::PriceList.new(r) }
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.get_products(filters={})
|
@@ -14,7 +14,7 @@ module Xsys
|
|
14
14
|
|
15
15
|
if response[:headers][:link]
|
16
16
|
{
|
17
|
-
pagination: Pagination.new(JSON.parse(response
|
17
|
+
pagination: Pagination.new(JSON.parse(response[:headers][:link])),
|
18
18
|
results: response[:body].map { |r| Model::Product.new(r) }
|
19
19
|
}
|
20
20
|
else
|
@@ -31,7 +31,7 @@ module Xsys
|
|
31
31
|
|
32
32
|
if response[:headers][:link]
|
33
33
|
{
|
34
|
-
pagination: Pagination.new(JSON.parse(response
|
34
|
+
pagination: Pagination.new(JSON.parse(response[:headers][:link])),
|
35
35
|
results: response[:body].map { |r| Model::ProductProvider.new(r) }
|
36
36
|
}
|
37
37
|
else
|
@@ -40,7 +40,7 @@ module Xsys
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.get_product_provider(provider_code)
|
43
|
-
Model::ProductProvider.new(get_request("/product_providers/#{provider_code}"))
|
43
|
+
Model::ProductProvider.new(get_request("/product_providers/#{provider_code}")[:body])
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.get_product_categories(filters={})
|
@@ -48,7 +48,7 @@ module Xsys
|
|
48
48
|
|
49
49
|
if response[:headers][:link]
|
50
50
|
{
|
51
|
-
pagination: Pagination.new(JSON.parse(response
|
51
|
+
pagination: Pagination.new(JSON.parse(response[:headers][:link])),
|
52
52
|
results: response[:body].map { |r| Model::ProductCategory.new(r) }
|
53
53
|
}
|
54
54
|
else
|
@@ -57,7 +57,7 @@ module Xsys
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.get_product_category(category_code)
|
60
|
-
Model::ProductCategory.new(get_request("/product_categories/#{category_code}"))
|
60
|
+
Model::ProductCategory.new(get_request("/product_categories/#{category_code}")[:body])
|
61
61
|
end
|
62
62
|
|
63
63
|
def self.get_product_price_lists(filters={})
|
@@ -65,7 +65,7 @@ module Xsys
|
|
65
65
|
|
66
66
|
if response[:headers][:link]
|
67
67
|
{
|
68
|
-
pagination: Pagination.new(JSON.parse(response
|
68
|
+
pagination: Pagination.new(JSON.parse(response[:headers][:link])),
|
69
69
|
results: response[:body].map { |r| Model::ProductPriceList.new(r) }
|
70
70
|
}
|
71
71
|
else
|
@@ -98,7 +98,7 @@ module Xsys
|
|
98
98
|
def self.get_request(action, params={}, headers={})
|
99
99
|
begin
|
100
100
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
101
|
-
parse_response(RestClient.get("#{@
|
101
|
+
parse_response(RestClient.get("#{@endpoint}#{action}", {params: params}.merge(headers)))
|
102
102
|
rescue => e
|
103
103
|
parse_response(e.response)
|
104
104
|
end
|
@@ -107,7 +107,7 @@ module Xsys
|
|
107
107
|
def self.post_request(action, params={}, headers={})
|
108
108
|
begin
|
109
109
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
110
|
-
parse_response(RestClient.post("#{@
|
110
|
+
parse_response(RestClient.post("#{@endpoint}#{action}", params, headers))
|
111
111
|
rescue => e
|
112
112
|
parse_response(e.response)
|
113
113
|
end
|
@@ -116,7 +116,7 @@ module Xsys
|
|
116
116
|
def self.put_request(action, params={}, headers={})
|
117
117
|
begin
|
118
118
|
headers.merge!({ authorization: "Token token=\"#{@access_token}\"" })
|
119
|
-
parse_response(RestClient.put("#{@
|
119
|
+
parse_response(RestClient.put("#{@endpoint}#{action}", params, headers))
|
120
120
|
rescue => e
|
121
121
|
parse_response(e.response)
|
122
122
|
end
|
data/lib/xsys/model/product.rb
CHANGED
@@ -18,7 +18,7 @@ module Xsys
|
|
18
18
|
elsif k == 'stocks'
|
19
19
|
@stocks = v.map { |s| Stock.new(s) }
|
20
20
|
elsif k == 'prices'
|
21
|
-
@prices = v.map { |s|
|
21
|
+
@prices = v.map { |s| ProductPriceList.new(s) }
|
22
22
|
else
|
23
23
|
self.send("#{k}=", v) if self.respond_to?(k)
|
24
24
|
end
|
@@ -55,7 +55,7 @@ module Xsys
|
|
55
55
|
}.try(:markup) || 0.0
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def price_in_list(price_list_code)
|
59
59
|
prices.find { |p|
|
60
60
|
p.price_list_code.to_i == price_list_code.to_i
|
61
61
|
}.try(:total_price) || 0.0
|
data/lib/xsys/version.rb
CHANGED