millennium 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 5f2d5dc760da4e924e4cce9e9bb1df20913dba2d
4
- data.tar.gz: 5b7374c4ec41549d9b232ae5c5dba6c4db0e2e49
3
+ metadata.gz: d9500716a164644123f709a410faddf429dbcb64
4
+ data.tar.gz: 6dc6a152008b99a00afb7a1a9d59768e92a53e91
5
5
  SHA512:
6
- metadata.gz: 72dcdcb3e73aef7830a620c6be51e631f91f3b44c4279cfe50337e734aeac9c10a68782c84e08b86326a31d68012cdee5b2d1404165556698c5974d19fe4a2f0
7
- data.tar.gz: 85d4afcfadb8a99eaeb0499d518ed09e900e153bedf03c6000366adee440d1035511bd5b39673f6fa819c7943487724e4f34ad46f21bd3d68a191b96ea82159d
6
+ metadata.gz: e7c3c56307851f2b47ad9bb8eb02142e8874111fa619177f08600a57af5e913cdf43d19c6ebe0579f88be702c6bb84abb33335b4723bdbfc6ce2ff9d284ffee9
7
+ data.tar.gz: 596d5c7a3382ce00ce3d696634c714372524244a3b28254c98d73badaa67d70e6f769ad8f6520b170ab59ab64ba4e9b3ee92b17949e10d073345b934f7c5ee46
data/README.md CHANGED
@@ -36,23 +36,8 @@ end
36
36
 
37
37
  ### Buscando uma compra faturada
38
38
 
39
- **Parâmetros**
40
-
41
- | Parâmetro | Obrigatório | Tipo | Descrição |
42
- | ------------------------ | :---------: | :--------------------------------: | ---------------------------------- |
43
- | data_atualizacao | Não | String (formato: YYYY-mm-dd-H-M-S) | Data de atualização |
44
- | vitrine | Não | Integer | Id da vitrine |
45
- | saida_inicial | Não | Integer | Id da saida ou entrada que será usado como ponto de partida |
46
- | trans_id | Não | Integer | Trans_id para a listagem das notas fiscais, as notas fiscais serão listadas a partir desse trans_id. Trans_id é um campo numérico que indica quando um item foi alterado |
47
- | aprovado | Não | Boolean | Listar somente notas aprovadas |
48
- | cancelada | Não | Boolean | Listar somente as notas canceladas |
49
- | data_atualizacao_inicial | Não | String (formato: YYYY-mm-dd-H-M-S) | Data inicial do período desejado |
50
- | data_atualizacao_final | Não | String (formato: YYYY-mm-dd-H-M-S) | Data final do período desejado |
51
-
52
- **Exemplo:**
53
-
54
39
  ```ruby
55
- clientes = Millennium::PedidoVenda.lista_faturamentos({
40
+ Millennium::PedidoVenda.lista_faturamentos({
56
41
  data_atualizacao_inicial: '2016-01-01-00-00-00',
57
42
  data_atualizacao_final: '2016-10-26-23-59-59',
58
43
  })
@@ -2,29 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/clientes/clientes.rb
4
4
  class Clientes
5
- class << self
6
- OBJECT = 'Clientes'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- consulta_por_documento: 'ConsultaPorDocumento',
10
- incluir_ou_alterar: 'IncluirOuAlterar',
11
- consulta_endereco: 'ConsultaEndereco',
12
- consulta_credito: 'ConsultaCredito',
13
- reserva_credito: 'ReservaCredito',
14
- lista: 'Lista'
15
- }.freeze
16
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'Clientes'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
17
10
 
18
- ENDPOINTS_NAMES.each do |method_name, endpoint|
19
- define_method method_name do |params = {}|
20
- url = "#{OBJECT}/#{endpoint}?$format=json"
21
- unless params.empty?
22
- query = Millennium::Helpers.mount_query(params)
23
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
24
- end
25
- Millennium::Request.run(url)
26
- end
27
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
28
13
  end
29
14
  end
30
15
  end
@@ -2,7 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/crm/crm.rb
4
4
  class CRM
5
- class << self
5
+ def initialize(endpoint, params)
6
+ @object = 'CRM'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
10
+
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
6
13
  end
7
14
  end
8
15
  end
@@ -2,31 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/crm_chamados/crm_chamados.rb
4
4
  class CRMChamados
5
- class << self
6
- OBJECT = 'Crm.Chamados'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- inclui_relacionamento: 'IncluiRelacionamento',
10
- lista_origens_chamado: 'ListaOrigensChamado',
11
- lista_tipos_chamado: 'ListaTiposChamado',
12
- inclui_comentario: 'IncluiComentario',
13
- lista_sub_motivos: 'ListaSubMotivos',
14
- lista_motivos: 'ListaMotivos',
15
- inclui: 'Inclui',
16
- fecha: 'Fecha'
17
- }.freeze
18
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'Crm.Chamados'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
19
10
 
20
- ENDPOINTS_NAMES.each do |method_name, endpoint|
21
- define_method method_name do |params = {}|
22
- url = "#{OBJECT}/#{endpoint}?$format=json"
23
- unless params.empty?
24
- query = Millennium::Helpers.mount_query(params)
25
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
26
- end
27
- Millennium::Request.run(url)
28
- end
29
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
30
13
  end
31
14
  end
32
15
  end
@@ -7,5 +7,11 @@ module Millennium
7
7
  query << "#{key}=#{value}&"
8
8
  end
9
9
  end
10
+
11
+ def self.full_endpoint(object, endpoint, params)
12
+ return "#{object}/#{endpoint}?$format=json" if params.empty?
13
+ query = mount_query(params)
14
+ "#{object}/#{endpoint}?#{query}$format=json"
15
+ end
10
16
  end
11
17
  end
@@ -2,23 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/modulo/modulo.rb
4
4
  class Modulo
5
- class << self
6
- OBJECT = 'Module'.freeze
7
- private_constant :OBJECT
8
-
9
- ENDPOINTS_NAMES = { permissions: 'Permissions' }.freeze
10
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'Module'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
11
10
 
12
- ENDPOINTS_NAMES.each do |method_name, endpoint|
13
- define_method method_name do |params = {}|
14
- url = "#{OBJECT}/#{endpoint}?$format=json"
15
- unless params.empty?
16
- query = Millennium::Helpers.mount_query(params)
17
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
18
- end
19
- Millennium::Request.run(url)
20
- end
21
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
22
13
  end
23
14
  end
24
15
  end
@@ -2,36 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/pedido_venda/pedido_venda.rb
4
4
  class PedidoVenda
5
- class << self
6
- OBJECT = 'Pedido_Venda'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- lista_faturamentos: 'ListaFaturamentos',
10
- consulta_status_wf: 'ConsultaStatusWF',
11
- lista_operadoras: 'ListaOperadoras',
12
- consulta_simples: 'ConsultaSimples',
13
- consulta_produto: 'ConsultaProduto',
14
- consulta_xml_nfe: 'ConsultaXmlNFe',
15
- lista_bandeiras: 'ListaBandeiras',
16
- consulta_status: 'ConsultaStatus',
17
- lista_tipo_pgto: 'ListaTipoPgto',
18
- consulta_itens: 'Consulta_Itens',
19
- lista_pedidos: 'ListaPedidos',
20
- consulta: 'Consulta',
21
- lista: 'Lista'
22
- }.freeze
23
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'Pedido_Venda'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
24
10
 
25
- ENDPOINTS_NAMES.each do |method_name, endpoint|
26
- define_method method_name do |params = {}|
27
- url = "#{OBJECT}/#{endpoint}?$format=json"
28
- unless params.empty?
29
- query = Millennium::Helpers.mount_query(params)
30
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
31
- end
32
- Millennium::Request.run(url)
33
- end
34
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
35
13
  end
36
14
  end
37
15
  end
@@ -1,33 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module Millennium
3
3
  # lib/millennium/produtos/produtos.rb
4
- class Produtos
5
- class << self
6
- OBJECT = 'Produtos'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- atualiza_produtos_vitrine: 'AtualizaProdutosVitrine',
10
- atualiza_saldo_de_estoque: 'AtualizaSaldoDeEstoque',
11
- atualiza_preco_de_tabela: 'AtualizaPrecoDeTabela',
12
- lista_relacionados: 'ListaRelacionados',
13
- saldo_de_estoque: 'SaldoDeEstoque',
14
- preco_de_tabela: 'PrecoDeTabela',
15
- lista_id_fotos: 'ListaIdFotos',
16
- lista_vitrine: 'ListaVitrine',
17
- busca_foto: 'BuscaFoto'
18
- }.freeze
19
- private_constant :ENDPOINTS_NAMES
4
+ class PedidoVenda
5
+ def initialize(endpoint, params)
6
+ @object = 'Produtos'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
20
10
 
21
- ENDPOINTS_NAMES.each do |method_name, endpoint|
22
- define_method method_name do |params = {}|
23
- url = "#{OBJECT}/#{endpoint}?$format=json"
24
- unless params.empty?
25
- query = Millennium::Helpers.mount_query(params)
26
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
27
- end
28
- Millennium::Request.run(url)
29
- end
30
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
31
13
  end
32
14
  end
33
15
  end
@@ -2,37 +2,33 @@
2
2
  module Millennium
3
3
  # lib/millennium/request.rb
4
4
  class Request
5
- class << self
6
- def run(endpoint)
7
- url = mount_url(endpoint)
8
- make_request(url)
9
- end
5
+ HOSTNAME = Millennium::Config.host || 'millennium.iwise.com.br'
6
+ PORT = Millennium::Config.port || '888'
10
7
 
11
- private
8
+ OPTIONS = {
9
+ userpwd: "#{Millennium::Config.user}:#{Millennium::Config.pass}",
10
+ httpauth: :ntlm,
11
+ verbose: true
12
+ }.freeze
12
13
 
13
- def make_request(url)
14
- Typhoeus::Request.new(url, options).run
15
- end
14
+ private_constant :HOSTNAME
15
+ private_constant :PORT
16
+ private_constant :OPTIONS
16
17
 
17
- def mount_url(endpoint)
18
- hostname = Millennium::Config.host || 'millennium.iwise.com.br'
19
- port = Millennium::Config.port || '888'
18
+ def initialize(object, endpoint, params)
19
+ @full_endpoint = Millennium::Helpers.full_endpoint(
20
+ object, endpoint, params
21
+ )
22
+ end
20
23
 
21
- "http://#{hostname}:#{port}/api/millenium_eco/#{endpoint}"
22
- end
24
+ def run
25
+ Typhoeus::Request.new(url, OPTIONS).run
26
+ end
23
27
 
24
- def options
25
- {
26
- userpwd: userpwd,
27
- httpauth: :ntlm,
28
- verbose: true
29
- }
30
- end
28
+ private
31
29
 
32
- def userpwd
33
- config = Millennium::Config
34
- "#{config.user}:#{config.pass}"
35
- end
30
+ def url
31
+ "http://#{HOSTNAME}:#{PORT}/api/millenium_eco/#{@full_endpoint}"
36
32
  end
37
33
  end
38
34
  end
@@ -1,27 +1,15 @@
1
1
  # encoding: utf-8
2
2
  module Millennium
3
3
  # lib/millennium/transportadoras/transportadoras.rb
4
- class Transportadoras
5
- class << self
6
- OBJECT = 'Transportadoras'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- atualiza_saldo_de_estoque: 'ConsultaPorDocumento',
10
- atualiza_preco_de_tabela: 'IncluirOuAlterar',
11
- atualiza_produtos_vitrine: 'CalculaFrete'
12
- }.freeze
13
- private_constant :ENDPOINTS_NAMES
4
+ class PedidoVenda
5
+ def initialize(endpoint, params)
6
+ @object = 'Transportadoras'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
14
10
 
15
- ENDPOINTS_NAMES.each do |method_name, endpoint|
16
- define_method method_name do |params = {}|
17
- url = "#{OBJECT}/#{endpoint}?$format=json"
18
- unless params.empty?
19
- query = Millennium::Helpers.mount_query(params)
20
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
21
- end
22
- Millennium::Request.run(url)
23
- end
24
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
25
13
  end
26
14
  end
27
15
  end
@@ -2,28 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/troca_devolucao/troca_devolucao.rb
4
4
  class TrocaDevolucao
5
- class << self
6
- OBJECT = 'TrocaDevolucao'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- lista_para_troca_devolucao: 'ListaParaTrocaDevolucao',
10
- consulta_credito: 'ConsultaCredito',
11
- reserva_credito: 'ReservaCredito',
12
- inclui: 'Inclui',
13
- lista: 'Lista'
14
- }.freeze
15
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'TrocaDevolucao'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
16
10
 
17
- ENDPOINTS_NAMES.each do |method_name, endpoint|
18
- define_method method_name do |params = {}|
19
- url = "#{OBJECT}/#{endpoint}?$format=json"
20
- unless params.empty?
21
- query = Millennium::Helpers.mount_query(params)
22
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
23
- end
24
- Millennium::Request.run(url)
25
- end
26
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
27
13
  end
28
14
  end
29
15
  end
@@ -1,4 +1,4 @@
1
1
  # lib/millennium/version.rb
2
2
  module Millennium
3
- VERSION = '0.0.3'.freeze
3
+ VERSION = '0.0.4'.freeze
4
4
  end
@@ -2,29 +2,14 @@
2
2
  module Millennium
3
3
  # lib/millennium/vitrine/vitrine.rb
4
4
  class Vitrine
5
- class << self
6
- OBJECT = 'Vitrine'.freeze
7
- private_constant :OBJECT
8
- ENDPOINTS_NAMES = {
9
- atualiza_status_produtos: 'Atualiza_Status_Produtos',
10
- atualiza_classificacoes: 'Atualiza_Classificacoes',
11
- lista_classificacoes: 'Lista_Classificacoes',
12
- atualiza_status: 'Atualiza_Status',
13
- atualiza_log: 'Atualiza_Log',
14
- lista_status: 'Lista_Status'
15
- }.freeze
16
- private_constant :ENDPOINTS_NAMES
5
+ def initialize(endpoint, params)
6
+ @object = 'Vitrine'
7
+ @endpoint = endpoint
8
+ @params = params
9
+ end
17
10
 
18
- ENDPOINTS_NAMES.each do |method_name, endpoint|
19
- define_method method_name do |params = {}|
20
- url = "#{OBJECT}/#{endpoint}?$format=json"
21
- unless params.empty?
22
- query = Millennium::Helpers.mount_query(params)
23
- url = "#{OBJECT}/#{endpoint}?#{query}$format=json"
24
- end
25
- Millennium::Request.run(url)
26
- end
27
- end
11
+ def run
12
+ Millennium::Request.new(@object, @endpoint, @params).run
28
13
  end
29
14
  end
30
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: millennium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Henrique Bruce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2016-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus