Skip to content

Commit d6dfe9a

Browse files
authored
Merge pull request #207 from FacturAPI/update/send-edit-link
Update/send edit link
2 parents 6c971cc + e339af4 commit d6dfe9a

File tree

3 files changed

+300
-0
lines changed

3 files changed

+300
-0
lines changed

website/docs/guides/customers.mdx

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,113 @@ curl https://www.facturapi.io/v1/customers \
260260
```
261261

262262
</details>
263+
264+
## Crear cliente con enlace de edición
265+
266+
Según convenga a tu flujo, puedes crear un cliente proporcionando únicamente el correo electrónico y el parámetro `createEditLink: true`. Esto genera un enlace que puedes enviar al cliente para que él mismo complete sus datos fiscales.
267+
268+
<Tabs groupId="editLinkExamples">
269+
<TabItem value="js" label="Node.js" default>
270+
271+
```javascript
272+
const customer = await facturapi.customers.create({
273+
email: "cliente@ejemplo.com"
274+
}, {
275+
createEditLink: true
276+
});
277+
```
278+
279+
</TabItem>
280+
<TabItem value="cs" label="C#">
281+
282+
```csharp
283+
var customer = await facturapi.Customer.CreateAsync(new Dictionary<string, object>
284+
{
285+
["email"] = "cliente@ejemplo.com"
286+
}, new Dictionary<string, object>
287+
{
288+
["createEditLink"] = true
289+
});
290+
```
291+
292+
</TabItem>
293+
<TabItem value="php" label="PHP">
294+
295+
```php
296+
$customer = $facturapi->Customers->create([
297+
"email" => "cliente@ejemplo.com"
298+
], [
299+
"createEditLink" => true
300+
]);
301+
```
302+
303+
</TabItem>
304+
<TabItem value="curl" label="cURL">
305+
306+
```bash
307+
curl https://www.facturapi.io/v2/customers \
308+
-H "Authorization: Bearer sk_test_API_KEY" \
309+
-H "Content-Type: application/json" \
310+
-d '{
311+
"email": "cliente@ejemplo.com"
312+
}' \
313+
-G --data-urlencode 'createEditLink=true'
314+
```
315+
316+
</TabItem>
317+
</Tabs>
318+
319+
El objeto de respuesta incluirá el campo `edit_link`, que es el enlace que puedes enviar por correo electrónico al cliente:
320+
321+
```json
322+
{
323+
"id": "62714bc2d1bfa410df1d98eb",
324+
"email": "cliente@ejemplo.com",
325+
"edit_link": "https://auto.facturapi.io/tax-info/abcd1234"
326+
}
327+
```
328+
329+
Puedes enviar este enlace al cliente usando tu propio sistema de correo, para que él mismo complete sus datos fiscales directamente en Facturapi.
330+
331+
<Tabs groupId="sendEditLinkExamples">
332+
<TabItem value="js" label="Node.js" default>
333+
334+
```javascript
335+
await facturapi.customers.sendEditLinkByEmail("62714bc2d1bfa410df1d98eb", {
336+
email: "cliente@ejemplo.com" // Opcional, si no se incluye se usará el email del cliente
337+
});
338+
```
339+
340+
</TabItem>
341+
<TabItem value="cs" label="C#">
342+
343+
```csharp
344+
await facturapi.Customer.SendEditLinkByEmailAsync("62714bc2d1bfa410df1d98eb", new Dictionary<string, object>
345+
{
346+
["email"] = "cliente@ejemplo.com" // Opcional, si no se incluye se usará el email del cliente
347+
});
348+
```
349+
350+
</TabItem>
351+
<TabItem value="php" label="PHP">
352+
353+
```php
354+
$facturapi->Customers->sendEditLinkByEmail("62714bc2d1bfa410df1d98eb", [
355+
"email" => "cliente@ejemplo.com" // Opcional, si no se incluye se usará el email del cliente
356+
]);
357+
```
358+
359+
</TabItem>
360+
<TabItem value="curl" label="cURL">
361+
362+
```bash
363+
curl -X POST https://www.facturapi.io/v2/customers/62714bc2d1bfa410df1d98eb/email-edit-link \
364+
-H "Authorization: Bearer sk_test_API_KEY" \
365+
-H "Content-Type: application/json" \
366+
-d '{
367+
"email": "cliente@ejemplo.com" // Opcional, si no se incluye se usará el email del cliente
368+
}'
369+
```
370+
371+
</TabItem>
372+
</Tabs>

website/i18n/en/docusaurus-plugin-content-docs/current/guides/customers.mdx

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,113 @@ curl https://www.facturapi.io/v1/customers \
258258
```
259259
260260
</details>
261+
262+
## Create customer with edit link
263+
264+
Depending on your workflow, you can create a customer by providing only the email address and the parameter `createEditLink: true`. This generates a link that you can send to the customer so they can complete their own tax information.
265+
266+
<Tabs groupId="editLinkExamples">
267+
<TabItem value="js" label="Node.js" default>
268+
269+
```javascript
270+
const customer = await facturapi.customers.create({
271+
email: "customer@example.com"
272+
}, {
273+
createEditLink: true
274+
});
275+
```
276+
277+
</TabItem>
278+
<TabItem value="cs" label="C#">
279+
280+
```csharp
281+
var customer = await facturapi.Customer.CreateAsync(new Dictionary<string, object>
282+
{
283+
["email"] = "customer@example.com"
284+
}, new Dictionary<string, object>
285+
{
286+
["createEditLink"] = true
287+
});
288+
```
289+
290+
</TabItem>
291+
<TabItem value="php" label="PHP">
292+
293+
```php
294+
$customer = $facturapi->Customers->create([
295+
"email" => "customer@example.com"
296+
], [
297+
"createEditLink" => true
298+
]);
299+
```
300+
301+
</TabItem>
302+
<TabItem value="curl" label="cURL">
303+
304+
```bash
305+
curl https://www.facturapi.io/v2/customers \
306+
-H "Authorization: Bearer sk_test_API_KEY" \
307+
-H "Content-Type: application/json" \
308+
-d '{
309+
"email": "customer@example.com"
310+
}' \
311+
-G --data-urlencode 'createEditLink=true'
312+
```
313+
314+
</TabItem>
315+
</Tabs>
316+
317+
The response object will include the `edit_link` field, which is the link you can send to the customer by email:
318+
319+
```json
320+
{
321+
"id": "62714bc2d1bfa410df1d98eb",
322+
"email": "customer@example.com",
323+
"edit_link": "https://auto.facturapi.io/tax-info/abcd1234"
324+
}
325+
```
326+
327+
You can send this link to the customer using your own email system, so they can complete their tax information directly in Facturapi.
328+
329+
<Tabs groupId="sendEditLinkExamples">
330+
<TabItem value="js" label="Node.js" default>
331+
332+
```javascript
333+
await facturapi.customers.sendEditLinkByEmail("62714bc2d1bfa410df1d98eb", {
334+
email: "customer@example.com" // Optional, if not included the customer's email will be used
335+
});
336+
```
337+
338+
</TabItem>
339+
<TabItem value="cs" label="C#">
340+
341+
```csharp
342+
await facturapi.Customer.SendEditLinkByEmailAsync("62714bc2d1bfa410df1d98eb", new Dictionary<string, object>
343+
{
344+
["email"] = "customer@example.com" // Optional, if not included the customer's email will be used
345+
});
346+
```
347+
348+
</TabItem>
349+
<TabItem value="php" label="PHP">
350+
351+
```php
352+
$facturapi->Customers->sendEditLinkByEmail("62714bc2d1bfa410df1d98eb", [
353+
"email" => "customer@example.com" // Optional, if not included the customer's email will be used
354+
]);
355+
```
356+
357+
</TabItem>
358+
<TabItem value="curl" label="cURL">
359+
360+
```bash
361+
curl -X POST https://www.facturapi.io/v2/customers/62714bc2d1bfa410df1d98eb/email-edit-link \
362+
-H "Authorization: Bearer sk_test_API_KEY" \
363+
-H "Content-Type: application/json" \
364+
-d '{
365+
"email": "customer@example.com" // Optional, if not included the customer's email will be used
366+
}'
367+
```
368+
369+
</TabItem>
370+
</Tabs>

website/openapi_v2.en.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,86 @@ paths:
990990
$ref: "#/components/responses/Unauthenticated"
991991
"500":
992992
$ref: "#/components/responses/UnexpectedError"
993+
/customers/{customer_id}/email-edit-link:
994+
post:
995+
operationId: sendEditLinkByEmail
996+
tags:
997+
- customer
998+
summary: Send edit link by email
999+
description: |
1000+
Sends a link for the customer to edit their fiscal information.
1001+
1002+
This link will be available in the `edit_link` field, valid for 7 days and can only be used once.
1003+
x-codeSamples:
1004+
- lang: Bash
1005+
label: cURL
1006+
source: |
1007+
curl https://www.facturapi.io/v2/customers/590ce6c56d04f840aa8438af/email-edit-link \
1008+
-H "Authorization: Bearer sk_test_API_KEY" \
1009+
-X POST \
1010+
-d '{
1011+
"email": "email@example.com"
1012+
}'
1013+
- lang: JavaScript
1014+
label: Node.js
1015+
source: |
1016+
import Facturapi from 'facturapi'
1017+
const facturapi = new Facturapi('sk_test_API_KEY');
1018+
1019+
await facturapi.customers.sendEditLinkByEmail('67bf1239b15b44fb9269e6a8', {
1020+
email: 'email@example.com' // Optional, if not provided, the customer's email will be used
1021+
});
1022+
- lang: csharp
1023+
label: C#
1024+
source: |
1025+
await facturapi.Customer.SendEditLinkByEmailAsync("67bf1239b15b44fb9269e6a8", new Dictionary<string, object>
1026+
{
1027+
["email"] = "email@example.com" // Optional, if not provided, the customer's email will be used
1028+
});
1029+
- lang: PHP
1030+
label: PHP
1031+
source: |
1032+
$customer = $facturapi->Customers->sendEditLinkByEmail("67bf1239b15b44fb9269e6a8", [
1033+
"email" => "email@example.com" // Optional, if not provided, the customer's email will be used
1034+
]);
1035+
parameters:
1036+
- in: path
1037+
name: customer_id
1038+
schema:
1039+
type: string
1040+
required: true
1041+
description: ID of the `Customer` object to edit
1042+
requestBody:
1043+
required: false
1044+
content:
1045+
application/json:
1046+
schema:
1047+
type: object
1048+
properties:
1049+
email:
1050+
type: string
1051+
description: Customer's email. If not provided, the customer's email will be used.
1052+
security:
1053+
- "SecretLiveKey": []
1054+
- "SecretTestKey": []
1055+
responses:
1056+
"200":
1057+
description: Edit link sent successfully
1058+
content:
1059+
application/json:
1060+
schema:
1061+
type: object
1062+
properties:
1063+
ok:
1064+
type: boolean
1065+
description: Indicates if the link was sent successfully
1066+
example: true
1067+
"400":
1068+
$ref: "#/components/responses/BadRequest"
1069+
"401":
1070+
$ref: "#/components/responses/Unauthenticated"
1071+
"500":
1072+
$ref: "#/components/responses/UnexpectedError"
9931073
/customers/{customer_id}/tax-info-validation:
9941074
get:
9951075
operationId: validateCustomerTaxInfo

0 commit comments

Comments
 (0)