nfe-io 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +54 -20
- data/lib/nfe/api_resource.rb +12 -7
- data/lib/nfe/company.rb +1 -1
- data/lib/nfe/legal_people.rb +1 -1
- data/lib/nfe/natural_people.rb +1 -1
- data/lib/nfe/nfe_object.rb +1 -1
- data/lib/nfe/version.rb +1 -1
- data/lib/nfe.rb +10 -1
- data/nfe.gemspec +1 -1
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462baea3afbbf2e706d4f0614335c717e047f14f
|
4
|
+
data.tar.gz: a6907b9e971630d68a3fefc9c7e69d457718ff23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37f28eeafc6a09ab816c4c864ea21deb2f16b47c4506de13cde8587edc3f33c0c22a1e2098e952e849b3e8bc5130da5df7fa1d08246ea2746a5937b98c3606a6
|
7
|
+
data.tar.gz: 7b08e015a31e6c6a474e93e9fdfab8f37e96885d0018fc9bd8aaf56dc1b47d2c40d0adae7b0ea2d07126f9e4008032e1db1200b4272db190b8aad94942e5a5f4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.1
|
data/README.md
CHANGED
@@ -1,43 +1,77 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/
|
1
|
+
[![Build Status](https://travis-ci.org/nfe/client-ruby.svg?branch=master)](https://travis-ci.org/nfe/client-ruby.svg?branch=master)
|
2
2
|
|
3
|
-
#
|
3
|
+
# NFe.io para Ruby
|
4
4
|
|
5
|
-
|
5
|
+
## Instalação
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this line to your application's Gemfile:
|
7
|
+
Incluir essa linha no Gemfile da sua aplicação:
|
12
8
|
|
13
9
|
```ruby
|
14
|
-
gem 'nfe'
|
10
|
+
gem 'nfe-io'
|
15
11
|
```
|
16
12
|
|
17
|
-
|
13
|
+
E depois execute:
|
18
14
|
|
19
15
|
$ bundle
|
20
16
|
|
21
|
-
|
17
|
+
Ou instale diretamente via comando:
|
22
18
|
|
23
|
-
$ gem install nfe
|
19
|
+
$ gem install nfe-io
|
24
20
|
|
25
|
-
##
|
21
|
+
## Exemplos de uso
|
26
22
|
|
27
|
-
|
23
|
+
### Emitir nota fiscal
|
24
|
+
```ruby
|
28
25
|
|
29
|
-
|
26
|
+
# Define a API Key, conforme está no painel
|
27
|
+
Nfe.api_key('c73d49f9649046eeba36dcf69f6334fd')
|
28
|
+
|
29
|
+
# ID da empresa, você encontra no painel
|
30
|
+
Nfe::ServiceInvoice.company_id("55df4dc6b6cd9007e4f13ee8")
|
31
|
+
|
32
|
+
# Dados do Tomador dos Serviços
|
33
|
+
customer_params = {
|
34
|
+
borrower: {
|
35
|
+
federalTaxNumber: '191', # CNPJ ou CPF (opcional para tomadores no exterior)
|
36
|
+
name: 'BANCO DO BRASIL SA', # Nome da pessoa física ou Razão Social da Empresa
|
37
|
+
email: 'nfe-io@mailinator.com', # Email para onde deverá ser enviado a nota fiscal
|
38
|
+
# Endereço do tomador
|
39
|
+
address: {
|
40
|
+
country: 'BRA', # Código do pais com três letras
|
41
|
+
postalCode: '70073901', # CEP do endereço (opcional para tomadores no exterior)
|
42
|
+
street: 'Rua Do Cliente', # Logradouro
|
43
|
+
number: 'S/N', # Número (opcional)
|
44
|
+
additionalInformation: 'QUADRA 01 BLOCO G', # Complemento (opcional)
|
45
|
+
district: 'Asa Sul', # Bairro
|
46
|
+
city: { # Cidade é opcional para tomadores no exterior
|
47
|
+
code: 4204202, # Código do IBGE para a Cidade
|
48
|
+
name: 'Brasilia' # Nome da Cidade
|
49
|
+
},
|
50
|
+
state: 'DF'
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
# Dados da nota fiscal de serviço
|
56
|
+
service_params = {
|
57
|
+
cityServiceCode: '2690', # Código do serviço de acordo com o a cidade
|
58
|
+
description: 'Teste, para manutenção e suporte técnico.', # Descrição dos serviços prestados
|
59
|
+
servicesAmount: 0.1 # Valor total do serviços
|
60
|
+
}
|
61
|
+
|
62
|
+
# Emite a nota fiscal
|
63
|
+
invoice_create_result = Nfe::ServiceInvoice.create(customer_params.merge(service_params))
|
30
64
|
|
31
|
-
|
65
|
+
```
|
32
66
|
|
33
|
-
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).
|
34
67
|
|
35
|
-
##
|
68
|
+
## Contribuir
|
36
69
|
|
37
|
-
|
70
|
+
Envio de bugs e pull requests são muito bem vindos no https://github.com/nfe/client-ruby.
|
38
71
|
|
39
72
|
|
40
73
|
## License
|
41
74
|
|
42
|
-
|
75
|
+
Originalmente criado pela equipe da [Pluga](https://github.com/PlugaDotCo).
|
43
76
|
|
77
|
+
Esta gem é open source sob os termos da [Licença MIT](http://opensource.org/licenses/MIT).
|
data/lib/nfe/api_resource.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Nfe
|
2
2
|
module ApiResource
|
3
|
-
BASE_URL = 'http://api.nfe.io'
|
4
3
|
SSL_BUNDLE_PATH = File.dirname(__FILE__) + '/../data/ssl-bundle.crt'
|
5
4
|
|
6
5
|
def url_encode(key)
|
@@ -12,7 +11,7 @@ module Nfe
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def api_request(url, method, params=nil)
|
15
|
-
url = "#{
|
14
|
+
url = "#{Nfe.configuration.url}#{url}"
|
16
15
|
api_key = Nfe.access_keys
|
17
16
|
|
18
17
|
if method == :get && params
|
@@ -23,10 +22,16 @@ module Nfe
|
|
23
22
|
|
24
23
|
begin
|
25
24
|
payload = params.to_json
|
26
|
-
response = RestClient::Request.new(
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
response = RestClient::Request.new(
|
26
|
+
method: method,
|
27
|
+
url: url,
|
28
|
+
payload: payload,
|
29
|
+
headers: {
|
30
|
+
content_type: 'application/json',
|
31
|
+
accept: '*/*',
|
32
|
+
authorization: api_key,
|
33
|
+
user_agent: Nfe.configuration.user_agent
|
34
|
+
}).execute
|
30
35
|
|
31
36
|
rescue RestClient::ExceptionWithResponse => e
|
32
37
|
if rcode = e.http_code and rbody = e.http_body
|
@@ -47,4 +52,4 @@ module Nfe
|
|
47
52
|
base.extend(ApiResource)
|
48
53
|
end
|
49
54
|
end
|
50
|
-
end
|
55
|
+
end
|
data/lib/nfe/company.rb
CHANGED
data/lib/nfe/legal_people.rb
CHANGED
data/lib/nfe/natural_people.rb
CHANGED
data/lib/nfe/nfe_object.rb
CHANGED
data/lib/nfe/version.rb
CHANGED
data/lib/nfe.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rest-client"
|
2
2
|
require "json"
|
3
3
|
require "nfe/version"
|
4
|
+
require "nfe/configure"
|
4
5
|
|
5
6
|
require "nfe/api_resource"
|
6
7
|
require "nfe/api_operations/create"
|
@@ -29,4 +30,12 @@ module Nfe
|
|
29
30
|
def self.access_keys
|
30
31
|
"#{@@api_key}"
|
31
32
|
end
|
32
|
-
|
33
|
+
|
34
|
+
def self.configuration
|
35
|
+
@configuration ||= Configuration.new
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.configure
|
39
|
+
yield(configuration) if block_given?
|
40
|
+
end
|
41
|
+
end
|
data/nfe.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_dependency "rest-client", "~>
|
30
|
+
spec.add_dependency "rest-client", "~> 2.0.2"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.10"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nfe-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Caldeira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '10.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Nfe.io's ruby gem
|
@@ -73,11 +73,11 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .ruby-gemset
|
79
|
+
- .ruby-version
|
80
|
+
- .travis.yml
|
81
81
|
- Gemfile
|
82
82
|
- LICENSE.txt
|
83
83
|
- README.md
|
@@ -111,17 +111,17 @@ require_paths:
|
|
111
111
|
- lib
|
112
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - '>='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- -
|
119
|
+
- - '>='
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.0.14.1
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Nfe.io's ruby gem
|