From 587777e77636880724473003dc39045bf206d0d9 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sun, 16 Apr 2023 21:59:23 -0500 Subject: [PATCH] docs: add get apps section --- src/docs/version_002/docsStructure.ts | 26 +++++++ src/docs/version_002/resources/apps/copy.md | 31 +++++++++ .../version_002/resources/apps/example.md | 13 ++++ .../resources/apps/get_app_by_id/copy.md | 1 + .../resources/apps/get_app_by_id/example.md | 0 .../resources/apps/get_apps/copy.md | 7 ++ .../resources/apps/get_apps/example.md | 69 +++++++++++++++++++ .../resources/apps/get_apps_by_ids/copy.md | 1 + .../resources/apps/get_apps_by_ids/example.md | 0 .../version_002/resources/records/copy.md | 2 +- .../records/get_records_by_app/example.md | 19 +++-- 11 files changed, 158 insertions(+), 11 deletions(-) create mode 100644 src/docs/version_002/resources/apps/copy.md create mode 100644 src/docs/version_002/resources/apps/example.md create mode 100644 src/docs/version_002/resources/apps/get_app_by_id/copy.md create mode 100644 src/docs/version_002/resources/apps/get_app_by_id/example.md create mode 100644 src/docs/version_002/resources/apps/get_apps/copy.md create mode 100644 src/docs/version_002/resources/apps/get_apps/example.md create mode 100644 src/docs/version_002/resources/apps/get_apps_by_ids/copy.md create mode 100644 src/docs/version_002/resources/apps/get_apps_by_ids/example.md diff --git a/src/docs/version_002/docsStructure.ts b/src/docs/version_002/docsStructure.ts index 3510546..39deeab 100644 --- a/src/docs/version_002/docsStructure.ts +++ b/src/docs/version_002/docsStructure.ts @@ -44,6 +44,32 @@ export const versionTwo: DocsStructure = { copy: 'copy.md', example: 'example.md', }, + { + title: 'Apps', + folder: 'apps', + copy: 'copy.md', + example: 'example.md', + children: [ + { + title: 'Get Apps', + folder: 'get_apps', + copy: 'copy.md', + example: 'example.md', + }, + { + title: 'Get App by Id', + folder: 'get_app_by_id', + copy: 'copy.md', + example: 'example.md', + }, + { + title: 'Get Apps by Ids', + folder: 'get_apps_by_ids', + copy: 'copy.md', + example: 'example.md', + }, + ], + }, { title: 'Records', folder: 'records', diff --git a/src/docs/version_002/resources/apps/copy.md b/src/docs/version_002/resources/apps/copy.md new file mode 100644 index 0000000..d91a42e --- /dev/null +++ b/src/docs/version_002/resources/apps/copy.md @@ -0,0 +1,31 @@ +# Apps {% #apps %} + +These are objects that represent apps and/or surveys in an Onspring instance. You can retrieve a list of apps or a specific app by its Id. + +## App Properties + +{% table %} + +- Property Name +- Data Type +- Description + +--- + +- href +- `string` +- The URL of the app. + +--- + +- id +- `number` +- The id of the app. + +--- + +- name +- `string` +- The name of the app. + +{% /table %} diff --git a/src/docs/version_002/resources/apps/example.md b/src/docs/version_002/resources/apps/example.md new file mode 100644 index 0000000..6b82ba0 --- /dev/null +++ b/src/docs/version_002/resources/apps/example.md @@ -0,0 +1,13 @@ +# The App Object + +{% code heading="APP" defaultLanguage="json" %} + +```json +{ + "href": "https://api.onspring.dev/apps/id/195", + "id": 195, + "name": "Tasks" +} +``` + +{% /code %} diff --git a/src/docs/version_002/resources/apps/get_app_by_id/copy.md b/src/docs/version_002/resources/apps/get_app_by_id/copy.md new file mode 100644 index 0000000..bd0f07f --- /dev/null +++ b/src/docs/version_002/resources/apps/get_app_by_id/copy.md @@ -0,0 +1 @@ +# Get App by Id {% #get-app-by-id %} diff --git a/src/docs/version_002/resources/apps/get_app_by_id/example.md b/src/docs/version_002/resources/apps/get_app_by_id/example.md new file mode 100644 index 0000000..e69de29 diff --git a/src/docs/version_002/resources/apps/get_apps/copy.md b/src/docs/version_002/resources/apps/get_apps/copy.md new file mode 100644 index 0000000..3cfa662 --- /dev/null +++ b/src/docs/version_002/resources/apps/get_apps/copy.md @@ -0,0 +1,7 @@ +# Get Apps {% #get-apps %} + +This endpoint returns a [paged](#pagination) collection of [apps](#apps) that the given API key has access to. + +## Query Parameters + +**Note:** [Pagination](#pagination) query parameters can be used to control the number of apps returned in the response. diff --git a/src/docs/version_002/resources/apps/get_apps/example.md b/src/docs/version_002/resources/apps/get_apps/example.md new file mode 100644 index 0000000..54a2617 --- /dev/null +++ b/src/docs/version_002/resources/apps/get_apps/example.md @@ -0,0 +1,69 @@ +# Retrieve apps accessible to the API key + +{% code method="GET" heading="/Apps" defaultLanguage="bash" %} + +```bash +curl --location 'https://api.onspring.com/Apps' \ +--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.GetAppsAsync(); + +foreach (var app in response.Value.Items) +{ + Console.WriteLine($"{app.Id}, {app.Name}"); +} +``` + +```javascript +import dotenv from 'dotenv'; +import { OnspringClient } from 'onspring-api-sdk'; +dotenv.config(); + +const client = new OnspringClient( + process.env.BASE_URL, + process.env.API_KEY +); + +const res = await client.getApps(); +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.GetApps() + +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 app in response.data.apps: + print(f'Id: {app.id}') + print(f'Name: {app.name}') + print(f'href: {app.href}') +``` + +{% /code %} 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 new file mode 100644 index 0000000..38fb758 --- /dev/null +++ b/src/docs/version_002/resources/apps/get_apps_by_ids/copy.md @@ -0,0 +1 @@ +# Get Apps by Ids {% #get-apps-by-ids %} 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 new file mode 100644 index 0000000..e69de29 diff --git a/src/docs/version_002/resources/records/copy.md b/src/docs/version_002/resources/records/copy.md index a73c8e3..3ad98c7 100644 --- a/src/docs/version_002/resources/records/copy.md +++ b/src/docs/version_002/resources/records/copy.md @@ -12,7 +12,7 @@ These are objects representing a content record in your instance. You can create --- -- App Id +- appId - `number` - The id of the app or survey. diff --git a/src/docs/version_002/resources/records/get_records_by_app/example.md b/src/docs/version_002/resources/records/get_records_by_app/example.md index b11bd4d..b7c304d 100644 --- a/src/docs/version_002/resources/records/get_records_by_app/example.md +++ b/src/docs/version_002/resources/records/get_records_by_app/example.md @@ -15,25 +15,24 @@ var onspringClient = new OnspringClient( config.ApiKey ); -var response = await onspringClient.GetAppsAsync(); +var getReportsResponse = await onspringClient.GetReportsForAppAsync(195); -foreach (var app in response.Value.Items) +foreach (var report in getReportsResponse.Value.Items) { - Console.WriteLine($"{app.Id}, {app.Name}"); + Console.WriteLine($"{report.Id}, {report.AppId}, {report.Name}"); } ``` ```javascript +import { + GetRecordsByAppIdRequest, + OnspringClient, +} from 'onspring-api-sdk'; import dotenv from 'dotenv'; -import { OnspringClient } from 'onspring-api-sdk'; dotenv.config(); -const client = new OnspringClient( - process.env.BASE_URL, - process.env.API_KEY -); - -const res = await client.getApps(); +const request = new GetRecordsByAppIdRequest(195); +const res = await client.getRecordsByAppId(request); const apps = res.data.items; for (const app of apps) {