bseller_ruby 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bseller_ruby.gemspec +31 -0
- data/lib/bseller_ruby.rb +21 -0
- data/lib/bseller_ruby/base.rb +100 -0
- data/lib/bseller_ruby/delivery.rb +14 -0
- data/lib/bseller_ruby/item.rb +37 -0
- data/lib/bseller_ruby/order.rb +92 -0
- data/lib/bseller_ruby/price.rb +20 -0
- data/lib/bseller_ruby/purchase.rb +23 -0
- data/lib/bseller_ruby/response.rb +32 -0
- data/lib/bseller_ruby/stock.rb +29 -0
- data/lib/bseller_ruby/tracking.rb +13 -0
- data/lib/bseller_ruby/version.rb +3 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f39d0e4d45bbe244904d06127ffbbd07174ef49
|
4
|
+
data.tar.gz: ed636fff174817508b78b79ab7666a715a95463f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb9a4b73d369fce85bdb147b6a184f6f4ba50fe3698873f4f48a1c17ea085e76d6ee224f84590252809648e8dc1762714158eeb233dd5bec9f75d7ece1e9b124
|
7
|
+
data.tar.gz: 676ea2a3513371767aceb39c1c090b98887759fc1cc4ab94b4ca9a78fd0d65612aa055adf306ab5b048c6bb10db037e81dd4edd471f0c7c2f580c2995d2a89d5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Wesley Conde
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# BsellerRuby
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bseller_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bseller_ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bseller_ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bseller_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bseller_ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bseller_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bseller_ruby"
|
8
|
+
spec.version = BsellerRuby::VERSION
|
9
|
+
spec.authors = ["Wesley Conde"]
|
10
|
+
spec.email = ["kerponeis@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Bseller}
|
13
|
+
spec.description = %q{Bseller API}
|
14
|
+
spec.homepage = "https://github.com/wesleyskap/bseller_ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "savon"
|
23
|
+
spec.add_dependency "rest-client"
|
24
|
+
spec.add_dependency "gyoku", "~> 1.0"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
28
|
+
spec.add_development_dependency "vcr"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
spec.add_development_dependency "webmock"
|
31
|
+
end
|
data/lib/bseller_ruby.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require "savon"
|
3
|
+
require "bseller_ruby/base"
|
4
|
+
require "bseller_ruby/response"
|
5
|
+
require "bseller_ruby/item"
|
6
|
+
require "bseller_ruby/stock"
|
7
|
+
require "bseller_ruby/order"
|
8
|
+
require "bseller_ruby/purchase"
|
9
|
+
require "bseller_ruby/price"
|
10
|
+
require "bseller_ruby/tracking"
|
11
|
+
require "bseller_ruby/delivery"
|
12
|
+
|
13
|
+
module BsellerRuby
|
14
|
+
def self.config!(config)
|
15
|
+
@config = config
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.config
|
19
|
+
@config
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#
|
2
|
+
# Operations provided by your service:
|
3
|
+
# [:get_versao, :consulta_estoque_parcial, :consulta_estoque_total,
|
4
|
+
# :confirma_consulta_estoque_total, :consulta_tracking, :confirma_consulta_tracking,
|
5
|
+
# :confirma_consulta_estoque_parcial, :importa_vales, :confirma_importa_vales,
|
6
|
+
# :envia_pedido, :consulta_entrega, :confirma_consulta_entrega, :consulta_itens,
|
7
|
+
# :confirma_consulta_itens]
|
8
|
+
#
|
9
|
+
module BsellerRuby
|
10
|
+
class Base
|
11
|
+
attr_reader :response
|
12
|
+
|
13
|
+
def initialize(params)
|
14
|
+
params.each do |key, value|
|
15
|
+
instance_variable_set "@#{key}", value
|
16
|
+
define_singleton_method(key) { instance_variable_get "@#{key}" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class << self
|
21
|
+
%w(ws resource_name collection_name).each do |attribute|
|
22
|
+
define_method "#{attribute}=" do |param|
|
23
|
+
instance_variable_set "@#{attribute}", param
|
24
|
+
end
|
25
|
+
|
26
|
+
define_method "#{attribute}" do
|
27
|
+
instance_variable_get "@#{attribute}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def collection_name
|
32
|
+
@collection_name ||= "#{resource_name}s"
|
33
|
+
end
|
34
|
+
|
35
|
+
def call(method, params)
|
36
|
+
@method = method
|
37
|
+
params.merge!(authentication) if params.class.eql?(Hash)
|
38
|
+
Response.new method, api.call(method, message: params)
|
39
|
+
end
|
40
|
+
|
41
|
+
def create(method, params)
|
42
|
+
new response: call(method, params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def get(resource, params = {})
|
46
|
+
json_parse(execute(:get, "#{resource}?#{to_params(params)}"))
|
47
|
+
end
|
48
|
+
|
49
|
+
def post(path, body, &block)
|
50
|
+
json_parse(execute(:post, path, body: body, &block))
|
51
|
+
end
|
52
|
+
|
53
|
+
def put(resource, path, payload)
|
54
|
+
execute(:put, "#{resource}/#{path}", body: payload)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def self.execute(method, path, params = {}, &block)
|
61
|
+
begin
|
62
|
+
params[:payload] = JSON.generate(params[:body]) if params[:body]
|
63
|
+
rescue
|
64
|
+
params[:payload] = params[:body]
|
65
|
+
end
|
66
|
+
headers = { accept: 'application/json', content_type: 'application/json', 'X-AUTH-TOKEN' => ws['json_token'] }
|
67
|
+
RestClient::Request.execute({ verify_ssl: false, method: method, url: "#{ws['json_endpoint']}/#{path}&api_key=#{ws['json_token']}", headers: headers }.merge(params), &block)
|
68
|
+
rescue => e
|
69
|
+
e
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.to_params(params)
|
73
|
+
params.map { |key, value| "#{key}=#{value}" }.join "&"
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.camelize(key)
|
77
|
+
key.to_s.split(/_/).map{ |word| word.capitalize }.join('')
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.json_parse(value)
|
81
|
+
value.class.eql?(String) ? JSON.parse(value) : JSON.parse(value.response)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.api
|
85
|
+
@api ||= Savon.client wsdl: "#{ws['soap_endpoint']}/CPPedido?wsdl", log: ws['log'], read_timeout: 600, open_timeout: 600 do
|
86
|
+
convert_request_keys_to :camelcase
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.ws
|
91
|
+
BsellerRuby.config['ws']
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.authentication
|
95
|
+
@authentication ||= { 'idCia' => ws['cia_id'], 'usuario' => ws['username'], 'senha' => ws['password'] }
|
96
|
+
@method.to_s.end_with?('pedido') ? {} : @authentication
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BsellerRuby
|
2
|
+
class Item < Base
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
# <maxReg />: 9(9), Quantidade máxima de registros a ser retornada.
|
6
|
+
# Se nulo ou zero trás todos os registros disponíveis.
|
7
|
+
#
|
8
|
+
# <confirmaSN />: X(1), Informa se vai chamar a interface confirmaConsultaItens
|
9
|
+
# S – Irá chamar a interface confirmaConsultaItens
|
10
|
+
# N – Não irá chamar a interface confirmaConsultaItens
|
11
|
+
# Se não for informado, considera N
|
12
|
+
#
|
13
|
+
# <tpInterface />: X(15), Interface cadastrada na ESEA0130. Se NULL
|
14
|
+
# envia a interface padrão.
|
15
|
+
def self.get_list(params)
|
16
|
+
call(:consulta_itens, params).result
|
17
|
+
end
|
18
|
+
|
19
|
+
# <confirmaSN />: X(1), Informa se a consulta foi recebida e processada corretamente
|
20
|
+
# S – Recebida e processada corretamente
|
21
|
+
# N – Não foi recebida ou processada corretamente. Na próxima
|
22
|
+
# consulta os dados serão enviados novamente.
|
23
|
+
#
|
24
|
+
# <tpInterface />: X(15), Interface cadastrada na ESEA0130. Se NULL
|
25
|
+
# envia a interface padrão.
|
26
|
+
def self.confirm_to_list!(params)
|
27
|
+
call(:confirma_consulta_itens, params).result
|
28
|
+
end
|
29
|
+
|
30
|
+
#<idItem />: X(50), Sim, Código do item
|
31
|
+
#
|
32
|
+
#<tpInterface />: X(15), Não, Código do tipo de interface
|
33
|
+
def self.find(id_item, interface=nil)
|
34
|
+
get("itens/#{id_item}", interface ? {tpInterface: interface} : nil)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module BsellerRuby
|
2
|
+
class Order < Base
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def self.create!(params)
|
6
|
+
call(:envia_pedido, params).result
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(params)
|
10
|
+
call(:consulta_entrega, params).result
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.find_confirm(params)
|
14
|
+
call(:confirma_consulta_entrega, params).result
|
15
|
+
end
|
16
|
+
|
17
|
+
#def self.sent_purchase
|
18
|
+
#end
|
19
|
+
#
|
20
|
+
# Cabeçalho do Pedido
|
21
|
+
#
|
22
|
+
# => CLIENTEENT
|
23
|
+
#
|
24
|
+
# <P_BAIRRO_ENT />: X(50), Bairro do endereço de entrega
|
25
|
+
# <P_CEP_ENT />: 9(8), CEP do endereço de entrega
|
26
|
+
# <P_CIDADE_ENT />: X(50), Cidade do endereço de entrega
|
27
|
+
# <P_COMPL_ENT />: X(50), Complemento do endereço de entrega
|
28
|
+
# <P_ID_TIPCLIE_ENT />: 9(9), Tipo de cliente de entrega
|
29
|
+
# 1 - Pessoa Jurídica no país
|
30
|
+
# 2 - Pessoa Física no país
|
31
|
+
# 5 - Pessoa Jurídica no País sem IE
|
32
|
+
#
|
33
|
+
# <P_INSEST_ENT/>: X(18), Inscrição Estadual do cliente do
|
34
|
+
# endereço de entrega.
|
35
|
+
# Obrigatório se o P_ID_TIPCLIE_ENT = 1
|
36
|
+
# (Pessoa Jurídica no país)
|
37
|
+
#
|
38
|
+
# <P_LOGRADOURO_ENT />: X(60), Endereço de Entrega
|
39
|
+
# <P_NOME_ENT/>: X(40), Nome do cliente do endereço de entrega
|
40
|
+
# <P_NUMERO_ENT />: 9(6), Número do endereço de entrega
|
41
|
+
# <P_PAIS_ENT />: X(30), País do endereço de entrega. Geralmente Brasil.
|
42
|
+
# <P_REFERENCIA_ENT />: X(100) Ponto de referencia do endereço de entrega
|
43
|
+
# <P_TEL_CELULAR />: X(15), Celular do cliente do endereço de entrega
|
44
|
+
# <P_TEL_COMERCIAL />: X(15), Telefone comercial do cliente do endereço de entrega
|
45
|
+
# <P_TEL_RESIDENCIAL />: X(15), Telefone residencial do cliente do endereço de entrega
|
46
|
+
# <P_UF_ENT />: X(2), Unidade Federativa do endereço de entrega
|
47
|
+
# <P_ZIP_CODE_ ENT />: X(14), ZIP CODE do endereço de entrega
|
48
|
+
#
|
49
|
+
# => CLIENTEFAT
|
50
|
+
#
|
51
|
+
# <P_BAIRRO_FAT/>: X(50) Bairro do endereço de faturamento
|
52
|
+
# <P_CEP_FAT/>: 9(8) CEP do endereço de faturamento
|
53
|
+
# <P_CIDADE_FAT/>: X(50) Cidade do endereço de faturamento
|
54
|
+
# <P_COMPL_FAT/>: X(50) Complemento do endereço de faturamento
|
55
|
+
# <P_DT_NASC/>: D Data de nascimento do cliente do endereço de faturamento - DD/MM/AAAA
|
56
|
+
# <P_EMAIL_FAT/>: X(45) E-mail do cliente de faturamento
|
57
|
+
# <P_FAX_FAT/>: X(15) Fax do cliente de faturamento
|
58
|
+
# <P_ID_CLASF_CLIENTE_FAT/> 9(9) Classificação de cliente
|
59
|
+
# 0 – Normal
|
60
|
+
# 1 – VIP
|
61
|
+
# 2 - Crítico
|
62
|
+
#
|
63
|
+
# <P_ID_CLIENTE_FAT/> 9(14) CPF/CNPJ do cliente de faturamento
|
64
|
+
# <P_ID_TIPCLIE_FAT/> 9(9) Tipo de cliente de faturamento (FK)
|
65
|
+
# 1 - Pessoa Jurídica no país
|
66
|
+
# 2 - Pessoa Física no país
|
67
|
+
# 5 - Pessoa Jurídica no País sem IE
|
68
|
+
#
|
69
|
+
# <P_INSEST_FAT/> X(18) Inscrição estadual do endereço de faturamento.
|
70
|
+
# Obrigatório se P_ID_TIPCLIE_FAT = 1
|
71
|
+
# (Pessoa Jurídica no país)
|
72
|
+
#
|
73
|
+
# <P_LOGRADOURO_FAT/> X(60) Endereço de Faturamento
|
74
|
+
# <P_NOME_FAT/> X(40) Nome do cliente de faturamento
|
75
|
+
# <P_NUMERO_FAT/> 9(6) Número do endereço de faturamento
|
76
|
+
# < P_PAIS_FAT/> X(30) País do endereço de faturamento. Geralmente Brasil.
|
77
|
+
# <P_REFERENCIA_FAT/> X(100) Ponto de referencia do endereço de faturamento
|
78
|
+
# <P_RG/> X(20) RG do cliente de faturamento
|
79
|
+
# <P_SEXO/> X(1) Sexo do cliente do endereço de faturamento:
|
80
|
+
# [F] - Feminino
|
81
|
+
# [M] - Masculino
|
82
|
+
#
|
83
|
+
# <P_TEL_CELULAR/> X(15) Celular do cliente de faturamento
|
84
|
+
# <P_TEL_COMERCIAL/> X(15) Telefone comercial do cliente de faturamento
|
85
|
+
# <P_TEL_RESIDENCIAL/> X(15) Telefone residencial do cliente de faturamento
|
86
|
+
# <P_UF_FAT/> X(2) Unidade Federativa do endereço de faturamento
|
87
|
+
# <P_ZIP_CODE_FAT/> X(14) ZIP CODE do endereço de faturamento
|
88
|
+
# <P_ID_CRT> 9(1) Código do Regime Tributário
|
89
|
+
# 1 – Simples Nacional
|
90
|
+
# 3 – Regime Normal
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BsellerRuby
|
2
|
+
class Price < Base
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def self.list(params = {})
|
6
|
+
get(path, params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.confirm(cod_item, params = {})
|
10
|
+
post("#{path}/status/#{cod_item}?#{to_params(params)}", {})
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.path
|
16
|
+
'itens/precos'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module BsellerRuby
|
2
|
+
class Purchase < Base
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def self.list(params = {})
|
6
|
+
get(path, params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create!(params = {})
|
10
|
+
post("#{path}?", params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.confirm!(params = {})
|
14
|
+
post("#{path}/status?", params)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def self.path
|
20
|
+
'compras/requisicao'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module BsellerRuby
|
4
|
+
class Response
|
5
|
+
include Enumerable
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@savon, :to_s
|
8
|
+
|
9
|
+
def initialize(method, savon)
|
10
|
+
@method = method
|
11
|
+
@savon = savon
|
12
|
+
end
|
13
|
+
|
14
|
+
def result
|
15
|
+
@result = doc
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def doc
|
21
|
+
@method =~ /confirm|envia_pedido/ || savon_hash =~ /CallableStatementCallback|PED_CLIENTE|sucesso/ ? savon_hash : xml_parser(savon_hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def xml_parser(xml)
|
25
|
+
@xml_parser ||= Nori.new(convert_tags_to: lambda { |tag| tag.snakecase.to_sym }).parse(xml)
|
26
|
+
end
|
27
|
+
|
28
|
+
def savon_hash
|
29
|
+
@savon_hash ||= @savon.hash[:envelope][:body]["#{@method}_response".to_sym]["#{@method}_return".to_sym]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module BsellerRuby
|
2
|
+
class Stock < Base
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
# <confirmaSN />: X(1), Informa se a consulta foi recebida e processada corretamente
|
6
|
+
# S – Recebida e processada corretamente
|
7
|
+
# N – Não foi recebida ou processada corretamente. Na próxima
|
8
|
+
# consulta os dados serão enviados novamente.
|
9
|
+
#
|
10
|
+
# <tpInterface />: X(15), Interface cadastrada na ESEA0130. Se NULL
|
11
|
+
# envia a interface padrão.
|
12
|
+
|
13
|
+
def self.get_total(params)
|
14
|
+
call(:consulta_estoque_total, params).result
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.confirm_to_total_list!(params)
|
18
|
+
call(:confirma_consulta_estoque_total, params).result
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_partial(params)
|
22
|
+
call(:consulta_estoque_parcial, params).result
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.confirm_to_partial_list!(params)
|
26
|
+
call(:confirma_consulta_estoque_parcial, params).result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bseller_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wesley Conde
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gyoku
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Bseller API
|
140
|
+
email:
|
141
|
+
- kerponeis@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
|
+
- CODE_OF_CONDUCT.md
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- bin/console
|
155
|
+
- bin/setup
|
156
|
+
- bseller_ruby.gemspec
|
157
|
+
- lib/bseller_ruby.rb
|
158
|
+
- lib/bseller_ruby/base.rb
|
159
|
+
- lib/bseller_ruby/delivery.rb
|
160
|
+
- lib/bseller_ruby/item.rb
|
161
|
+
- lib/bseller_ruby/order.rb
|
162
|
+
- lib/bseller_ruby/price.rb
|
163
|
+
- lib/bseller_ruby/purchase.rb
|
164
|
+
- lib/bseller_ruby/response.rb
|
165
|
+
- lib/bseller_ruby/stock.rb
|
166
|
+
- lib/bseller_ruby/tracking.rb
|
167
|
+
- lib/bseller_ruby/version.rb
|
168
|
+
homepage: https://github.com/wesleyskap/bseller_ruby
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.4.8
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Bseller
|
192
|
+
test_files: []
|