invofox-api-ruby 0.1.1 → 0.1.3

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
  SHA256:
3
- metadata.gz: b00b513fe176cfdbcb4d62613895e50b3eeecf33f1b8f9b07ed29de98c6c7a36
4
- data.tar.gz: b40d4e0c9f8e8f41591c08f88fee0a7d16748c25fd25522668ee8c3c9311e25a
3
+ metadata.gz: 0b3b23128f3a968a7d39c6e9341fced0e6a8f6b980b5cc558cdefae1e11aab6f
4
+ data.tar.gz: 69b10c217a0177465d04cec477533af61e1bdc0568c17357283046a158ec7e7d
5
5
  SHA512:
6
- metadata.gz: 210d9cf33066ee484f40acb375c1820abb16436e9951cf23afbc559402c189958bbdef6ff565f30d465f9c7a7b5cc12309743376c66a491ad84b2959166f10bd
7
- data.tar.gz: 8548ec572c3c1276f4ca11117528142a227da74dfcf566944204983a8305c4d975e579cf74b29fb6d1755b59fe0fed9dfc0b6c9c6c400d2aecca9f73b2f635d7
6
+ metadata.gz: 77d0c1b2eb38d4a38877268a988fdf8784b30ed74af3f7bf363887c3288cda3f3611938fffe380acc442c70174d5d4ba8d9dbf9a1f3c17b01bae4693238307de
7
+ data.tar.gz: d26f9a1069835b38c8a05dc41f259efa1273d6640134cefa3aee21b4a75dfd605042f97a3ac8ffd7981672605ff54f0717c57d6f204bf1743c2559d7c3a5113c
@@ -0,0 +1,12 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2024-04-17 14:37:05 UTC using RuboCop version 1.36.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/MissingSuper:
11
+ Exclude:
12
+ - 'lib/invofox/collection.rb'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invofox-api-ruby (0.1.1)
4
+ invofox-api-ruby (0.1.3)
5
5
  rest-client (~> 2.0.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -33,6 +33,8 @@ You can set a `logger` as well.
33
33
  Changelog
34
34
  ---------
35
35
 
36
+ * v.0.1.3 Increase timeout to 5m.
37
+ * v.0.1.2 Added support for companies' list endpoint.
36
38
  * v.0.1.1 Added support for documents' update_type endpoint.
37
39
  * v.0.1.0 First vull version, including resource wrapping for companies (get, create and update), documents (get, bulk and update) and load batches (get), plus logger integration.
38
40
 
data/lib/invofox/base.rb CHANGED
@@ -25,6 +25,7 @@ module Invofox
25
25
  headers: request_headers,
26
26
  method: method,
27
27
  url: url,
28
+ timeout: 60 * 5 # a 5m timeout should be enough for anything
28
29
  }
29
30
 
30
31
  if method == :post || method == :put
@@ -56,18 +57,16 @@ module Invofox
56
57
  # 2. If all went fine, we locate the body result
57
58
  result_in_body = block.call(response_body)
58
59
 
59
- # 3. Then we extract account and environment
60
- account = result_in_body.delete("account")
61
- environment = result_in_body.delete("environment")
62
-
63
- # 4. We build the resource result
64
- result = clazz.new(result_in_body)
60
+ # 3. We build the resource result
61
+ result = if result_in_body.is_a?(Array)
62
+ Collection.new(result_in_body, clazz)
63
+ else
64
+ clazz.new(result_in_body)
65
+ end
65
66
 
66
67
  # 4. And return everything together
67
68
  Invofox::Response.new(
68
- result: result,
69
- account: account,
70
- environment: environment
69
+ result: result
71
70
  )
72
71
  end
73
72
 
@@ -0,0 +1,7 @@
1
+ class Invofox::Collection < Array
2
+ def initialize(response, item_klass)
3
+ response.each do |item|
4
+ self << item_klass.new(item)
5
+ end
6
+ end
7
+ end
@@ -5,7 +5,14 @@ class Invofox::Resource
5
5
  end
6
6
 
7
7
  def fields_information
8
- self.class.fields_information
8
+ # We add account and environment, which are common in all resources
9
+ self
10
+ .class
11
+ .fields_information
12
+ .merge(
13
+ account: :string,
14
+ environment: :string
15
+ )
9
16
  end
10
17
 
11
18
  private
@@ -7,6 +7,21 @@ class Invofox::Company < Invofox::Resource
7
7
  data: :hash
8
8
 
9
9
  class << self
10
+ # TODO allow not required fields; for now we just need this scenario at Quipu
11
+ def list(country_code:, tax_id:)
12
+ Invofox.api_call(
13
+ clazz: self,
14
+ method: :get,
15
+ path: "/companies",
16
+ params: {
17
+ countryCode: country_code,
18
+ taxId: tax_id
19
+ }
20
+ ) do |response_body|
21
+ response_body['result']
22
+ end
23
+ end
24
+
10
25
  def get(id:)
11
26
  Invofox.api_call(
12
27
  clazz: self,
@@ -1,3 +1,3 @@
1
1
  module Invofox
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/invofox.rb CHANGED
@@ -3,6 +3,7 @@ require 'invofox/configuration'
3
3
  require 'invofox/base'
4
4
  require 'invofox/error'
5
5
  require 'invofox/resource'
6
+ require 'invofox/collection'
6
7
  require 'invofox/response'
7
8
 
8
9
  require 'invofox/resources/company'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invofox-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Bellonch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-15 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -142,6 +142,7 @@ files:
142
142
  - invofox.gemspec
143
143
  - lib/invofox.rb
144
144
  - lib/invofox/base.rb
145
+ - lib/invofox/collection.rb
145
146
  - lib/invofox/configuration.rb
146
147
  - lib/invofox/error.rb
147
148
  - lib/invofox/resource.rb