Skip to content

Commit 73ce2a4

Browse files
authored
Add Java SDK (#246)
* docs: add Java SDK examples * docs: add sdk language cards * docs: address copilot review comments
1 parent b84d403 commit 73ce2a4

36 files changed

Lines changed: 3933 additions & 15 deletions

website/docs/getting-started/authenticate.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ const facturapi = new Facturapi('<SECRET_KEY>');
3232
var facturapi = new FacturapiClient("<SECRET_KEY>");
3333
```
3434

35+
</TabItem>
36+
<TabItem value="java" label="Java">
37+
38+
```java
39+
import io.facturapi.Facturapi;
40+
41+
Facturapi facturapi = new Facturapi("<SECRET_KEY>");
42+
```
43+
3544
</TabItem>
3645
<TabItem value="php" label="PHP">
3746

website/docs/getting-started/install.mdx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ sidebar_position: 2
44

55
import Tabs from '@theme/Tabs';
66
import TabItem from '@theme/TabItem';
7+
import LanguageStrip from '@site/src/components/LanguageStrip';
78

89
# Instalación del SDK
910

1011
Contamos con librerías oficiales para los siguientes lenguajes:
1112

12-
- Node.js
13-
- C#
14-
- PHP
13+
<LanguageStrip />
1514

1615
Si usas algún otro lenguaje, aún puedes consumir la API usando tu propio cliente HTTP.
1716

@@ -39,6 +38,28 @@ desde Visual Studio, o bien, desde la terminal del Package Manager:
3938
dotnet add package Facturapi
4039
```
4140

41+
</TabItem>
42+
<TabItem value="java" label="Java">
43+
44+
Instala el [paquete de Maven Central](https://central.sonatype.com/artifact/io.facturapi/facturapi-java).
45+
Elige el bloque que corresponda con tu herramienta de construcción.
46+
47+
Usando Maven:
48+
49+
```xml
50+
<dependency>
51+
<groupId>io.facturapi</groupId>
52+
<artifactId>facturapi-java</artifactId>
53+
<version>1.0.0</version>
54+
</dependency>
55+
```
56+
57+
Usando Gradle:
58+
59+
```gradle
60+
implementation("io.facturapi:facturapi-java:1.0.0")
61+
```
62+
4263
</TabItem>
4364
<TabItem value="php" label="PHP">
4465

@@ -73,6 +94,13 @@ import Facturapi from 'facturapi';
7394
using Facturapi;
7495
```
7596

97+
</TabItem>
98+
<TabItem value="java" label="Java">
99+
100+
```java
101+
import io.facturapi.Facturapi;
102+
```
103+
76104
</TabItem>
77105
<TabItem value="php" label="PHP">
78106

website/docs/guides/customer-edit-link.mdx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ var newCustomer = facturapi.Customer.CreateAsync(new Dictionary<string, object>
5252
});
5353
```
5454

55+
</TabItem>
56+
<TabItem value="java" label="Java">
57+
58+
```java
59+
import io.facturapi.Facturapi;
60+
import java.util.Map;
61+
62+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
63+
var newCustomer = facturapi.customers().create(
64+
Map.of("email", "email@example.com"),
65+
Map.of("createEditLink", true)
66+
);
67+
```
68+
5569
</TabItem>
5670
<TabItem value="php" label="PHP">
5771

@@ -110,6 +124,16 @@ const customer = await facturapi.customers.retrieve('67bf1239b15b44fb9269e6a8');
110124
var customer = await facturapi.Customer.RetrieveAsync("67bf1239b15b44fb9269e6a8");
111125
```
112126

127+
</TabItem>
128+
<TabItem value="java" label="Java">
129+
130+
```java
131+
import io.facturapi.Facturapi;
132+
133+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
134+
var customer = facturapi.customers().retrieve("67bf1239b15b44fb9269e6a8");
135+
```
136+
113137
</TabItem>
114138
<TabItem value="php" label="PHP">
115139

@@ -174,6 +198,21 @@ var customer = await facturapi.Customer.UpdateAsync("67bf1239b15b44fb9269e6a8",
174198
});
175199
```
176200

201+
</TabItem>
202+
<TabItem value="java" label="Java">
203+
204+
```java
205+
import io.facturapi.Facturapi;
206+
import java.util.Map;
207+
208+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
209+
var customer = facturapi.customers().update(
210+
"67bf1239b15b44fb9269e6a8",
211+
Map.of(),
212+
Map.of("createEditLink", true)
213+
);
214+
```
215+
177216
</TabItem>
178217
<TabItem value="php" label="PHP">
179218

@@ -231,6 +270,19 @@ await facturapi.Customer.SendEditLinkByEmailAsync("67bf1239b15b44fb9269e6a8", ne
231270
});
232271
```
233272

273+
</TabItem>
274+
<TabItem value="java" label="Java">
275+
276+
```java
277+
import io.facturapi.Facturapi;
278+
279+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
280+
facturapi.customers().sendEditLinkByEmail(
281+
"67bf1239b15b44fb9269e6a8",
282+
"email@example.com"
283+
);
284+
```
285+
234286
</TabItem>
235287
<TabItem value="php" label="PHP">
236288

@@ -251,4 +303,4 @@ curl https://www.facturapi.io/v2/customers/67bf1239b15b44fb9269e6a8/email-edit-l
251303
```
252304

253305
</TabItem>
254-
</Tabs>
306+
</Tabs>

website/docs/guides/customers.mdx

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ var customer = await facturapi.Customer.CreateAsync(new Dictionary<string, objec
7878
});
7979
```
8080

81+
</TabItem>
82+
<TabItem value="java" label="Java">
83+
84+
```java
85+
import io.facturapi.Facturapi;
86+
import java.util.Map;
87+
88+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
89+
var customer = facturapi.customers().create(Map.of(
90+
"legal_name", "Dunder Mifflin",
91+
"tax_id", "ABC101010111",
92+
"tax_system", "601",
93+
"email", "email@example.com",
94+
"address", Map.of("zip", "85900")
95+
), null);
96+
```
97+
8198
</TabItem>
8299
<TabItem value="php" label="PHP">
83100

@@ -200,6 +217,26 @@ var customer = await facturapi.Customer.CreateAsync(new Dictionary<string, objec
200217
});
201218
```
202219

220+
</TabItem>
221+
<TabItem value="java" label="Java">
222+
223+
```java
224+
import io.facturapi.Facturapi;
225+
import java.util.Map;
226+
227+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
228+
var customer = facturapi.customers().create(Map.of(
229+
"legal_name", "Vättenfall, A.B.",
230+
"tax_id", "198912171234",
231+
"email", "email@example.com",
232+
"address", Map.of(
233+
"country", "SWE",
234+
"zip", "17123",
235+
"city", "Stockholm"
236+
)
237+
), null);
238+
```
239+
203240
</TabItem>
204241
<TabItem value="php" label="PHP">
205242

@@ -289,6 +326,19 @@ var customer = await facturapi.Customer.CreateAsync(new Dictionary<string, objec
289326
});
290327
```
291328

329+
</TabItem>
330+
<TabItem value="java" label="Java">
331+
332+
```java
333+
import io.facturapi.Facturapi;
334+
import java.util.Map;
335+
336+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
337+
var customer = facturapi.customers().create(Map.of(
338+
"email", "cliente@ejemplo.com"
339+
), Map.of("createEditLink", true));
340+
```
341+
292342
</TabItem>
293343
<TabItem value="php" label="PHP">
294344

@@ -347,6 +397,16 @@ await facturapi.Customer.SendEditLinkByEmailAsync("62714bc2d1bfa410df1d98eb", ne
347397
});
348398
```
349399

400+
</TabItem>
401+
<TabItem value="java" label="Java">
402+
403+
```java
404+
facturapi.customers().sendEditLinkByEmail(
405+
"62714bc2d1bfa410df1d98eb",
406+
"cliente@ejemplo.com"
407+
);
408+
```
409+
350410
</TabItem>
351411
<TabItem value="php" label="PHP">
352412

@@ -369,4 +429,4 @@ curl -X POST https://www.facturapi.io/v2/customers/62714bc2d1bfa410df1d98eb/emai
369429
```
370430

371431
</TabItem>
372-
</Tabs>
432+
</Tabs>

website/docs/guides/drafts.mdx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,36 @@ var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object>
8484
});
8585
```
8686

87+
</TabItem>
88+
<TabItem value="java" label="Java">
89+
90+
```java
91+
import io.facturapi.Facturapi;
92+
import java.util.HashMap;
93+
import java.util.List;
94+
import java.util.Map;
95+
96+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
97+
Map<String, Object> body = new HashMap<>();
98+
body.put("status", "draft");
99+
body.put("customer", null);
100+
body.put("items", List.of(Map.of(
101+
"quantity", 2,
102+
"product", Map.of(
103+
"description", "Ukelele",
104+
"product_key", "60131324",
105+
"price", 345.60,
106+
"taxes", List.of(Map.of(
107+
"type", "IVA",
108+
"rate", 0.16
109+
))
110+
)
111+
)));
112+
body.put("use", "G01");
113+
body.put("payment_form", "28");
114+
var invoice = facturapi.invoices().create(body, null);
115+
```
116+
87117
</TabItem>
88118
<TabItem value="php" label="PHP">
89119

@@ -193,6 +223,25 @@ var invoice = await facturapi.Invoice.UpdateDraft(new Dictionary<string, object>
193223
});
194224
```
195225

226+
</TabItem>
227+
<TabItem value="java" label="Java">
228+
229+
```java
230+
import io.facturapi.Facturapi;
231+
import java.util.Map;
232+
233+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
234+
var invoice = facturapi.invoices().updateDraft("[INVOICE_ID]", Map.of(
235+
"customer", Map.of(
236+
"legal_name", "Dunder Mifflin",
237+
"email", "email@example.com",
238+
"tax_id", "ABC101010111",
239+
"tax_system", "601",
240+
"address", Map.of("zip", "85900")
241+
)
242+
));
243+
```
244+
196245
</TabItem>
197246
<TabItem value="php" label="PHP">
198247

website/docs/guides/invoices/async-invoices.mdx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,43 @@ var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object>
102102
});
103103
```
104104

105+
</TabItem>
106+
<TabItem value="java" label="Java">
107+
108+
```java
109+
import io.facturapi.Facturapi;
110+
import java.util.List;
111+
import java.util.Map;
112+
113+
Facturapi facturapi = new Facturapi("sk_test_API_KEY");
114+
var invoice = facturapi.invoices().create(
115+
Map.of(
116+
"customer", Map.of(
117+
"legal_name", "Dunder Mifflin",
118+
"email", "email@example.com",
119+
"tax_id", "ABC101010111",
120+
"tax_system", "601",
121+
"address", Map.of("zip", "85900")
122+
),
123+
"items", List.of(Map.of(
124+
"quantity", 2,
125+
"product", Map.of(
126+
"description", "Ukelele",
127+
"product_key", "60131324",
128+
"price", 345.60,
129+
"taxes", List.of(Map.of(
130+
"type", "IVA",
131+
"rate", 0.16
132+
))
133+
)
134+
)),
135+
"use", "G01",
136+
"payment_form", "28"
137+
),
138+
Map.of("async", true)
139+
);
140+
```
141+
105142
</TabItem>
106143
<TabItem value="php" label="PHP">
107144

@@ -219,4 +256,4 @@ curl https://www.facturapi.io/v2/invoices \
219256
"stamp": null,
220257
"uuid": null
221258
}
222-
```
259+
```

0 commit comments

Comments
 (0)