From c1d20205db43ab3dcc22e3d15335dbc7867a0890 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 17 Apr 2023 22:19:28 -0500 Subject: [PATCH] docs: add get field by id section --- .../resources/fields/get_field_by_id/copy.md | 18 ++++ .../fields/get_field_by_id/example.md | 97 +++++++++++++++++++ .../fields/get_fields_by_app/copy.md | 16 +++ .../fields/get_fields_by_app/example.md | 6 +- 4 files changed, 134 insertions(+), 3 deletions(-) diff --git a/src/docs/version_002/resources/fields/get_field_by_id/copy.md b/src/docs/version_002/resources/fields/get_field_by_id/copy.md index b172825..cd4a4ef 100644 --- a/src/docs/version_002/resources/fields/get_field_by_id/copy.md +++ b/src/docs/version_002/resources/fields/get_field_by_id/copy.md @@ -1 +1,19 @@ # Get Field by Id {% #get-field-by-id %} + +This endpoint returns a [Field](#fields) by its id. + +## Path Parameters + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- fieldId +- `number` +- The id of the field to retrieve. + +{% /table %} diff --git a/src/docs/version_002/resources/fields/get_field_by_id/example.md b/src/docs/version_002/resources/fields/get_field_by_id/example.md index 5a080b6..9283018 100644 --- a/src/docs/version_002/resources/fields/get_field_by_id/example.md +++ b/src/docs/version_002/resources/fields/get_field_by_id/example.md @@ -1 +1,98 @@ # Retrieve a field by its id + +{% code method="GET" heading="/Fields/id/{fieldId}" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/Fields/id/6986' \ +--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' +``` + +```csharp +using Onspring.API.SDK; + +var onspringClient = new OnspringClient( + config.BaseUrl, + config.ApiKey +); + +var response = await onspringClient.GetFieldAsync(6986); +var field = response.Value; + +Console.WriteLine($"{field.Id}"); +``` + +```javascript +import { OnspringClient } from 'onspring-api-sdk'; +import dotenv from 'dotenv'; +dotenv.config(); + +const client = new OnspringClient( + process.env.BASE_URL, + process.env.API_KEY +); + +const res = await client.getFieldById(6986); +const field = res.data; + +console.log(field); +``` + +```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.GetFieldById(fieldId=6986) + +print(f'Status Code: {response.statusCode}') +print(f'Field Id: {response.data.id}') +``` + +{% /code %} + +{% code heading="RESPONSE" defaultLanguage="json" %} + +```json +{ + "multiplicity": "SingleSelect", + "listId": 906, + "values": [ + { + "id": "4118d53a-9121-4345-8682-07f23d606daa", + "name": "In Progress", + "sortOrder": 1, + "numericValue": 1.0, + "color": "#db3e3e" + }, + { + "id": "1c1c5f7e-cd03-4b70-9790-0f83b24b5863", + "name": "Complete", + "sortOrder": 2, + "numericValue": 2.0, + "color": "#ffffff" + }, + { + "id": "42493542-f77c-4298-91a0-18455ba0c764", + "name": "Not Started", + "sortOrder": 3, + "numericValue": 0.0, + "color": "#ffffff" + } + ], + "id": 6986, + "appId": 195, + "name": "Status", + "type": "List", + "status": "Enabled", + "isRequired": false, + "isUnique": false +} +``` + +{% /code %} diff --git a/src/docs/version_002/resources/fields/get_fields_by_app/copy.md b/src/docs/version_002/resources/fields/get_fields_by_app/copy.md index ec9cf38..abc653b 100644 --- a/src/docs/version_002/resources/fields/get_fields_by_app/copy.md +++ b/src/docs/version_002/resources/fields/get_fields_by_app/copy.md @@ -2,6 +2,22 @@ This endpoint returns a [paged](#pagination) collection of [fields](#fields) for the given app. +## Path Parameters + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- appId +- `number` +- The id of the app to retrieve fields for. + +{% /table %} + ## Query Parameters **Note:** [Pagination](#pagination) query parameters can be used to control the number of fields returned in the response. diff --git a/src/docs/version_002/resources/fields/get_fields_by_app/example.md b/src/docs/version_002/resources/fields/get_fields_by_app/example.md index 18270c4..eac4f39 100644 --- a/src/docs/version_002/resources/fields/get_fields_by_app/example.md +++ b/src/docs/version_002/resources/fields/get_fields_by_app/example.md @@ -15,8 +15,9 @@ var onspringClient = new OnspringClient( config.ApiKey ); -var getFieldsResponse = await onspringClient.GetFieldsForAppAsync(195); -foreach (Field field in getFieldsResponse.Value.Items) +var response = await onspringClient.GetFieldsForAppAsync(195); + +foreach (var field in response.Value.Items) { Console.WriteLine($"{field.Id}, {field.AppId}, {field.Name}, {field.Type}, {field.Status}, {field.IsRequired}, {field.IsUnique}"); } @@ -51,7 +52,6 @@ key = cfg['prod']['key'] url = cfg['prod']['url'] client = OnspringClient(url, key) - response = client.GetFieldsByAppId(appId=195) print(f'Status Code: {response.statusCode}')