kounta_rest 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/kounta.rb CHANGED
@@ -12,6 +12,7 @@ require_relative "kounta/order"
12
12
  require_relative "kounta/person"
13
13
  require_relative "kounta/customer"
14
14
  require_relative "kounta/price_list"
15
+ require_relative "kounta/inventory"
15
16
  require_relative "kounta/site"
16
17
  require_relative "kounta/company"
17
18
 
@@ -0,0 +1,8 @@
1
+ module Kounta
2
+
3
+ class Inventory < Kounta::Resource
4
+ property :company_id
5
+ property :stock
6
+ end
7
+
8
+ end
@@ -28,8 +28,6 @@ module Kounta
28
28
  begin
29
29
  log("#{request_method}: #{Kounta::SITE_URI}#{path_from_hash(url_hash)}.#{FORMAT.to_s} (#{options})")
30
30
  response = @conn.request(request_method, "#{path_from_hash(url_hash)}.#{FORMAT.to_s}", options)
31
- log("response:")
32
- log("#{response.parsed}")
33
31
  rescue OAuth2::Error => ex
34
32
  if ex.message.include? 'The access token provided has expired'
35
33
  log('oauth2 token expired, refreshing it...')
@@ -37,7 +35,16 @@ module Kounta
37
35
  retry
38
36
  end
39
37
  end
40
- response.parsed if response
38
+
39
+ log("response:")
40
+
41
+ if response
42
+ log("#{response.parsed}")
43
+ response.parsed
44
+ else
45
+ log('No response recieved')
46
+ nil
47
+ end
41
48
  end
42
49
 
43
50
  def objects_from_response(klass, request_method, url_hash, options={})
data/lib/kounta/site.rb CHANGED
@@ -32,6 +32,7 @@ module Kounta
32
32
  has_many :categories, Kounta::Category, {:company_id => :company_id}, lambda { |klass| {companies: klass.company_id, sites: klass.id, categories: nil} }
33
33
  has_many :addresses, Kounta::Address, {:company_id => :company_id}, lambda { |klass| {companies: klass.company_id, sites: klass.id, addresses: nil} }
34
34
  has_many :orders, Kounta::Order, {:company_id => :company_id}, lambda { |klass| {companies: klass.company_id, sites: klass.id, orders: nil} }
35
+ has_many :inventory, Kounta::Inventory, {:company_id => :company_id}, lambda { |klass| {companies: klass.company_id, sites: klass.id, inventory: nil} }
35
36
 
36
37
  def resource_path
37
38
  {companies: company_id, sites: id}
@@ -1,3 +1,3 @@
1
1
  module Kounta
2
- VERSION = "0.0.7"
3
- end
2
+ VERSION = "0.0.8"
3
+ end
@@ -0,0 +1,10 @@
1
+ [
2
+ {
3
+ "id":5143,
4
+ "stock": 45
5
+ },
6
+ {
7
+ "id": 33975,
8
+ "stock": 0
9
+ }
10
+ ]
@@ -10,7 +10,7 @@ describe Kounta do
10
10
  end
11
11
  end
12
12
 
13
- it "should be able to configure loggin" do
13
+ it "should be able to configure logging" do
14
14
  Kounta.enable_logging.should be(false)
15
15
  Kounta.enable_logging = true
16
16
  Kounta.enable_logging.should be(true)
@@ -56,6 +56,7 @@ module Helpers
56
56
  stub_request(:get, group_endpoint('taxes')).to_return(:body => load_json_from_fixture('taxes.json'), :headers => endpoint_headers)
57
57
  stub_request(:get, singular_endpoint('orders')).to_return(:body => load_json_from_fixture('order.json'), :headers => endpoint_headers)
58
58
  stub_request(:get, group_endpoint('orders')).to_return(:body => load_json_from_fixture('orders.json'), :headers => endpoint_headers)
59
+ stub_request(:get, group_endpoint('inventory')).to_return(:body => load_json_from_fixture('inventory.json'), :headers => endpoint_headers)
59
60
 
60
61
  # update
61
62
  stub_request(:put, singular_endpoint('products')).to_return(:body => load_json_from_fixture('product.json'), :headers => endpoint_headers)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kounta_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-06 00:00:00.000000000 Z
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -192,6 +192,7 @@ files:
192
192
  - lib/kounta/company.rb
193
193
  - lib/kounta/customer.rb
194
194
  - lib/kounta/errors.rb
195
+ - lib/kounta/inventory.rb
195
196
  - lib/kounta/line.rb
196
197
  - lib/kounta/order.rb
197
198
  - lib/kounta/payment.rb
@@ -211,6 +212,7 @@ files:
211
212
  - spec/fixtures/companies_me.json
212
213
  - spec/fixtures/customer.json
213
214
  - spec/fixtures/customers.json
215
+ - spec/fixtures/inventory.json
214
216
  - spec/fixtures/line.json
215
217
  - spec/fixtures/order.json
216
218
  - spec/fixtures/orders.json
@@ -274,6 +276,7 @@ test_files:
274
276
  - spec/fixtures/companies_me.json
275
277
  - spec/fixtures/customer.json
276
278
  - spec/fixtures/customers.json
279
+ - spec/fixtures/inventory.json
277
280
  - spec/fixtures/line.json
278
281
  - spec/fixtures/order.json
279
282
  - spec/fixtures/orders.json