From 21f75036b3c5f103904466241ae38885ddfb9a2b Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 17 Apr 2023 22:07:08 -0500 Subject: [PATCH] docs: add get fields by app section --- .../fields/get_fields_by_app/copy.md | 6 ++ .../fields/get_fields_by_app/example.md | 101 ++++++++++++++++++ 2 files changed, 107 insertions(+) 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 1ba04ff..ec9cf38 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 @@ -1 +1,7 @@ # Get Fields by App {% #get-fields-by-app %} + +This endpoint returns a [paged](#pagination) collection of [fields](#fields) for the given app. + +## 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 7426bce..18270c4 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 @@ -1 +1,102 @@ # Retrieve all fields for an app + +{% code method="GET" heading="/Fields/appId/{appId}" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/Fields/appId/195' \ +--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' +``` + +```csharp +using Onspring.API.SDK; + +var onspringClient = new OnspringClient( + config.BaseUrl, + config.ApiKey +); + +var getFieldsResponse = await onspringClient.GetFieldsForAppAsync(195); +foreach (Field field in getFieldsResponse.Value.Items) +{ + Console.WriteLine($"{field.Id}, {field.AppId}, {field.Name}, {field.Type}, {field.Status}, {field.IsRequired}, {field.IsUnique}"); +} +``` + +```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.getFieldsByAppId(195); +const fields = res.data.items; + +for (const field of fields) { + 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.GetFieldsByAppId(appId=195) + +print(f'Status Code: {response.statusCode}') +print(f'Page Size: {response.data.pageSize}') +print(f'Page Number: {response.data.pageNumber}') +print(f'Total Pages: {response.data.totalPages}') +print(f'Total Records: {response.data.totalRecords}') + +for field in response.data.fields: + print(f'Field Id: {field.id}') +``` + +{% /code %} + +{% code heading="RESPONSE" defaultLanguage="json" %} + +```json +{ + "pageNumber": 1, + "pageSize": 2, + "totalPages": 1, + "totalRecords": 2, + "items": [ + { + "id": 6989, + "appId": 195, + "name": "Attachments", + "type": "Attachment", + "status": "Enabled", + "isRequired": false, + "isUnique": false + }, + { + "multiplicity": "SingleSelect", + "referencedAppId": 2, + "id": 6980, + "appId": 195, + "name": "Created By", + "type": "Reference", + "status": "Enabled", + "isRequired": false, + "isUnique": false + } + ] +} +``` + +{% /code %}