omie-client 0.1.5 → 0.1.9

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: 93709fdff9221e8360fe0c77374ff883659d5e158fc8bfa1353dad9c961470f9
4
- data.tar.gz: bf3d5191c9d1479515d665a1b36ec1e1fb420cb0f6d9823946129c475b2190de
3
+ metadata.gz: d6b8ab8d390aaaf20e0d60b18a1bc7712f05db081326ff570d79c22274c72780
4
+ data.tar.gz: 3d16f6cfe5083df91eb117a431179911847d083ee62b9ae074fc7800baba2589
5
5
  SHA512:
6
- metadata.gz: f672cb89d67a4587c0bb42ea780627f28669e45bc4b92d0b0159ead56e8965e557f7a3b473c59980fcd451a8d6229d068bb2fa9b780c62bb693c357e8ba7d1f2
7
- data.tar.gz: e0a1dd775e8897a5f1c1c192e1e748315a23b8942ae05de01654c47b1fa31d77090aceb33ba8ea14399ebe5c8c12019b24aaa21b788986e3a975bb2de11f1fd2
6
+ metadata.gz: c828f93902a3e07a73f4427ce69b9aec8514050170eb310a6bbb93c26bd01a5c13624302cf01fa423b66772f928f3406e07bb4bc324620e6a78de4435751e91d
7
+ data.tar.gz: 9f1663956aa61d1cb3eec5a4d85bcb8c8c80639842c3e1b72b88f250ea5593b2da74e96694fff58d526c00c6790a56954b72c389ff06343edb20e784e3478f1c
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/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, :inativo
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,11 +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
27
31
  attr_accessor :codigo, :tipoItem # They do not keep the same name style =(
32
+ attr_accessor :recomendacoes_fiscais # {Omie::TaxRecommendation}
28
33
 
29
34
  # Record a new product using the
30
35
  # {https://app.omie.com.br/api/v1/geral/produtos/#IncluirProduto
@@ -89,26 +94,22 @@ module Omie
89
94
  # records.
90
95
  #
91
96
  # @!scope class
92
- # @param page [Integer]
93
- # the page to be returned.
94
- # @param per_page [Integer]
95
- # the number of items per page (max: 50).
96
- # @param only_imported [String]
97
- # related to 'apenas_importado_api' params, accept 'S' or 'N'.
98
- # @param only_pdv [String]
99
- # related to 'filtrar_apenas_omiepdv' params, accept 'S' or 'N'.
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
100
100
  # @return [Array<Omie::Product>]
101
101
  # the list of found companies
102
- def self.list(
103
- page = 1, per_page = 50, only_imported = 'N', only_pdv = 'N'
104
- )
105
- params = {
106
- pagina: page, registros_por_pagina: per_page,
107
- apenas_importado_api: only_imported,
108
- filtrar_apenas_omiepdv: only_pdv
102
+ def self.list(options = {})
103
+ default = {
104
+ pagina: 1, registros_por_pagina: 50,
105
+ apenas_importado_api: 'N', filtrar_apenas_omiepdv: 'N'
109
106
  }
110
107
 
111
- response = request(URI, CALLS[:list], params)
108
+ default.each do |k, v|
109
+ options[k] = v unless options.key?(k)
110
+ end
111
+
112
+ response = request(URI, CALLS[:list], options)
112
113
  response['produto_servico_cadastro'].map do |product|
113
114
  Omie::Product.new(product)
114
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.5'
4
+ VERSION = '0.1.9'
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.5
4
+ version: 0.1.9
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-24 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