xsys 0.0.5 → 0.0.6

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: 49e7000e06ab79e54cad70a2831da14878228053
4
- data.tar.gz: e904c0dfad14a80581b11de9d874130e1d94d44a
3
+ metadata.gz: 1128f66cb7ed55f5d26677e8f7ce9e7a18c514fc
4
+ data.tar.gz: 5fa0b025e8ae3a856d01531759597afcc49f03d3
5
5
  SHA512:
6
- metadata.gz: cc23e0ab522d7297ea070e9be3da76f71357523d437b10be2a7081053ad4534c82e715b0769f8b79f0c9f62dafae123550886e205d1d9e2bca8154ea2eaf5f38
7
- data.tar.gz: 33482c07e465ba687d7e758f407e50de6346a0baaf8622c76378d78cdd6f487a40b23deb9d616a2728a2341947d08387d284c58c98f67e98d13b39bfe14e174b
6
+ metadata.gz: b99c4c71bd2b4a045154a4c29aa8a12509c704f97afb4c5c8f30feceab0d936da984e7b5ddcdc7b6487d5b328d836423eea3b8b52e1b3591c96bc18ef600a219
7
+ data.tar.gz: be2b19a8a869426d6ba3b8179c75184e29554d97500fab27c461277e2f5e9ec82e0e9527658285e909b89038ca6361876529ec344388b57ac947b441765a7d03
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ ## v0.0.1
2
+
3
+ * Initial release
4
+
5
+ ## v0.0.2
6
+
7
+ * Bugfix: Authentication header missing
8
+
9
+ ## v0.0.3
10
+
11
+ * Added attributes to shop
12
+
13
+ ## v0.0.4
14
+
15
+ * Bugfix: Authentication token not being passed correctly
16
+
17
+ ## v0.0.5
18
+
19
+ * Api class turned into singleton class
20
+
21
+ ## v0.0.6
22
+
23
+ * Api class turned into singleton class
data/lib/xsys/api.rb CHANGED
@@ -2,62 +2,64 @@ module Xsys
2
2
  class Api
3
3
  include Singleton
4
4
 
5
+ attr_accessor :endpoint, :access_token
6
+
5
7
  def self.configure(args={})
6
- @access_token = args[:access_token]
7
- @endpoint = args[:endpoint]
8
+ instance.endpoint = (args[:endpoint] || 'https://xsys.lhconfort.com.ar')
9
+ instance.access_token = args[:access_token]
8
10
  end
9
11
 
10
12
  def get_price_lists(filters={})
11
- get_request('/price_lists').map { |r| Xsys::Model::PriceList.new(r) }
13
+ get_request('/price_lists').map { |r| Model::PriceList.new(r) }
12
14
  end
13
15
 
14
16
  def get_provider_kinds(filters={})
15
17
  request = get_request('/provider_kinds', filters)
16
- request[:results] = request[:results].map { |r| Xsys::Model::ProviderKind.new(r) }
18
+ request[:results] = request[:results].map { |r| Model::ProviderKind.new(r) }
17
19
  request
18
20
  end
19
21
 
20
22
  def get_provider_kind(id)
21
- Xsys::Model::ProviderKind.new(get_request("/provider_kinds/#{id}"))
23
+ Model::ProviderKind.new(get_request("/provider_kinds/#{id}"))
22
24
  end
23
25
 
24
26
  def get_product_providers(filters={})
25
27
  request = get_request('/product_providers', filters)
26
- request[:results] = request[:results].map { |r| Xsys::Model::ProductProvider.new(r) }
28
+ request[:results] = request[:results].map { |r| Model::ProductProvider.new(r) }
27
29
  request
28
30
  end
29
31
 
30
32
  def get_product_provider(id)
31
- Xsys::Model::ProductProvider.new(get_request("/product_providers/#{id}"))
33
+ Model::ProductProvider.new(get_request("/product_providers/#{id}"))
32
34
  end
33
35
 
34
36
  def get_product_categories(filters={})
35
37
  request = get_request('/product_categories', filters)
36
- request[:results] = request[:results].map { |r| Xsys::Model::ProductCategory.new(r) }
38
+ request[:results] = request[:results].map { |r| Model::ProductCategory.new(r) }
37
39
  request
38
40
  end
39
41
 
40
42
  def get_product_category(id)
41
- Xsys::Model::ProductCategory.new(get_request("/product_categories/#{id}"))
43
+ Model::ProductCategory.new(get_request("/product_categories/#{id}"))
42
44
  end
43
45
 
44
46
  def get_products(filters={})
45
47
  request = get_request('/products', filters)
46
- request[:results] = request[:results].map { |r| Xsys::Model::Product.new(r) }
48
+ request[:results] = request[:results].map { |r| Model::Product.new(r) }
47
49
  request
48
50
  end
49
51
 
50
52
  def get_product(id)
51
- Xsys::Model::Product.new(get_request("/products/#{id}"))
53
+ Model::Product.new(get_request("/products/#{id}"))
52
54
  end
53
55
 
54
56
  def get_shops(kind=nil)
55
57
  shops_url = (kind.nil? ? '/shops' : "/shops/#{kind}")
56
- get_request(shops_url).map { |r| Xsys::Model::Shop.new(r) }
58
+ get_request(shops_url).map { |r| Model::Shop.new(r) }
57
59
  end
58
60
 
59
61
  def get_sellers
60
- get_request('/sellers').map { |r| Xsys::Model::Seller.new(r) }
62
+ get_request('/sellers').map { |r| Model::Seller.new(r) }
61
63
  end
62
64
 
63
65
  def get_sales_period(period, from, to, shop_code=nil)
@@ -65,51 +67,43 @@ module Xsys
65
67
  date_from: from,
66
68
  date_to: to,
67
69
  shop_code: shop_code
68
- }).map { |r| Xsys::Model::SalesPeriod.new(r) }
70
+ }).map { |r| Model::SalesPeriod.new(r) }
69
71
  end
70
72
 
71
73
  def get_purchase_order_items(filters={})
72
74
  request = get_request('/purchase_order_items', filters)
73
- request[:results] = request[:results].map { |r| Xsys::Model::PurchaseOrderItem.new(r) }
75
+ request[:results] = request[:results].map { |r| Model::PurchaseOrderItem.new(r) }
74
76
  request
75
77
  end
76
78
 
77
79
  def get_grouped_purchase_order_items(filters={})
78
80
  request = get_request('/purchase_order_items/grouped', filters)
79
- request[:results] = request[:results].map { |r| Xsys::Model::GroupedPurchaseOrderItem.new(r) }
81
+ request[:results] = request[:results].map { |r| Model::GroupedPurchaseOrderItem.new(r) }
80
82
  request
81
83
  end
82
84
 
83
85
  def get_sale_items(filters={})
84
86
  request = get_request('/sale_items', filters)
85
- request[:results] = request[:results].map { |r| Xsys::Model::SaleItem.new(r) }
87
+ request[:results] = request[:results].map { |r| Model::SaleItem.new(r) }
86
88
  request
87
89
  end
88
90
 
89
91
  def get_grouped_sale_items(filters={})
90
92
  request = get_request('/sale_items/grouped', filters)
91
- request[:results] = request[:results].map { |r| Xsys::Model::GroupedSaleItem.new(r) }
93
+ request[:results] = request[:results].map { |r| Model::GroupedSaleItem.new(r) }
92
94
  request
93
95
  end
94
96
 
95
97
  private
96
98
 
97
- def self.access_token
98
- @access_token
99
- end
100
-
101
- def self.endpoint
102
- @endpoint || 'https://xsys.lhconfort.com.ar'
103
- end
104
-
105
99
  def get_request(action, params={})
106
- response = ::RestClient.get("#{Xsys::Api.endpoint}#{action}", {params: params}.merge({
107
- authorization: "Token token=\"#{Xsys::Api.access_token}\""
100
+ response = ::RestClient.get("#{@endpoint}#{action}", {params: params}.merge({
101
+ authorization: "Token token=\"#{@access_token}\""
108
102
  }))
109
103
 
110
104
  if response.headers[:link]
111
105
  {
112
- pagination: Xsys::Pagination.new(JSON.parse(response.headers[:link])),
106
+ pagination: Pagination.new(JSON.parse(response.headers[:link])),
113
107
  results: JSON.parse(response.body)
114
108
  }
115
109
  else
data/lib/xsys/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Xsys
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - LICENSE.md
63
63
  - README.md
64
+ - CHANGELOG.md
64
65
  - lib/xsys/api.rb
65
66
  - lib/xsys/model/grouped_purchase_order_item.rb
66
67
  - lib/xsys/model/grouped_sale_item.rb