From a880b219e0c70d5b054db5e27fc34dc38e6d1f4e Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Mon, 17 Apr 2023 08:49:43 -0500 Subject: [PATCH] docs: add get apps by ids section --- .vscode/settings.json | 1 + .../resources/apps/get_apps_by_ids/copy.md | 34 ++++++ .../resources/apps/get_apps_by_ids/example.md | 107 ++++++++++++++++++ 3 files changed, 142 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index b1b1d0e..e6ca1e7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "typescript.tsdk": "node_modules\\typescript\\lib", "typescript.enablePromptUseWorkspaceTsdk": true, "cSpell.words": [ + "BCDR", "configparser", "DDTHH", "isnull", diff --git a/src/docs/version_002/resources/apps/get_apps_by_ids/copy.md b/src/docs/version_002/resources/apps/get_apps_by_ids/copy.md index 38fb758..960677b 100644 --- a/src/docs/version_002/resources/apps/get_apps_by_ids/copy.md +++ b/src/docs/version_002/resources/apps/get_apps_by_ids/copy.md @@ -1 +1,35 @@ # Get Apps by Ids {% #get-apps-by-ids %} + +This endpoint returns a batch of [apps](#apps) based on the given app ids. + +## Request Body + +{% code heading="REQUEST" defaultLanguage="json" %} + +```json +[8, 79, 137, 193, 183] +``` + +{% /code %} + +## Response Body Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- count +- `number` +- The number of apps returned. + +--- + +- items +- `object[]` +- The [apps](#apps) returned. + +{% /table %} diff --git a/src/docs/version_002/resources/apps/get_apps_by_ids/example.md b/src/docs/version_002/resources/apps/get_apps_by_ids/example.md index e69de29..7ddcd02 100644 --- a/src/docs/version_002/resources/apps/get_apps_by_ids/example.md +++ b/src/docs/version_002/resources/apps/get_apps_by_ids/example.md @@ -0,0 +1,107 @@ +# Retrieve a batch of apps by ids + +{% code method="POST" heading="/Apps/batch-get" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/Apps/batch-get' \ +--header 'X-ApiKey: 000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000' \ +--header 'Content-Type: application/json' \ +--data '[8,79,137,193,183]' +``` + +```csharp +using Onspring.API.SDK; + +var onspringClient = new OnspringClient( + config.BaseUrl, + config.ApiKey +); + +var response = await onspringClient.GetAppsAsync( + new List { 8, 79, 137, 193, 183 } +); + +foreach (var app in response.Value.Items) +{ + Console.WriteLine($"{app.Id}, {app.Name}"); +} +``` + +```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.getAppsByIds([130, 131]); +const apps = res.data.items; + +for (const app of apps) { + console.log(app); +} +``` + +```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.GetAppsByIds(appIds=[195, 240]) + +print(f'Status Code: {response.statusCode}') +print(f'Count: {response.data.count}') + +for app in response.data.apps: + print(f'Id: {app.id}') + print(f'Name: {app.name}') + print(f'href: {app.href}') +``` + +{% /code %} + +{% code heading="RESPONSE" defaultLanguage="json" %} + +```json +{ + "count": 5, + "items": [ + { + "href": "https://api.onspring.dev/apps/id/8", + "id": 8, + "name": "Activated BCDR Tasks" + }, + { + "href": "https://api.onspring.dev/apps/id/79", + "id": 79, + "name": "Application Assessments" + }, + { + "href": "https://api.onspring.dev/apps/id/137", + "id": 137, + "name": "Applications" + }, + { + "href": "https://api.onspring.dev/apps/id/193", + "id": 193, + "name": "Ascent Obligations" + }, + { + "href": "https://api.onspring.dev/apps/id/183", + "id": 183, + "name": "Asset Baseline Repository" + } + ] +} +``` + +{% /code %}