From 46f93c82244321179f8886c39be58e40982dcd1f Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 25 Apr 2023 07:30:01 -0500 Subject: [PATCH] docs: add update record section to version 1 --- src/docs/version_001/docsStructure.ts | 6 ++ .../resources/records/add_record/copy.md | 2 +- .../resources/records/add_record/example.md | 2 +- .../resources/records/update_record/copy.md | 57 +++++++++++++++++++ .../records/update_record/example.md | 52 +++++++++++++++++ 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 src/docs/version_001/resources/records/update_record/copy.md create mode 100644 src/docs/version_001/resources/records/update_record/example.md diff --git a/src/docs/version_001/docsStructure.ts b/src/docs/version_001/docsStructure.ts index fdc46c2..1809880 100644 --- a/src/docs/version_001/docsStructure.ts +++ b/src/docs/version_001/docsStructure.ts @@ -170,6 +170,12 @@ export const versionOne: DocsStructure = { copy: 'copy.md', example: 'example.md', }, + { + title: 'Update Record', + folder: 'update_record', + copy: 'copy.md', + example: 'example.md', + }, ], }, { diff --git a/src/docs/version_001/resources/records/add_record/copy.md b/src/docs/version_001/resources/records/add_record/copy.md index efd1f0a..5ad1a3c 100644 --- a/src/docs/version_001/resources/records/add_record/copy.md +++ b/src/docs/version_001/resources/records/add_record/copy.md @@ -1,6 +1,6 @@ # Add Record {% #add-record %} -This endpoint allows you to add a record to an app. If the record creation was successful you will receive a `201` response. +This endpoint allows you to add a record to an app. If the record creation was successful a `201` response will be returned. ## Path Parameters diff --git a/src/docs/version_001/resources/records/add_record/example.md b/src/docs/version_001/resources/records/add_record/example.md index dc15d9d..7aa3ab9 100644 --- a/src/docs/version_001/resources/records/add_record/example.md +++ b/src/docs/version_001/resources/records/add_record/example.md @@ -35,7 +35,7 @@ var result = httpHelper.CreateAppRecord(195, fieldValues); Console.WriteLine($"New Record Id is: {result.CreatedId}"); -foreach (string warning in result.Warnings) +foreach (var warning in result.Warnings) { Console.WriteLine($"Warning: {warning}"); } diff --git a/src/docs/version_001/resources/records/update_record/copy.md b/src/docs/version_001/resources/records/update_record/copy.md new file mode 100644 index 0000000..b36e518 --- /dev/null +++ b/src/docs/version_001/resources/records/update_record/copy.md @@ -0,0 +1,57 @@ +# Update Record {% #update-record %} + +This endpoint allows you to update a record in an app. If the record update is successful and no warnings are encountered a `204` response will be returned with an empty body. If warnings are encountered a `200` response will be returned with the body containing the warnings encountered. + +## Path Parameters + +{% table %} + +- Parameter Name +- Data Type +- Description + +--- + +- appId +- `number` +- The id of the app or survey that the record will be added to. + +--- + +- recordId +- `number` +- The id of the record that will be updated. + +{% /table %} + +## Request Body Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- FieldData +- `object` +- The field data to be used to update the record. Each `key` should be an id of a field you want to populate and its `value` should be the value you want to place into that field. + +{% /table %} + +## Response Body Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- Warnings +- `string[]` +- A list of warnings related to the records creation. Will only be present if warnings were in fact generated by the request. + +{% /table %} diff --git a/src/docs/version_001/resources/records/update_record/example.md b/src/docs/version_001/resources/records/update_record/example.md new file mode 100644 index 0000000..4b51c79 --- /dev/null +++ b/src/docs/version_001/resources/records/update_record/example.md @@ -0,0 +1,52 @@ +# Add a record in an app + +{% code method="PUT" heading="/Records/{appId}/{recordId}" defaultLanguage="bash" %} + +```bash +curl --location --request PUT 'https://api.onspring.com/v1/Records/195/12' \ +--header 'Content-Type: application/json' \ +--data '{ + "FieldData": { + "6983": "An Updated 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.Helpers; + +var httpHelper = new HttpHelper( + config.baseUrl, + config.apiKey +); + +var fieldValues = new FieldAddEditContainer(); +fieldValues.Add(6983, "An Updated Test Task") +fieldValues.Add(6984, "This is a test task."); +fieldValues.Add(6985, "12/25/2021"); +fieldValues.Add(6986, "4118d53a-9121-4345-8682-07f23d606daa"); +fieldValues.Add(6987, new[] {4}) + +var result = httpHelper.UpdateAppRecord(195, 12, fieldValues); + +foreach (var warning in result.Warnings) +{ + Console.WriteLine($"Warning: {warning}"); +} +``` + +{% /code %} + +{% code heading="RESPONSE" defaultLanguage="json" %} + +```json +{ + "Warnings": ["A warning"] +} +``` + +{% /code %}