facturapyme 0.0.0
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 +7 -0
- data/lib/facturapyme.rb +64 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9af60b747a9410da8781122d266143e0a317dd17feef100be47ff48d8a656269
|
4
|
+
data.tar.gz: d8a07cd298c2f0a6714456441d87dc6685430dc7b63986c5539709daf0252977
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9e8dbf83eabdc5fa1b3b077ce0aff68a8a32883a4a8ae214ceea94d8e8a963cecc0ef49d403ff169ebfdf557d6921c6023f2702d754c481641dad795005e464
|
7
|
+
data.tar.gz: b6a9978e6504e8f67ea9245e4fc1c9ad10007ef0bdf38a007ba11340aa75c61daa4b4fe6893d54c6859d2c4490e0fbc2f1ae7dfbc50291a08622b4dea7ad4f6c
|
data/lib/facturapyme.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/https'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class FacturaPyme
|
6
|
+
|
7
|
+
def initialize (host, api_key, version = 'v1')
|
8
|
+
@headers = {
|
9
|
+
'User-Agent' => 'SDK FacturaPyme',
|
10
|
+
'Cache-Control' => 'no-cache',
|
11
|
+
'Authorization' => api_key
|
12
|
+
}
|
13
|
+
@url = URI.parse(host+ '/api/'+ version +'/')
|
14
|
+
@http = Net::HTTP.new(@url.host, @url.port)
|
15
|
+
self.ssl(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def debug()
|
19
|
+
@http.set_debug_output($stdout)
|
20
|
+
end
|
21
|
+
|
22
|
+
def ssl(ssl)
|
23
|
+
@http.use_ssl = ssl
|
24
|
+
end
|
25
|
+
|
26
|
+
def get (endPoint)
|
27
|
+
uri = URI.parse(@url.to_s+endPoint)
|
28
|
+
request = Net::HTTP::Get.new(uri.request_uri, @headers)
|
29
|
+
return self.processResponse(@http.request(request))
|
30
|
+
end
|
31
|
+
|
32
|
+
def post(endPoint, data)
|
33
|
+
uri = URI.parse(@url.to_s+endPoint)
|
34
|
+
request = Net::HTTP::Post.new(uri.request_uri, @headers)
|
35
|
+
request.content_type = 'application/json'
|
36
|
+
request.body = JSON.generate(data)
|
37
|
+
return self.processResponse(@http.request(request))
|
38
|
+
end
|
39
|
+
|
40
|
+
def pdf(tipoDte, folio)
|
41
|
+
return self.get('dte/pdf/'+tipoDte.to_s+'/'+folio.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def xml(tipoDte, folio)
|
45
|
+
return self.get('dte/xml/'+tipoDte.to_s+'/'+folio.to_s)
|
46
|
+
end
|
47
|
+
|
48
|
+
def enviaDTE(documento)
|
49
|
+
return self.post('dte', documento)
|
50
|
+
end
|
51
|
+
def estadoDTE(id)
|
52
|
+
return self.get('dte/'+id.to_s)
|
53
|
+
end
|
54
|
+
def processResponse(response)
|
55
|
+
body = response.body
|
56
|
+
if response.content_type == 'application/json'
|
57
|
+
body = JSON.parse(body)
|
58
|
+
end
|
59
|
+
if response.code.to_i > 400
|
60
|
+
raise 'error:['+response.code+']'+body['error']
|
61
|
+
end
|
62
|
+
return body
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: facturapyme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- blackxel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby SDK para integrar API de facturapy.me
|
14
|
+
email: dev@blackxel.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/facturapyme.rb
|
20
|
+
homepage: http://rubygems.org/gems/facturapyme
|
21
|
+
licenses:
|
22
|
+
- Unlicense
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Hola!
|
44
|
+
test_files: []
|