docs: add delete record by id section

This commit is contained in:
Stevan Freeborn
2023-04-15 21:48:13 -05:00
parent 3418306f6a
commit aeed070d89
7 changed files with 283 additions and 11 deletions
+2 -1
View File
@@ -8,6 +8,7 @@
"markdoc",
"notnull",
"Onpsring",
"prismjs"
"prismjs",
"utcnow"
]
}
@@ -1 +1,25 @@
# Delete Record by Id {% #delete-record-by-id %}
This endpoint allows you to delete a record from an app. When successful, a `204` response will be returned with no body.
## Path Parameters
{% table %}
- Parameter Name
- Data Type
- Description
---
- appId
- `number`
- The id of the app that contains the record.
---
- recordId
- `number`
- The id of the record to delete.
{% /table %}
@@ -1 +1,62 @@
# Deleting a record from an app
{% code method="DELETE" heading="/Records/appId/{appId}/recordId/{recordId}" defaultLanguage="bash" %}
```bash
curl --location --request DELETE 'https://api.onspring.com/Records/appId/195/recordId/140' \
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' \
--data ''
```
```csharp
using Onspring.API.SDK;
using System.Net;
var onspringClient = new OnspringClient(
config.BaseUrl,
config.ApiKey
);
var appId =195;
var recordId = 140;
var deleteResponse = await onspringClient.DeleteRecordAsync(appId, recordId);
if (deleteResponse.StatusCode == HttpStatusCode.NoContent)
{
Console.WriteLine("Record deleted");
}
```
```javascript
import { OnspringClient } from 'onspring-api-sdk';
const client = new OnspringClient(
process.env.BASE_URL,
process.env.API_KEY
);
const res = await client.deleteRecordById(195, 140);
res.statusCode === 204
? console.log('Record deleted')
: console.log('Error deleting record');
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
cfg.read('config.ini')
key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.DeleteRecordById(appId=195, recordId=140)
print(f'Status Code: {response.statusCode}')
print(f'Message: {response.message}')
```
{% /code %}
@@ -5,13 +5,12 @@
```bash
curl --location 'https://api.onspring.com/Records/batch-get' \
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' \
--header 'x-api-version: 2' \
--header 'Content-Type: application/json' \
--data '{
"AppId": 195,
"RecordIds": [1],
"FieldIds": [6983,6986,6987,6985,6984],
"DataFormat": "Raw"
"appId": 195,
"recordIds": [1],
"fieldIds": [6983,6986,6987,6985,6984],
"dataFormat": "Raw"
}'
```
@@ -5,13 +5,12 @@
```bash
curl --location 'https://api.onspring.com/Records/Query' \
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' \
--header 'x-api-version: 2' \
--header 'Content-Type: application/json' \
--data '{
"AppId": 195,
"Filter": "6983 eq '\''Test Task 5'\''",
"FieldIds": [6983,6986,6987,6985,6984],
"DataFormat": "Formatted"
"appId": 195,
"filter": "6983 eq '\''Test Task 5'\''",
"fieldIds": [6983,6986,6987,6985,6984],
"dataFormat": "Formatted"
}'
```
@@ -1 +1,53 @@
# Save Record {% #save-record %}
This endpoint allows you to add or update a record in an app. If a record id is provided in the request, the record will be updated and a `200` response will be returned. If no record id is provided, a new record will be created and a `201` response will be returned. When successful the response will contain the record id of the record that was created or updated and any warnings that were encountered.
## Request Body Properties
{% table %}
- Property Name
- Data Type
- Description
---
- appId
- `number`
- The id of the app that contains or will contain the record.
---
- recordId
- `number`
- The id of the record to update. If this property is not provided, a new record will be created.
---
- fields
- `object`
- An object containing the field values to save. The keys of the object should be the field ids and the values should be the field values. The field values should be in the format that is expected by the field type.
{% /table %}
## Response Body Properties
{% table %}
- Property Name
- Data Type
- Description
---
- recordId
- `number`
- The id of the record that was created or updated.
---
- warnings
- `string[]`
- An array of warnings that were encountered while saving the record.
{% /table %}
@@ -1 +1,137 @@
# Add a record to an app
{% code method="PUT" heading="/Records" defaultLanguage="bash" %}
```bash
curl --location --request PUT 'https://api.onspring.com/Records' \
--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' \
--header 'Content-Type: application/json' \
--data '{
"appId": 195,
"recordId": null,
"fields": {
6983: "A New Test Task",
6984: "This is a test task.",
6985: "12/25/2021",
6986: "4118d53a-9121-4345-8682-07f23d606daa",
6987: [4]
}
}'
```
```csharp
using Onspring.API.SDK;
using Onspring.API.SDK.Models;
var onspringClient = new OnspringClient(
config.BaseUrl,
config.ApiKey
);
var record = new ResultRecord
{
AppId = 195,
FieldData = new List<RecordFieldValue>
{
new StringFieldValue(6983, "A New Test Task"),
new StringFieldValue(6984, "This is a test task."),
new DateFieldValue(6985, DateTime.Parse("12/25/2021")),
new GuidFieldValue(6986, Guid.Parse("4118d53a-9121-4345-8682-07f23d606daa")),
new IntegerListFieldValue(6987, new List<int> { 4 }),
},
};
var saveResponse = await onspringClient.SaveRecordAsync(record);
Console.WriteLine($"New Record Id is: {saveResponse.Value.Id}");
foreach (string warning in saveResponse.Value.Warnings)
{
Console.WriteLine($"Warning: {warning}");
}
```
```javascript
import {
DateRecordValue,
GuidRecordValue,
IntegerListRecordValue,
OnspringClient,
Record,
StringRecordValue,
} from 'onspring-api-sdk';
import dotenv from 'dotenv';
dotenv.config();
const client = new OnspringClient(
process.env.BASE_URL,
process.env.API_KEY
);
const record = new Record(195, null);
record.addValues([
new StringRecordValue(6983, 'A New Test Task'),
new StringRecordValue(6984, 'This is a test task.'),
new DateRecordValue(6985, new Date('12/25/2021')),
new GuidRecordValue(
6986,
'4118d53a-9121-4345-8682-07f23d606daa'
),
new IntegerListRecordValue(6987, [4]),
]);
const res = await client.saveRecord(record);
const newRecordId = res.data.id;
console.log(newRecordId);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import StringFieldValue, GuidFieldValue, DateFieldValue, IntegerListValue, Record
from configparser import ConfigParser
fields = []
fields.append(StringFieldValue(6983, 'A New Test Task'))
fields.append(StringFieldValue(6984, 'This is a test task.'))
fields.append(
GuidFieldValue(
6986,
uuid.UUID('4118d53a-9121-4345-8682-07f23d606daa')
)
)
fields.append(
DateFieldValue(
6985,
datetime.datetime(2021, 12, 25)
)
)
fields.append(IntegerListValue(6987, [4]))
record = Record(
appId=195,
fields
)
response = client.AddOrUpdateRecord(record)
print(f'Status Code: {response.statusCode}')
print(f'Id: {response.data.id}')
for warning in response.data.warnings:
print(f'Warning: {warning}')
```
{% /code %}
{% code heading="Response" defaultLanguage="json" %}
```json
{
"warnings": [],
"id": 140
}
```
{% /code %}