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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 826298b8c134e49c3d58189f54f059a3b30c517a
4
- data.tar.gz: 253f5c3ebfb231a47f338dc7871bdde24e8bf746
3
+ metadata.gz: 0b252c024a11ee752ec3a5d1813e8e21b495cfa8
4
+ data.tar.gz: db5c4e65a5e6f8af9ac8bb9afcdf86a55876683e
5
5
  SHA512:
6
- metadata.gz: b57b454a874dcd148e00e14a86fd465c9e1677f5918daa4ca9f7c9c75ccdf8461127daf8132540e76c4c389b684e4b85c34000f946a07bd9758114413913bc30
7
- data.tar.gz: c0d85281b1eb0fe5fb6ed40168929c7bf9df5282775d163b8cc40404add6f9e0fedb1db9cdd06ce98f54dedf14662df4a467756eeea9d581c9affc003ef133f6
6
+ metadata.gz: d912ba5c83dd2d4177cf2d1f1e217dc465fde8a1c16f11b14095949d5bb3d72802b36c1d3b4de12abdde3ddb46ac089fa530c971bbda91b171687fbe581154c0
7
+ data.tar.gz: 1efd2327767964bd3ac7e964930f3aa25213f1f32c86b3776489ca0a7e369279ce2b51937278e96c81517f2233a42b6f56b302fedc9838e7927ad9b14d555f62
data/CHANGELOG.md CHANGED
@@ -109,3 +109,7 @@
109
109
  ## v0.1.0
110
110
 
111
111
  * redesigned API to minimal functionality
112
+
113
+ ## v0.1.1
114
+
115
+ * general fixes
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.headers[:link])),
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.headers[:link])),
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.headers[:link])),
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.headers[:link])),
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("#{@endpoint_url}#{action}", {params: params}.merge(headers)))
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("#{@endpoint_url}#{action}", params, headers))
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("#{@endpoint_url}#{action}", params, headers))
119
+ parse_response(RestClient.put("#{@endpoint}#{action}", params, headers))
120
120
  rescue => e
121
121
  parse_response(e.response)
122
122
  end
@@ -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| ProductListPrice.new(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 price_with_list(price_list_code)
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
@@ -1,3 +1,3 @@
1
1
  module Xsys
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick