omie-client 0.1.4 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72a1de613fdbc2ba050cfaa890e82d04b57ce34d9715dd2b00a81dfb6816129a
4
- data.tar.gz: cb79914f46a01909b57f794c09ac1b529ba6c03a4a4daa29ef67c972b5452c09
3
+ metadata.gz: 3363ec39f3eb50f1ce8f1555502c67837b6e9c89cb98ed44818fb1c4f29ffc15
4
+ data.tar.gz: 3e19a18a10d814e80e274700b3d584c114dad57196daad8a37382ea5fec58021
5
5
  SHA512:
6
- metadata.gz: f08dd02f8e999d00b363d0075eca5482ee467d738ee18824883b6c2021ab103aa3bf5663e4d6adb00a7ed3e1b363df83c5265c6ea664d525ccf20780c5d5030a
7
- data.tar.gz: d552b52fca09746097ee3558fa4db1aeb7f8ac74682405a858012572e2daedbe68249322011ed27a316ee4338496a8ebff94048cd1efa4a970d30b4f40dbaaa0
6
+ metadata.gz: 93d808cb45297237c3cf39e461d462f32e96afdcb881f1ba0e70caaa9cb55d67202e95e9c52c5c5d1316240fa3e3bca6cd6c3631f4928cad5c2f6aa7fc89be8c
7
+ data.tar.gz: 631ffe7c3e8f89fa7d9e0c56268824301b70e9f3d44470ce91e01ac273cc11e37b1e05bf291fd1824d7fe60e675b568e53f4f39dcc8c77e3ff87f31787706a26
data/.rubocop.yml CHANGED
@@ -14,3 +14,12 @@ Metrics/BlockLength:
14
14
  Lint/AmbiguousBlockAssociation:
15
15
  Exclude:
16
16
  - "spec/**/*"
17
+
18
+ Style/HashEachMethods:
19
+ Enabled: true
20
+
21
+ Style/HashTransformKeys:
22
+ Enabled: true
23
+
24
+ Style/HashTransformValues:
25
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omie-client (0.1.4)
4
+ omie-client (0.1.7)
5
5
  activesupport (>= 5.0)
6
6
  rest-client (>= 2.0)
7
7
 
@@ -70,7 +70,7 @@ GEM
70
70
  thread_safe (~> 0.1)
71
71
  unf (0.1.4)
72
72
  unf_ext
73
- unf_ext (0.0.7.6)
73
+ unf_ext (0.0.7.7)
74
74
  unicode-display_width (1.6.1)
75
75
 
76
76
  PLATFORMS
data/README.md CHANGED
@@ -104,7 +104,7 @@ from the API, please open an issue first to avoid duplicated work.
104
104
  To properly test if the gem is working properly, you can install it locally:
105
105
  ```sh
106
106
  gem build omie-client.gemspec
107
- gem install ./omie-client.gemspec-x.y.z.gem
107
+ gem install ./omie-client-x.y.z.gem
108
108
  ```
109
109
  The `x.y.z` represents the version described in [lib/omie/version.rb](lib/omie/version.rb)
110
110
 
@@ -117,10 +117,10 @@ irb
117
117
  ```
118
118
 
119
119
  ```ruby
120
- require 'omie-client'
120
+ require 'omie'
121
121
  => true
122
- Omie.version
123
- => x.y.z
122
+ Omie::VERSION
123
+ => "x.y.z"
124
124
  # Default credentials provided by Omie API for tests
125
125
  Omie.app_key = '1560731700'
126
126
  Omie.app_secret = '226dcf372489bb45ceede61bfd98f0f1'
@@ -129,6 +129,16 @@ Omie::Company.list
129
129
  Omie::Product.list
130
130
  ```
131
131
 
132
+ If everything is working fine and you have the proper credentials to upload
133
+ the new version, run:
134
+
135
+ ```sh
136
+ gem push omie-client-x.y.z.gem
137
+ Pushing gem to RubyGems.org...
138
+ Successfully registered gem: omie-client (x.y.z)
139
+ ```
140
+ > You may need to authenticate at rubygems first => https://guides.rubygems.org/make-your-own-gem/
141
+
132
142
  ## License
133
143
 
134
144
  See the [LICENSE](LICENSE) file.
data/lib/omie.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'omie/base_resource'
4
4
  require_relative 'omie/company'
5
+ require_relative 'omie/tax_recommendation'
5
6
  require_relative 'omie/product'
6
7
  require_relative 'omie/connection'
7
8
  require_relative 'omie/error'
@@ -11,7 +11,15 @@ module Omie
11
11
  # values
12
12
  def initialize(args = {})
13
13
  args.each do |key, value|
14
- send("#{key}=", value) if respond_to?(key)
14
+ key_s = key.to_sym
15
+ has_internal_const = self.class.const_defined?('INTERNAL_MODELS')
16
+ if has_internal_const && self.class::INTERNAL_MODELS.key?(key_s)
17
+ klass = self.class::INTERNAL_MODELS[key_s]
18
+ instance = klass.new(value)
19
+ send("#{key}=", instance)
20
+ elsif respond_to?(key_s)
21
+ send("#{key}=", value)
22
+ end
15
23
  end
16
24
  end
17
25
 
@@ -28,6 +36,7 @@ module Omie
28
36
 
29
37
  def self.request_and_initialize(uri, call, params)
30
38
  response = request(uri, call, params)
39
+
31
40
  new(response)
32
41
  end
33
42
  end
data/lib/omie/company.rb CHANGED
@@ -28,7 +28,7 @@ module Omie
28
28
  attr_accessor :email, :cnpj_cpf, :razao_social, :contato, :nome_fantasia
29
29
  attr_accessor :codigo_cliente_integracao, :codigo_cliente_omie, :endereco
30
30
  attr_accessor :cidade, :complemento, :estado, :endereco_numero, :cep
31
- attr_accessor :codigo_pais, :bairro, :inscricao_estadual
31
+ attr_accessor :codigo_pais, :bairro, :inscricao_estadual, :inativa
32
32
 
33
33
  # Record a new company using the
34
34
  # {https://app.omie.com.br/api/v1/geral/clientes/#IncluirCliente
@@ -93,16 +93,22 @@ module Omie
93
93
  # records.
94
94
  #
95
95
  # @!scope class
96
- # @param page [Integer]
97
- # the page to be returned.
98
- # @param per_page [Integer]
99
- # the number of items per page (max: 50).
96
+ # @param [Hash] options
97
+ # The options param follows the same structure described by
98
+ # https://app.omie.com.br/api/v1/geral/clientes/#clientes_list_request
100
99
  # @return [Array<Omie::Company>]
101
100
  # the list of found companies
102
- def self.list(page = 1, per_page = 50)
103
- params = { pagina: page, registros_por_pagina: per_page }
101
+ def self.list(options = {})
102
+ default = {
103
+ pagina: 1, registros_por_pagina: 50,
104
+ apenas_importado_api: 'N'
105
+ }
106
+
107
+ default.each do |k, v|
108
+ options[k] = v unless options.key?(k)
109
+ end
104
110
 
105
- response = request(URI, CALLS[:list], params)
111
+ response = request(URI, CALLS[:list], options)
106
112
  response['clientes_cadastro'].map { |client| Omie::Company.new(client) }
107
113
  rescue Omie::RequestError
108
114
  []
data/lib/omie/product.rb CHANGED
@@ -20,10 +20,16 @@ module Omie
20
20
  associate: 'AssociarCodIntProduto'
21
21
  }.freeze
22
22
 
23
+ INTERNAL_MODELS = {
24
+ recomendacoes_fiscais: Omie::TaxRecommendation
25
+ }.freeze
26
+
23
27
  URI = '/v1/geral/produtos/'
24
28
 
25
29
  attr_accessor :ncm, :valor_unitario, :unidade, :descricao_status
26
30
  attr_accessor :codigo_produto_integracao, :codigo_produto, :descricao
31
+ attr_accessor :codigo, :tipoItem # They do not keep the same name style =(
32
+ attr_accessor :recomendacoes_fiscais # {Omie::TaxRecommendation}
27
33
 
28
34
  # Record a new product using the
29
35
  # {https://app.omie.com.br/api/v1/geral/produtos/#IncluirProduto
@@ -88,16 +94,22 @@ module Omie
88
94
  # records.
89
95
  #
90
96
  # @!scope class
91
- # @param page [Integer]
92
- # the page to be returned.
93
- # @param per_page [Integer]
94
- # the number of items per page (max: 50).
97
+ # @param [Hash] options
98
+ # The options param follows the same structure described by
99
+ # https://app.omie.com.br/api/v1/geral/produtos/#produto_servico_list_request
95
100
  # @return [Array<Omie::Product>]
96
101
  # the list of found companies
97
- def self.list(page = 1, per_page = 50)
98
- params = { pagina: page, registros_por_pagina: per_page }
102
+ def self.list(options = {})
103
+ default = {
104
+ pagina: 1, registros_por_pagina: 50,
105
+ apenas_importado_api: 'N', filtrar_apenas_omiepdv: 'N'
106
+ }
107
+
108
+ default.each do |k, v|
109
+ options[k] = v unless options.key?(k)
110
+ end
99
111
 
100
- response = request(URI, CALLS[:list], params)
112
+ response = request(URI, CALLS[:list], options)
101
113
  response['produto_servico_cadastro'].map do |product|
102
114
  Omie::Product.new(product)
103
115
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omie
4
+ # This class abstracts tax recommendations related to the Product resource
5
+ # from Omie (Ref: Produto). It works as an embedded object inside Product
6
+ # payload. Take a look at this link for more details:
7
+ # {https://app.omie.com.br/api/v1/geral/produtos/}.
8
+ #
9
+ # Different from traditional resources that inherit from {Omie::BaseResource},
10
+ # internal objects does nothing but declares attributes that will comprise
11
+ # a higher level resource's payload. They usually does not have specific
12
+ # endpoints.
13
+ class TaxRecommendation < Omie::BaseResource
14
+ attr_accessor :origem_mercadoria, :id_preco_tabelado, :id_cest,
15
+ :cupom_fiscal, :market_place, :indicador_escala,
16
+ :cnpj_fabricante
17
+ end
18
+ end
data/lib/omie/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Omie
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omie-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peerdustry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -147,6 +147,7 @@ files:
147
147
  - lib/omie/error.rb
148
148
  - lib/omie/info.rb
149
149
  - lib/omie/product.rb
150
+ - lib/omie/tax_recommendation.rb
150
151
  - lib/omie/version.rb
151
152
  - omie-client.gemspec
152
153
  homepage: https://gitlab.com/peerdustry/floss/omie-client