xsys 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +22 -0
- data/README.md +29 -0
- data/lib/xsys.rb +21 -0
- data/lib/xsys/api.rb +116 -0
- data/lib/xsys/model/grouped_purchase_order_item.rb +13 -0
- data/lib/xsys/model/grouped_sale_item.rb +13 -0
- data/lib/xsys/model/price_list.rb +13 -0
- data/lib/xsys/model/product.rb +27 -0
- data/lib/xsys/model/product_category.rb +13 -0
- data/lib/xsys/model/product_provider.rb +14 -0
- data/lib/xsys/model/provider_kind.rb +17 -0
- data/lib/xsys/model/purchase_order_item.rb +14 -0
- data/lib/xsys/model/sale_item.rb +15 -0
- data/lib/xsys/model/sales_period.rb +13 -0
- data/lib/xsys/model/seller.rb +13 -0
- data/lib/xsys/model/shop.rb +34 -0
- data/lib/xsys/model/stock.rb +13 -0
- data/lib/xsys/pagination.rb +11 -0
- data/lib/xsys/version.rb +3 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2a7df9c1e5960b5e04bb479eebadda13e45a7223
|
4
|
+
data.tar.gz: 7f001cb9716dc4744b198f747be0f861cb162f92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0830dc1c1a8081d9f26de97610a2ec4288af957782d09836c0f6a77ca00ee4e88a20b335c4ba54d43f53c7f42540a9af3660a3fde2a192283827784c85d5f549
|
7
|
+
data.tar.gz: df19d7d749b5b30c86e8b57647b74deeb0fbe32e8b9a8688dcf1e49d9dbb3325b557f88dc583fd774f8e886c1758b1a7032bcdf2283610c2b12732afa2de349d
|
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 unformatt
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Xsys
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'xsys'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install xsys
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/lib/xsys.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'xsys/model/grouped_purchase_order_item'
|
2
|
+
require 'xsys/model/grouped_sale_item'
|
3
|
+
require 'xsys/model/price_list'
|
4
|
+
require 'xsys/model/product'
|
5
|
+
require 'xsys/model/product_category'
|
6
|
+
require 'xsys/model/product_provider'
|
7
|
+
require 'xsys/model/provider_kind'
|
8
|
+
require 'xsys/model/purchase_order_item'
|
9
|
+
require 'xsys/model/sale_item'
|
10
|
+
require 'xsys/model/sales_period'
|
11
|
+
require 'xsys/model/seller'
|
12
|
+
require 'xsys/model/shop'
|
13
|
+
require 'xsys/model/stock'
|
14
|
+
|
15
|
+
require 'xsys/api'
|
16
|
+
require 'xsys/pagination'
|
17
|
+
require 'xsys/version'
|
18
|
+
|
19
|
+
# dependencies
|
20
|
+
require 'rest-client'
|
21
|
+
|
data/lib/xsys/api.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
module Xsys
|
2
|
+
class Api
|
3
|
+
def self.configure(args={})
|
4
|
+
@access_token = args[:access_token]
|
5
|
+
@endpoint = args[:endpoint]
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_price_lists(filters={})
|
9
|
+
get_request('/price_lists').map { |r| Xsys::Model::PriceList.new(r) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_provider_kinds(filters={})
|
13
|
+
request = get_request('/provider_kinds', filters)
|
14
|
+
request[:results] = request[:results].map { |r| Xsys::Model::ProviderKind.new(r) }
|
15
|
+
request
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_provider_kind(id)
|
19
|
+
Xsys::Model::ProviderKind.new(get_request("/provider_kinds/#{id}"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_product_providers(filters={})
|
23
|
+
request = get_request('/product_providers', filters)
|
24
|
+
request[:results] = request[:results].map { |r| Xsys::Model::ProductProvider.new(r) }
|
25
|
+
request
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_product_provider(id)
|
29
|
+
Xsys::Model::ProductProvider.new(get_request("/product_providers/#{id}"))
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_product_categories(filters={})
|
33
|
+
request = get_request('/product_categories', filters)
|
34
|
+
request[:results] = request[:results].map { |r| Xsys::Model::ProductCategory.new(r) }
|
35
|
+
request
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_product_category(id)
|
39
|
+
Xsys::Model::ProductCategory.new(get_request("/product_categories/#{id}"))
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_products(filters={})
|
43
|
+
request = get_request('/products', filters)
|
44
|
+
request[:results] = request[:results].map { |r| Xsys::Model::Product.new(r) }
|
45
|
+
request
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_product(id)
|
49
|
+
Xsys::Model::Product.new(get_request("/products/#{id}"))
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_shops(kind=nil)
|
53
|
+
shops_url = (kind.nil? ? '/shops' : "/shops/#{kind}")
|
54
|
+
get_request(shops_url).map { |r| Xsys::Model::Shop.new(r) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_sellers
|
58
|
+
get_request('/sellers').map { |r| Xsys::Model::Seller.new(r) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_sales_period(period, from, to, shop_code=nil)
|
62
|
+
get_request("/sales_periods/#{period}", {
|
63
|
+
date_from: from,
|
64
|
+
date_to: to,
|
65
|
+
shop_code: shop_code
|
66
|
+
}).map { |r| Xsys::Model::SalesPeriod.new(r) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_purchase_order_items(filters={})
|
70
|
+
request = get_request('/purchase_order_items', filters)
|
71
|
+
request[:results] = request[:results].map { |r| Xsys::Model::PurchaseOrderItem.new(r) }
|
72
|
+
request
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_grouped_purchase_order_items(filters={})
|
76
|
+
request = get_request('/purchase_order_items/grouped', filters)
|
77
|
+
request[:results] = request[:results].map { |r| Xsys::Model::GroupedPurchaseOrderItem.new(r) }
|
78
|
+
request
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_sale_items(filters={})
|
82
|
+
request = get_request('/sale_items', filters)
|
83
|
+
request[:results] = request[:results].map { |r| Xsys::Model::SaleItem.new(r) }
|
84
|
+
request
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_grouped_sale_items(filters={})
|
88
|
+
request = get_request('/sale_items/grouped', filters)
|
89
|
+
request[:results] = request[:results].map { |r| Xsys::Model::GroupedSaleItem.new(r) }
|
90
|
+
request
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def self.access_token
|
96
|
+
@access_token
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.endpoint
|
100
|
+
@endpoint || 'https://xsys.lhconfort.com.ar'
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_request(action, params={}, headers={})
|
104
|
+
response = ::RestClient.get("#{Xsys::Api.endpoint}#{action}", {params: params}.merge(headers))
|
105
|
+
|
106
|
+
if response.headers[:link]
|
107
|
+
{
|
108
|
+
pagination: Xsys::Pagination.new(JSON.parse(response.headers[:link])),
|
109
|
+
results: JSON.parse(response.body)
|
110
|
+
}
|
111
|
+
else
|
112
|
+
JSON.parse(response.body)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class Product
|
4
|
+
attr_accessor :id, :name, :cost, :active, :sellable, :list_price_1, :list_price_6,
|
5
|
+
:list_price_35, :markup_1, :markup_6, :markup_35, :category, :provider, :stocks,
|
6
|
+
:remaining_quantity, :sales, :value_added_tax
|
7
|
+
|
8
|
+
def initialize(attributes={})
|
9
|
+
attributes.each do |k,v|
|
10
|
+
if k == 'category'
|
11
|
+
@category = ProductCategory.new(v)
|
12
|
+
elsif k == 'provider'
|
13
|
+
@provider = ProductProvider.new(v)
|
14
|
+
elsif k == 'stocks'
|
15
|
+
@stocks = v.map { |s| Stock.new(s) }
|
16
|
+
else
|
17
|
+
self.send("#{k}=", v)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def stock_in(shop_code)
|
23
|
+
stocks.find { |s| s.shop_code.to_sym == shop_code.to_sym }.try(:quantity)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class ProviderKind
|
4
|
+
attr_accessor :id, :name
|
5
|
+
|
6
|
+
def initialize(attributes={})
|
7
|
+
attributes.each do |k,v|
|
8
|
+
if k == 'kind'
|
9
|
+
@kind = ProviderKind.new(v)
|
10
|
+
else
|
11
|
+
self.send("#{k}=", v)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class PurchaseOrderItem
|
4
|
+
attr_accessor :product_id, :quantity, :remaining_quantity,
|
5
|
+
:transaction_date, :transaction_status_id, :transaction_kind_id
|
6
|
+
|
7
|
+
def initialize(attributes={})
|
8
|
+
attributes.each do |k,v|
|
9
|
+
self.send("#{k}=", v)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class SaleItem
|
4
|
+
attr_accessor :shop_code, :product_id, :seller_id, :quantity, :amount_total,
|
5
|
+
:client_id, :transaction_date, :receipt_number, :transaction_id,
|
6
|
+
:transaction_kind_id, :transaction_status_id
|
7
|
+
|
8
|
+
def initialize(attributes={})
|
9
|
+
attributes.each do |k,v|
|
10
|
+
self.send("#{k}=", v)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class SalesPeriod
|
4
|
+
attr_accessor :shop_code, :seller_id, :transaction_period, :amount_total, :amount_taxes
|
5
|
+
|
6
|
+
def initialize(attributes={})
|
7
|
+
attributes.each do |k,v|
|
8
|
+
self.send("#{k}=", v) if self.respond_to?(k)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Xsys
|
2
|
+
module Model
|
3
|
+
class Shop
|
4
|
+
attr_accessor :id, :code, :name, :is_commercial, :is_virtual,
|
5
|
+
:is_physical, :is_stockable, :has_target, :is_service
|
6
|
+
|
7
|
+
def initialize(attributes={})
|
8
|
+
attributes.each do |k,v|
|
9
|
+
self.send("#{k}=", v)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def commercial?
|
14
|
+
is_commercial == true
|
15
|
+
end
|
16
|
+
|
17
|
+
def virtual?
|
18
|
+
is_virtual == true
|
19
|
+
end
|
20
|
+
|
21
|
+
def stockable?
|
22
|
+
is_stockable == true
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_target?
|
26
|
+
has_target == true
|
27
|
+
end
|
28
|
+
|
29
|
+
def service?
|
30
|
+
is_service == true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/xsys/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xsys
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matias Hick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.7
|
55
|
+
description: Get data from xsys api
|
56
|
+
email:
|
57
|
+
- me@unformatt.com.ar
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE.md
|
63
|
+
- README.md
|
64
|
+
- lib/xsys/api.rb
|
65
|
+
- lib/xsys/model/grouped_purchase_order_item.rb
|
66
|
+
- lib/xsys/model/grouped_sale_item.rb
|
67
|
+
- lib/xsys/model/price_list.rb
|
68
|
+
- lib/xsys/model/product.rb
|
69
|
+
- lib/xsys/model/product_category.rb
|
70
|
+
- lib/xsys/model/product_provider.rb
|
71
|
+
- lib/xsys/model/provider_kind.rb
|
72
|
+
- lib/xsys/model/purchase_order_item.rb
|
73
|
+
- lib/xsys/model/sale_item.rb
|
74
|
+
- lib/xsys/model/sales_period.rb
|
75
|
+
- lib/xsys/model/seller.rb
|
76
|
+
- lib/xsys/model/shop.rb
|
77
|
+
- lib/xsys/model/stock.rb
|
78
|
+
- lib/xsys/pagination.rb
|
79
|
+
- lib/xsys/version.rb
|
80
|
+
- lib/xsys.rb
|
81
|
+
homepage: https://github.com/unformattmh/xsys
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.1.11
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Get data from xsys api
|
105
|
+
test_files: []
|