dtefacil_xml_builder 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,52 @@ class DteBuilder
|
|
12
12
|
#builder.actividadEconomica "asdfas"
|
13
13
|
end
|
14
14
|
|
15
|
+
def create_emisor nombre
|
16
|
+
builder = Builder::XmlMarkup.new :target => STDOUT
|
17
|
+
builder.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
18
|
+
builder.usuario(tipo: "emisor", xmlns: "http://dtefacil.cl/1.2"){
|
19
|
+
|u|
|
20
|
+
u.nombre nombre;
|
21
|
+
u.clave "123456";
|
22
|
+
u.sucursal{
|
23
|
+
|s|
|
24
|
+
s.nombre "primera";
|
25
|
+
s.codigo 4;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def self.gen_xml invoice, payment, client
|
32
|
+
xml = Builder::XmlMarkup.new
|
33
|
+
xml.instruct!(:xml, version: "1.0", encoding: "ISO-8859-1")
|
34
|
+
xml.facturaElectronica(xmlns: "http://dtefacil.cl/1.2"){
|
35
|
+
|fac|
|
36
|
+
fac.actividadEconomica 1234; #actividad economica de Acid
|
37
|
+
fac.receptor {
|
38
|
+
|rec|
|
39
|
+
rec.rut client.rut.first(client.rut.size - 1) + "-" + client.rut.last
|
40
|
+
rec.razonSocial client.name;
|
41
|
+
rec.giro client.giro;
|
42
|
+
rec.ubicacion {
|
43
|
+
|ub|
|
44
|
+
ub.direccion client.adress; #address feo feo feo
|
45
|
+
ub.comuna client.comuna;
|
46
|
+
ub.ciudad client.ciudad;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
fac.detalles {
|
50
|
+
|dets|
|
51
|
+
dets.detalle {
|
52
|
+
|det|
|
53
|
+
det.nombre payment.name;
|
54
|
+
det.cantidad 1;
|
55
|
+
det.precioUnitario invoice.amount;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
15
61
|
|
16
62
|
def create_detalles detalles, descuento
|
17
63
|
builder = Builder::XmlMarkup.new
|
@@ -17,11 +17,17 @@ module DtefacilXmlBuilder
|
|
17
17
|
#body = f.render_xml
|
18
18
|
#f.render_xml
|
19
19
|
#response = RestClient.get 'https://ptoTicket:pt0T1ck3t@api.dtefacil.cl/1.2/usuarios/yo'
|
20
|
-
|
20
|
+
db = DteBuilder.new
|
21
|
+
@emisor= db.create_emisor "emisor48"
|
22
|
+
#@emisor = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><usuario tipo=\"emisor\" xmlns=\"http://dtefacil.cl/1.2\"><nombre>emisor4</nombre><clave>1234567</clave><sucursal><nombre>segunda</nombre><codigo>4</codigo></sucursal></usuario>"
|
21
23
|
|
24
|
+
#delete_url= 'https://ptoTicket:pt0T1ck3t@api.dtefacil.cl/1.2/usuarios/emisores/dupzglfpvqbfx7mq7ownb5nrz7m?purgar=true'
|
22
25
|
|
23
|
-
response = RestClient.post
|
24
|
-
|
26
|
+
#response = RestClient.post , @emisor, content_type: "application/xml"
|
27
|
+
#response = RestClient.delete(delete_url)
|
28
|
+
response = RestClient.post "https://api.dtefacil.cl/1.2/usuarios/emisores/", @emisor, {content_type: "application/xml", authorization: "Basic cHRvVGlja2V0OnB0MFQxY2szdA=="}
|
29
|
+
puts response
|
30
|
+
#puts response.headers[:location]
|
25
31
|
|
26
32
|
end
|
27
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtefacil_xml_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|