omie-client 0.1.5 → 0.1.9
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/omie.rb +1 -0
- data/lib/omie/base_resource.rb +10 -1
- data/lib/omie/company.rb +14 -8
- data/lib/omie/product.rb +17 -16
- data/lib/omie/tax_recommendation.rb +18 -0
- data/lib/omie/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b8ab8d390aaaf20e0d60b18a1bc7712f05db081326ff570d79c22274c72780
|
4
|
+
data.tar.gz: 3d16f6cfe5083df91eb117a431179911847d083ee62b9ae074fc7800baba2589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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.
|
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
data/lib/omie/base_resource.rb
CHANGED
@@ -11,7 +11,15 @@ module Omie
|
|
11
11
|
# values
|
12
12
|
def initialize(args = {})
|
13
13
|
args.each do |key, value|
|
14
|
-
|
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
|
97
|
-
# the
|
98
|
-
#
|
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(
|
103
|
-
|
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],
|
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
|
93
|
-
# the
|
94
|
-
#
|
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
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
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
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
|
+
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:
|
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
|