Author SHA1 Message Date
Stevan Freeborn 5bb962cee3 Merge pull request #9 from StevanFreeborn/stevanfreeborn/feat/update-python-examples-for-version-3
feat: update python code snippets to reflect new version 3 of the python sdk
2026-06-26 17:52:17 -05:00
Stevan Freeborn 3bfaf17bf3 feat: update package dependencies and refactor Python SDK examples for consistency
- Bump versions of eslint-plugin-prettier, jest, jest-environment-jsdom, and prettier in package.json.
- Refactor Python SDK examples to use consistent naming conventions (snake_case) for method and parameter names.
- Update example responses to reflect changes in the SDK, including status code and data field names.
- Ensure all Python imports are updated to use the correct module naming.
2026-06-26 16:51:54 -05:00
Stevan Freeborn bbdb3b62a4 Merge pull request #8 from StevanFreeborn/stevanfreeborn/feat/add-go-sdk-and-examples
feat: add Go SDK support and examples to documentation
2026-03-26 22:12:02 -05:00
Stevan Freeborn 3c569db660 feat: add Go SDK support and examples to documentation 2026-03-26 22:09:26 -05:00
Stevan Freeborn fb0e177d91 Merge pull request #7 from StevanFreeborn/stevanfreeborn/feat/add-rust-sdk-and-examples
feat: add rust sdk examples
2026-03-26 21:56:17 -05:00
Stevan Freeborn 7ad0b30f34 feat: add Rust code examples and support for Rust syntax highlighting
- Added Rust syntax highlighting to the Fence component.
- Updated Markdoc functions to clone React elements with unique keys for copy and example sections.
- Included Rust code examples for various API endpoints in documentation:
  - `get_app_by_id`
  - `get_apps`
  - `get_apps_by_ids`
  - `connectivity`
  - `get_field_by_id`
  - `get_fields_by_app`
  - `get_fields_by_ids`
  - `add_file`
  - `delete_file_by_id`
  - `get_file_by_id`
  - `get_file_info_by_id`
  - `delete_list_value_by_id`
  - `save_list_value`
  - `delete_record_by_id`
  - `delete_records_by_ids`
  - `get_record_by_id`
  - `get_records_by_app`
  - `get_records_by_ids`
  - `get_records_by_query`
  - `save_record`
  - `get_report_by_id`
  - `get_reports_by_app`
2026-03-26 21:53:02 -05:00
Stevan Freeborn d7e82d5a80 fix: housekeeping 2026-03-26 15:22:04 -05:00
51 changed files with 7546 additions and 9619 deletions
+1
View File
@@ -0,0 +1 @@
next-env.d.ts
+44
View File
@@ -0,0 +1,44 @@
import nextPlugin from '@next/eslint-plugin-next';
import prettierPlugin from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
export default [
{
ignores: [
'.next/**',
'node_modules/**',
'coverage/**',
'.swc/**',
],
},
{
files: ['**/*.{js,mjs,cjs,ts,tsx}'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
'@next/next': nextPlugin,
'@typescript-eslint': tsPlugin,
prettier: prettierPlugin,
},
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs['core-web-vitals'].rules,
...tsPlugin.configs.recommended.rules,
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
},
prettierConfig,
];
+3 -2
View File
@@ -1,10 +1,11 @@
import nextJest from 'next/jest';
import type { Config } from 'jest';
import nextJest from 'next/jest.js';
const createJestConfig = nextJest({
dir: './',
});
const config = {
const config: Config = {
testEnvironment: 'jest-environment-jsdom',
clearMocks: true,
collectCoverage: true,
+1 -5
View File
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
};
const nextConfig = {};
module.exports = nextConfig;
+6079 -8932
View File
File diff suppressed because it is too large Load Diff
+25 -22
View File
@@ -6,33 +6,36 @@
"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint": "eslint .",
"test": "jest",
"test-coverage": "jest && live-server coverage/"
},
"dependencies": {
"@markdoc/markdoc": "^0.2.2",
"@types/node": "18.15.11",
"@types/react": "18.0.33",
"@types/react-dom": "18.0.11",
"@vercel/analytics": "^1.0.0",
"eslint": "8.38.0",
"eslint-config-next": "13.3.0",
"next": "13.2.4",
"prismjs": "^1.29.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
"@markdoc/markdoc": "^0.5.7",
"@types/node": "25.5.0",
"@types/react": "19.2.14",
"@types/react-dom": "19.2.3",
"@vercel/analytics": "^2.0.1",
"eslint": "10.1.0",
"eslint-config-next": "16.2.1",
"next": "16.2.1",
"prismjs": "^1.30.0",
"react": "19.2.4",
"react-dom": "19.2.4",
"typescript": "6.0.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/prismjs": "^1.26.0",
"cross-env": "^7.0.3",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.7",
"ts-node": "^10.9.1"
"@eslint/eslintrc": "^3.3.5",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@types/prismjs": "^1.26.6",
"cross-env": "^10.1.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.6",
"jest": "^30.4.2",
"jest-environment-jsdom": "^30.4.1",
"prettier": "^3.8.5",
"ts-node": "^10.9.2"
}
}
File diff suppressed because one or more lines are too long
+33 -23
View File
@@ -2,13 +2,24 @@
import React, {
Children,
MouseEvent,
ReactElement,
ReactNode,
useState,
} from 'react';
import styles from './CodeSnippet.module.css';
interface MarkdocFenceProps {
language?: string;
content?: string;
className?: string;
}
function isMarkdocElement(
child: ReactNode
): child is ReactElement<MarkdocFenceProps> {
return React.isValidElement(child);
}
function CodeSnippetCopyButton({
copyText,
}: {
@@ -20,7 +31,7 @@ function CodeSnippetCopyButton({
const [showTooltip, setShowTooltip] =
useState<boolean>(false);
const handleCopy = (e: MouseEvent<HTMLButtonElement>) => {
const handleCopy = () => {
setCopyButtonTooltip(true);
setTimeout(() => {
setCopyButtonTooltip(false);
@@ -129,30 +140,29 @@ export default function CodeSnippet({
setSelectedLanguage(e.target.value);
};
const code = Children.toArray(children)
.filter(
child =>
React.isValidElement(child) &&
child.props.className ===
`language-${selectedLanguage}`
)
.map(child => {
return child as ReactElement;
})[0];
const childrenArray = Children.toArray(children);
const snippetLanguages = Children.toArray(children).map(
child => {
if (React.isValidElement(child)) {
const languageClassParts =
child.props.className.split('-');
if (languageClassParts.length > 1) {
const language = languageClassParts[1];
return language;
}
}
const code = childrenArray.find(
(child): child is ReactElement<MarkdocFenceProps> => {
if (!isMarkdocElement(child)) return false;
const { language, className } = child.props;
return (
language === selectedLanguage ||
className === `language-${selectedLanguage}`
);
}
);
const snippetLanguages = childrenArray
.map(child => {
if (isMarkdocElement(child)) {
const { language, className } = child.props;
return language || className?.split('-')[1];
}
return undefined;
})
.filter((l): l is string => typeof l === 'string');
return (
<div className={styles.snippetContainer}>
<div className={styles.snippetHeader}>
@@ -176,7 +186,7 @@ export default function CodeSnippet({
</>
) : null}
<CodeSnippetCopyButton
copyText={code.props.content}
copyText={code?.props.content ?? ''}
/>
</div>
</div>
+2
View File
@@ -3,6 +3,8 @@ import 'prismjs/components/prism-bash';
import 'prismjs/components/prism-csharp';
import 'prismjs/components/prism-json';
import 'prismjs/components/prism-python';
import 'prismjs/components/prism-rust';
import 'prismjs/components/prism-go';
import './prism-custom.css';
export default function Fence({
+26 -18
View File
@@ -2,17 +2,29 @@
import Link from 'next/link';
import { useState } from 'react';
import { VERSIONS } from '../constants';
import { themes, useThemeContext } from '../context/theme';
import { DocsStructure, Version } from '../types/types';
import { DocsStructure } from '../types/types';
import styles from './NavBar.module.css';
import SectionDropdown from './SectionDropdown';
function VersionsDropdown({
version,
}: {
version: Version;
version: string;
}) {
const versions = {
version_001: {
name: 'Version 1',
path: '/version-1',
},
version_002: {
name: 'Version 2',
path: '/',
},
} as { [key: string]: { name: string; path: string } };
const currentVersion = versions[version];
const [isDropdownOpen, setIsDropdownOpen] =
useState<boolean>(false);
@@ -26,7 +38,7 @@ function VersionsDropdown({
className={styles.navLink}
onClick={handleDropdownToggle}
>
{version.name}{' '}
{currentVersion.name}{' '}
{isDropdownOpen ? (
<svg
xmlns="http://www.w3.org/2000/svg"
@@ -64,18 +76,18 @@ function VersionsDropdown({
: styles.dropdownMenu
}
>
{Object.keys(VERSIONS)
.filter(v => VERSIONS[v].name !== version.name)
{Object.keys(versions)
.filter(v => v !== version)
.map(v => (
<Link
href={`${VERSIONS[v].path}`}
href={`${versions[v].path}`}
key={v}
className={styles.navLink}
onClick={() => {
setIsDropdownOpen(false);
}}
>
{VERSIONS[v].name}
{versions[v].name}
</Link>
))}
</div>
@@ -84,14 +96,12 @@ function VersionsDropdown({
}
export default function NavBar({
versionDocStructure,
version,
}: {
versionDocStructure: DocsStructure;
version: DocsStructure;
}) {
const { theme } = useThemeContext();
const themeStyles = themes[theme];
const currentVersion =
VERSIONS[versionDocStructure.version];
const [isNavOpen, setIsNavOpen] =
useState<boolean>(false);
@@ -104,9 +114,7 @@ export default function NavBar({
<nav style={themeStyles} className={styles.nav}>
<ul className={styles.navListLeft}>
<li className={styles.sectionDropdown}>
<SectionDropdown
versionDocStructure={versionDocStructure}
/>
<SectionDropdown version={version} />
</li>
</ul>
<div>
@@ -126,18 +134,18 @@ export default function NavBar({
}
>
<li className={styles.navItem}>
<VersionsDropdown version={currentVersion} />
<VersionsDropdown version={version.version} />
</li>
<li className={styles.navItem}>
<Link
href={currentVersion.officialDocs}
href={version.officialDocs}
className={styles.navLink}
target="_blank"
>
Official Docs
</Link>
</li>
{currentVersion.hasSwagger ? (
{version.hasSwagger ? (
<li className={styles.navItem}>
<Link
href="https://api.onspring.com/swagger"
+4 -4
View File
@@ -10,10 +10,10 @@ import styles from './Page.module.css';
import SideBar from './SideBar';
export default function Page({
versionDocStructure,
version,
versionSections,
}: {
versionDocStructure: DocsStructure;
version: DocsStructure;
versionSections: DocSection[];
}) {
const { theme } = useThemeContext();
@@ -56,9 +56,9 @@ export default function Page({
return (
<div className={styles.wrapper} style={themeStyles}>
<SideBar versionDocStructure={versionDocStructure} />
<SideBar version={version} />
<div className={styles.container}>
<NavBar versionDocStructure={versionDocStructure} />
<NavBar version={version} />
<Main versionSections={versionSections} />
</div>
</div>
+7 -4
View File
@@ -1,15 +1,18 @@
import { ChangeEvent } from 'react';
import { useSectionContext } from '../context/section';
import { Doc, DocsStructure } from '../types/types';
import { toKebabCase } from '../utils/stringUtils';
import styles from './SectionDropdown.module.css';
export default function SectionDropdown({
versionDocStructure,
version,
}: {
versionDocStructure: DocsStructure;
version: DocsStructure;
}) {
const { section, setSection } = useSectionContext();
const handleSelectChange = (e: any) => {
const handleSelectChange = (
e: ChangeEvent<HTMLSelectElement>
) => {
setSection(e.target.value);
location.hash = e.target.value;
};
@@ -28,7 +31,7 @@ export default function SectionDropdown({
return result;
};
const docs = getAllDocs(versionDocStructure.docs);
const docs = getAllDocs(version.docs);
return (
<select
+3 -3
View File
@@ -107,9 +107,9 @@ function ListTree({ docs }: { docs: Doc[] }) {
}
export default function SideBar({
versionDocStructure,
version,
}: {
versionDocStructure: DocsStructure;
version: DocsStructure;
}) {
const { theme, setTheme } = useThemeContext();
@@ -138,7 +138,7 @@ export default function SideBar({
></span>
</label>
</div>
<ListTree docs={versionDocStructure.docs} />
<ListTree docs={version.docs} />
</div>
);
}
-82
View File
@@ -1,82 +0,0 @@
import path from 'path';
import { Version } from './types/types';
export const DOCS_PATH = path.join(
process.cwd(),
'src/docs'
);
const CSHARP_SVG = `
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 456 456" fill="none">
<rect width="456" height="456" fill="#512BD4"/>
<path d="M81.2738 291.333C78.0496 291.333 75.309 290.259 73.052 288.11C70.795 285.906 69.6665 283.289 69.6665 280.259C69.6665 277.173 70.795 274.529 73.052 272.325C75.309 270.121 78.0496 269.019 81.2738 269.019C84.5518 269.019 87.3193 270.121 89.5763 272.325C91.887 274.529 93.0424 277.173 93.0424 280.259C93.0424 283.289 91.887 285.906 89.5763 288.11C87.3193 290.259 84.5518 291.333 81.2738 291.333Z" fill="white"/>
<path d="M210.167 289.515H189.209L133.994 202.406C132.597 200.202 131.441 197.915 130.528 195.546H130.044C130.474 198.081 130.689 203.508 130.689 211.827V289.515H112.149V171H134.477L187.839 256.043C190.096 259.57 191.547 261.994 192.192 263.316H192.514C191.977 260.176 191.708 254.859 191.708 247.365V171H210.167V289.515Z" fill="white"/>
<path d="M300.449 289.515H235.561V171H297.87V187.695H254.746V221.249H294.485V237.861H254.746V272.903H300.449V289.515Z" fill="white"/>
<path d="M392.667 187.695H359.457V289.515H340.272V187.695H307.143V171H392.667V187.695Z" fill="white"/>
</svg>
`;
export const VERSIONS: Record<string, Version> = {
version_001: {
name: 'Version 1',
path: '/version-1',
officialDocs:
'https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v1%20API.pdf',
hasSwagger: false,
clients: [
{
name: 'C#',
repoLink:
'https://github.com/onspring-technologies/onspring-api-sdk/tree/v1.1',
installCommand:
'dotnet add package Onspring.API.SDK --version 2.1.0',
svg: CSHARP_SVG,
official: true,
},
],
},
version_002: {
name: 'Version 2',
path: '/',
officialDocs:
'https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf',
hasSwagger: true,
clients: [
{
name: 'C#',
repoLink:
'https://github.com/onspring-technologies/onspring-api-sdk',
installCommand:
'dotnet add package Onspring.API.SDK',
svg: CSHARP_SVG,
official: true,
},
{
name: 'Javascript',
repoLink:
'https://github.com/StevanFreeborn/onspring-api-sdk-javascript',
installCommand: 'npm install onspring-api-sdk',
svg: `
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" aria-label="JavaScript" viewBox="0 0 512 512" id="javascript">
<rect width="512" height="512" fill="#f7df1e" rx="15%"></rect>
<path d="m324,370c10,17 24,29 47,29 20,0 33,-10 33,-24 0,-16 -13,-22 -35,-32l-12,-5c-35,-15 -58,-33 -58,-72 0,-36 27,-64 70,-64 31,0 53,11 68,39l-37,24c-8,-15 -17,-21 -31,-21 -14,0 -23,9 -23,21 0,14 9,20 30,29l12,5c41,18 64,35 64,76 0,43 -34,67 -80,67 -45,0 -74,-21 -88,-49zm-170,4c8,13 14,25 31,25 16,0 26,-6 26,-30V203h48v164c0,50 -29,72 -72,72 -39,0 -61,-20 -72,-44z"></path>
</svg>
`,
official: false,
},
{
name: 'Python',
repoLink:
'https://github.com/StevanFreeborn/onspring-api-sdk-python',
installCommand: 'pip install OnspringApiSdk',
svg: `
<svg width="30" height="30" viewBox="0 0 256 255" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
<path d="M126.916.072c-64.832 0-60.784 28.115-60.784 28.115l.072 29.128h61.868v8.745H41.631S.145 61.355.145 126.77c0 65.417 36.21 63.097 36.21 63.097h21.61v-30.356s-1.165-36.21 35.632-36.21h61.362s34.475.557 34.475-33.319V33.97S194.67.072 126.916.072zM92.802 19.66a11.12 11.12 0 0111.13 11.13 11.12 11.12 0 01-11.13 11.13 11.12 11.12 0 01-11.13-11.13 11.12 11.12 0 0111.13-11.13z" fill="#3372a7"></path>
<path d="M128.757 254.126c64.832 0 60.784-28.115 60.784-28.115l-.072-29.127H127.6v-8.745h86.441s41.486 4.705 41.486-60.712c0-65.416-36.21-63.096-36.21-63.096h-21.61v30.355s1.165 36.21-35.632 36.21h-61.362s-34.475-.557-34.475 33.32v56.013s-5.235 33.897 62.518 33.897zm34.114-19.586a11.12 11.12 0 01-11.13-11.13 11.12 11.12 0 0111.13-11.131 11.12 11.12 0 0111.13 11.13 11.12 11.12 0 01-11.13 11.13z" fill="#ffd235"></path>
</svg>
`,
official: false,
},
],
},
};
+17 -3
View File
@@ -7,7 +7,14 @@ import {
useState,
} from 'react';
const SectionContext = createContext({});
type SectionContextType = {
section: string;
setSection: (section: string) => void;
};
const SectionContext = createContext<
SectionContextType | undefined
>(undefined);
export const SectionContextProvider = ({
children,
@@ -25,5 +32,12 @@ export const SectionContextProvider = ({
);
};
export const useSectionContext: any = () =>
useContext(SectionContext);
export const useSectionContext = (): SectionContextType => {
const context = useContext(SectionContext);
if (!context) {
throw new Error(
'useSectionContext must be used within SectionContextProvider'
);
}
return context;
};
+17 -3
View File
@@ -7,6 +7,11 @@ import {
useState,
} from 'react';
interface ThemeContextType {
theme: string;
setTheme: (theme: string) => void;
}
const darkTheme = {
color: 'white',
backgroundColor: '#05254a',
@@ -17,7 +22,9 @@ const lightTheme = {
backgroundColor: 'white',
};
const ThemeContext = createContext({});
const ThemeContext = createContext<
ThemeContextType | undefined
>(undefined);
export const ThemeContextProvider = ({
children,
@@ -38,5 +45,12 @@ export const themes = {
light: lightTheme,
} as { [key: string]: { [key: string]: string } };
export const useThemeContext: any = () =>
useContext(ThemeContext);
export const useThemeContext = (): ThemeContextType => {
const context = useContext(ThemeContext);
if (!context) {
throw new Error(
'useThemeContext must be used within ThemeContextProvider'
);
}
return context;
};
+2
View File
@@ -9,6 +9,8 @@ export default function GlobalError({
error: Error;
reset: () => void;
}) {
console.error(error);
return (
<div className={styles.container}>
<h2>Something went wrong!</h2>
+3 -2
View File
@@ -15,11 +15,12 @@ export const metadata = {
},
],
},
viewport: {
};
export const viewport = {
width: 'device-width',
initialScale: 1,
maximumScale: 1,
},
};
export default function RootLayout({
+48 -37
View File
@@ -5,10 +5,40 @@ import React, { ReactNode } from 'react';
import Clients from '../components/Clients';
import CodeSnippet from '../components/CodeSnippet';
import Fence from '../components/Fence';
import { DOCS_PATH } from '../constants';
import { Doc, DocSection } from './../types/types';
export const markDocConfig = {
const DOCS_PATH = path.join(process.cwd(), 'src/docs');
function getCopyPath(
version: string,
doc: Doc,
docPath: string
): string {
if (doc.copy === undefined) {
return '';
}
return path.join(DOCS_PATH, version, docPath, doc.copy);
}
function getExamplePath(
version: string,
doc: Doc,
docPath: string
): string {
if (doc.example === undefined) {
return '';
}
return path.join(
DOCS_PATH,
version,
docPath,
doc.example
);
}
const markDocConfig = {
nodes: {
fence: {
render: 'Fence',
@@ -48,14 +78,12 @@ export const markDocConfig = {
},
};
export function parseMarkdown(
sourcePath: string
): ReactNode {
function parseMarkdown(sourcePath: string): ReactNode {
const source = fs.readFileSync(sourcePath, 'utf8');
const ast = Markdoc.parse(source);
const content = Markdoc.transform(
ast,
markDocConfig as any
markDocConfig as never
);
const children = Markdoc.renderers.react(content, React, {
components: {
@@ -68,42 +96,19 @@ export function parseMarkdown(
return children;
}
export function getCopyPath(
version: string,
doc: Doc,
docPath: string
): string {
if (doc.copy === undefined) {
return '';
}
return path.join(DOCS_PATH, version, docPath, doc.copy);
}
export function getExamplePath(
version: string,
doc: Doc,
docPath: string
): string {
if (doc.example === undefined) {
return '';
}
return path.join(
DOCS_PATH,
version,
docPath,
doc.example
);
}
function getCopyChild(
version: string,
doc: Doc,
docPath: string
) {
const copyPath = getCopyPath(version, doc, docPath);
return parseMarkdown(copyPath);
const child = parseMarkdown(copyPath);
if (React.isValidElement(child)) {
return React.cloneElement(child, { key: 'copy' });
}
return child;
}
function getExampleChild(
@@ -112,7 +117,13 @@ function getExampleChild(
docPath: string
) {
const examplePath = getExamplePath(version, doc, docPath);
return parseMarkdown(examplePath);
const child = parseMarkdown(examplePath);
if (React.isValidElement(child)) {
return React.cloneElement(child, { key: 'example' });
}
return child;
}
export function loadSections(
+1 -1
View File
@@ -10,7 +10,7 @@ export default function VersionTwo() {
return (
<Page
versionDocStructure={versionTwo}
version={versionTwo}
versionSections={versionTwoSections}
/>
);
+2 -16
View File
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
export type DocsStructure = {
version: string;
officialDocs: string;
hasSwagger: boolean;
docs: Doc[];
};
@@ -18,19 +20,3 @@ export type DocSection = {
copy: ReactNode;
example: ReactNode;
};
export type Version = {
name: string;
path: string;
officialDocs: string;
hasSwagger: boolean;
clients: Client[];
};
export type Client = {
name: string;
repoLink: string;
installCommand: string;
svg: string;
official: boolean;
};
+1 -1
View File
@@ -10,7 +10,7 @@ export default function VersionOne() {
return (
<Page
versionDocStructure={versionOne}
version={versionOne}
versionSections={versionOneSections}
/>
);
+3
View File
@@ -2,6 +2,9 @@ import { DocsStructure } from '@/app/types/types';
export const versionOne: DocsStructure = {
version: 'version_001',
officialDocs:
'https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v1%20API.pdf',
hasSwagger: false,
docs: [
{
title: 'Introduction',
+1 -1
View File
@@ -10,5 +10,5 @@ https://api.onspring.com/v1
{% /code %}
{% clients version="version_001" %}
{% clients version="1" %}
{% /clients %}
+3
View File
@@ -2,6 +2,9 @@ import { DocsStructure } from '@/app/types/types';
export const versionTwo: DocsStructure = {
version: 'version_002',
officialDocs:
'https://software.onspring.com/hubfs/Training/Admin%20Guide%20-%20v2%20API.pdf',
hasSwagger: true,
docs: [
{
title: 'Introduction',
+1 -1
View File
@@ -18,5 +18,5 @@ X-Api-Version: 2
{% /code %}
{% clients version="version_002" %}
{% clients version="2" %}
{% /clients %}
@@ -37,7 +37,7 @@ console.log(app);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -48,12 +48,45 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetAppById(appId=195)
response = client.get_app_by_id(app_id=195)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'id: {response.data.app.id}')
print(f'Name: {response.data.app.name}')
print(f'href: {response.data.app.href}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let app = client.get_app(195).await?;
println!(
"{}, {}",
app.id,
app.name.unwrap_or_default()
);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
app, _ := client.Apps.Get(
context.Background(),
195,
)
fmt.Printf("%d, %s\n", app.Id, app.Name)
```
{% /code %}
@@ -42,7 +42,7 @@ for (const app of apps) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,18 +52,59 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetApps()
response = client.get_apps()
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}')
print(f'Status Code: {response.status_code}')
print(f'Page Size: {response.data.page_size}')
print(f'Page Number: {response.data.page_number}')
print(f'Total Pages: {response.data.total_pages}')
print(f'Total Records: {response.data.total_records}')
for app in response.data.apps:
print(f'Id: {app.id}')
print(f'Name: {app.name}')
print(f'href: {app.href}')
```
```rust
use onspring::{OnspringClient, PagingRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let paging = PagingRequest {
page_number: 1,
page_size: 10,
};
let response = client.list_apps(Some(paging)).await?;
for app in response.items.unwrap_or_default() {
println!(
"{}, {}",
app.id,
app.name.unwrap_or_default()
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
page, _ := client.Apps.List(
context.Background(),
)
for _, app := range page.Items {
fmt.Printf("%d, %s\n", app.Id, app.Name)
}
```
{% /code %}
@@ -46,7 +46,7 @@ for (const app of apps) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -56,15 +56,53 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetAppsByIds(appIds=[195, 240])
response = client.get_apps_by_ids(app_ids=[195, 240])
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
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}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let ids = vec![8, 79, 137, 193, 183];
let response = client.batch_get_apps(&ids).await?;
for app in response.items.unwrap_or_default() {
println!(
"{}, {}",
app.id,
app.name.unwrap_or_default()
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
batch, _ := client.Apps.GetMany(
context.Background(),
[]int{8, 79, 137, 193, 183},
)
for _, app := range batch.Items {
fmt.Printf("%d, %s\n", app.Id, app.Name)
}
```
{% /code %}
@@ -37,7 +37,7 @@ console.log(res);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -48,12 +48,39 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
canConnect = client.CanConnect()
canConnect = client.can_connect()
if canConnect:
if can_connect:
print('Connected successfully')
else:
print('Attempt to connect failed')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
client.ping().await?;
println!("Connected to the Onspring API successfully.");
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
err := client.Ping.Get(context.Background())
if err == nil {
fmt.Println("Connected to Onspring API")
}
```
{% /code %}
@@ -38,7 +38,7 @@ console.log(field);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -48,10 +48,39 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetFieldById(fieldId=6986)
response = client.get_field_by_id(field_id=6986)
print(f'Status Code: {response.statusCode}')
print(f'Field Id: {response.data.id}')
print(f'Status Code: {response.status_code}')
print(f'Field Id: {response.data.field.id}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let field = client.get_field(6986).await?;
println!("Field Id: {}", field.id);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
field, _ := client.Fields.Get(
context.Background(),
6986,
)
fmt.Printf("Field Id: %d\n", field.Id)
```
{% /code %}
@@ -42,7 +42,7 @@ for (const field of fields) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,16 +52,54 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetFieldsByAppId(appId=195)
response = client.get_fields_by_app_id(app_id=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}')
print(f'Status Code: {response.status_code}')
print(f'Page Size: {response.data.page_size}')
print(f'Page Number: {response.data.page_number}')
print(f'Total Pages: {response.data.total_pages}')
print(f'Total Records: {response.data.total_records}')
for field in response.data.fields:
print(f'Field Id: {field.id}')
```
```rust
use onspring::{OnspringClient, PagingRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let paging = PagingRequest {
page_number: 1,
page_size: 10,
};
let response = client.list_fields(195, Some(paging)).await?;
for field in response.items.unwrap_or_default() {
println!("Field Id: {}", field.id);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
page, _ := client.Fields.List(
context.Background(),
195,
)
for _, field := range page.Items {
fmt.Printf("Field Id: %d\n", field.Id)
}
```
{% /code %}
@@ -44,7 +44,7 @@ for (const field of fields) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -54,13 +54,47 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetFieldsByIds(fieldIds=[6983, 6986, 6987, 6985, 6984])
response = client.get_fields_by_ids(field_ids=[6983, 6986, 6987, 6985, 6984])
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Count: {response.data.count}')
for field in response.data.fields:
print(f'Field Id: {field.id}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let ids = vec![6983, 6986, 6987, 6985, 6984];
let response = client.batch_get_fields(&ids).await?;
for field in response.items.unwrap_or_default() {
println!("Field Id: {}", field.id);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
batch, _ := client.Fields.GetMany(
context.Background(),
[]int{6983, 6986, 6987, 6985, 6984},
)
for _, field := range batch.Items {
fmt.Printf("Field Id: %d\n", field.Id)
}
```
{% /code %}
@@ -69,8 +69,8 @@ console.log(fileId);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import SaveFileRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import SaveFileRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -81,19 +81,68 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
request = SaveFileRequest(
recordId=140,
fieldId=6989,
fileName='test-attachment.txt',
filePath='test-attachment.txt',
contentType='text/plain',
record_id=140,
field_id=6989,
file_name='test-attachment.txt',
file_path='test-attachment.txt',
content_type='text/plain',
notes='Updating record with attachment.',
modifiedDate=datetime.now()
modified_date=datetime.now()
)
response = client.SaveFile(request)
response = client.save_file(request)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'File Id: {response.data.id}')
```
```rust
use onspring::{OnspringClient, SaveFileRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let request = SaveFileRequest {
record_id: 140,
field_id: 6989,
notes: Some(
"Updating record with attachment.".to_string()
),
modified_date: Some(chrono::Utc::now()),
file_name: "test-attachment.txt".to_string(),
file_data: std::fs::read("test-attachment.txt")?,
content_type: "text/plain".to_string(),
};
let response = client.upload_file(request).await?;
println!("New File Id is: {}", response.id);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
file, _ := os.Open("test-attachment.txt")
response, _ := client.Files.Save(
context.Background(),
onspring.SaveFileRequest{
RecordId: 140,
FieldId: 6989,
Notes: "Updating record with attachment.",
FileName: "test-attachment.txt",
FileContents: file,
},
)
fmt.Printf("New File Id is: %d\n", response.Id)
```
{% /code %}
@@ -42,7 +42,7 @@ res.statusCode === 204
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,12 +52,45 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.DeleteFileById(recordId=140, fieldId=6989, fileId=1904)
response = client.delete_file_by_id(record_id=140, field_id=6989, fileId=1904)
if response.status_code == 204:
print('File deleted')
else:
print('Error deleting file')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
client.delete_file(140, 6989, 1904).await?;
println!("File deleted successfully");
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
err := client.Files.Delete(
context.Background(),
140,
6989,
1904,
)
if err == nil {
fmt.Println("File deleted successfully")
}
```
{% /code %}
@@ -51,7 +51,7 @@ file.stream.pipe(fs.createWriteStream(file.fileName));
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -61,19 +61,60 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetFileById(recordId=1, fieldId=6989, fileId=89)
response = client.get_file_by_id(record_id=1, field_id=6989, fileId=89)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Name: {response.data.file.name}')
print(f'Content Type: {response.data.file.contentType}')
print(f'Content Length: {response.data.file.contentLength}')
print(f'Content Type: {response.data.file.content_type}')
print(f'Content Length: {response.data.file.content_length}')
filePath = f'C:\\Users\\sfree\\Documents\\Temp\\{response.data.file.name}'
file_path = f'C:\\Users\\sfree\\Documents\\Temp\\{response.data.file.name}'
with open(filePath, "wb") as file:
with open(file_path, "wb") as file:
file.write(response.data.file.content)
print(f'File Location: {filePath}')
print(f'File Location: {file_path}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let file = client
.get_file(1, 6989, 89)
.await?;
println!("File Name: {:?}", file.file_name);
println!("Content Type: {:?}", file.content_type);
println!("Size: {} bytes", file.data.len());
std::fs::write(&file.file_name, &file.data)?;
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
file, _ := client.Files.GetContent(
context.Background(),
1,
6989,
89,
)
fmt.Printf("File Name: %s\n", file.FileName)
fmt.Printf("Content Type: %s\n", file.ContentType)
fmt.Printf("Size: %d bytes\n", len(file.Data))
os.WriteFile(file.FileName, file.Data, 0644)
```
{% /code %}
@@ -37,7 +37,7 @@ console.log(fileInfo);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -47,10 +47,45 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetFileInfoById(recordId=1, fieldId=6989, fileId=89)
response = client.get_file_info_by_id(record_id=1, field_id=6989, fileId=89)
print(f'Name: {response.data.fileInfo.name}')
print(f'Content Type: {response.data.fileInfo.contentType}')
print(f'Name: {response.data.file_info.name}')
print(f'Content Type: {response.data.fileInfo.content_type}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let info = client
.get_file_info(1, 6989, 89)
.await?;
println!("Name: {:?}", info.name);
println!("Content Type: {:?}", info.content_type);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
info, _ := client.Files.GetInfo(
context.Background(),
1,
6989,
89,
)
fmt.Printf("Name: %s\n", info.Name)
fmt.Printf("Content Type: %s\n", info.ContentType)
```
{% /code %}
@@ -48,7 +48,7 @@ res.statusCode === 204
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -58,13 +58,50 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.DeleteListItem(
listId=906,
response = client.delete_list_item(
list_id=906,
itemId='36f94d8c-2b9d-465e-9ad1-ede04109efc9'
)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Message: {response.message}')
```
```rust
use onspring::OnspringClient;
use uuid::Uuid;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let item_id = Uuid::parse_str(
"e3371dbf-b557-4a31-b32f-33c0265d2a59"
)?;
client.delete_list_item(906, item_id).await?;
println!("List item deleted");
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
err := client.Lists.Delete(
context.Background(),
906,
"e3371dbf-b557-4a31-b32f-33c0265d2a59",
)
if err == nil {
fmt.Println("List item deleted")
}
```
{% /code %}
@@ -64,8 +64,8 @@ console.log(itemId);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import ListItemRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import ListItemRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -76,17 +76,63 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
request = ListItemRequest(
listId=906,
list_id=906,
name='Not Started',
id=None,
numericValue=0,
numeric_value=0,
color='#ffffff'
)
response = client.AddOrUpdateListItem(request)
response = client.add_or_update_list_item(request)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Id: {response.data.id}')
```
```rust
use onspring::{OnspringClient, SaveListItemRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let request = SaveListItemRequest {
id: None,
name: "Not Started".to_string(),
numeric_value: Some(0.0),
color: Some("#ffffff".to_string()),
};
let response = client
.save_list_item(906, request)
.await?;
println!("Id: {}", response.id);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
numericValue := 0.0
color := "#ffffff"
response, _ := client.Lists.Save(
context.Background(),
906,
onspring.SaveListItemRequest{
Name: "Not Started",
NumericValue: &numericValue,
Color: &color,
},
)
fmt.Printf("Id: %s\n", response.Id)
```
{% /code %}
@@ -42,7 +42,7 @@ res.statusCode === 204
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,10 +52,42 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.DeleteRecordById(appId=195, recordId=140)
response = client.delete_record_by_id(app_id=195, recordId=140)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Message: {response.message}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
client.delete_record(195, 140).await?;
println!("Record deleted");
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
err := client.Records.Delete(
context.Background(),
195,
140,
)
if err == nil {
fmt.Println("Record deleted")
}
```
{% /code %}
@@ -55,8 +55,8 @@ res.statusCode === 204
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import DeleteBatchRecordsRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import DeleteBatchRecordsRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -66,11 +66,50 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
request = DeleteBatchRecordsRequest(appId=195, recordIds=[138, 139])
response = client.DeleteRecordsByIds(request)
request = DeleteBatchRecordsRequest(app_id=195, record_ids=[138, 139])
response = client.delete_records_by_ids(request)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Message: {response.message}')
```
```rust
use onspring::{OnspringClient, BatchDeleteRecordsRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let request = BatchDeleteRecordsRequest {
app_id: 195,
record_ids: vec![138, 139],
};
client.batch_delete_records(request).await?;
println!("Records deleted successfully");
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
err := client.Records.DeleteMany(
context.Background(),
onspring.DeleteManyRecordsRequest{
AppId: 195,
RecordIds: []int{138, 139},
},
)
if err == nil {
fmt.Println("Records deleted successfully")
}
```
{% /code %}
@@ -52,22 +52,82 @@ console.log(record);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import GetRecordByIdRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import GetRecordByIdRequest
from configparser import ConfigParser
request = GetRecordByIdRequest(appId=195, recordId=1)
response = client.GetRecordById(request)
response = client.get_record_by_id(request)
print(f'Status Code: {response.statusCode}')
print(f'AppId: {response.data.appId}')
print(f'RecordId: {response.data.recordId}')
print(f'Status Code: {response.status_code}')
print(f'AppId: {response.data.app_id}')
print(f'RecordId: {response.data.record_id}')
for field in response.data.fields:
print(f'Type: {field.type}')
print(f'FieldId: {field.fieldId}')
print(f'Value: {field.GetResultValueString()}')
print(f'FieldId: {field.field_id}')
print(f'Value: {field.value}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let record = client
.get_record(195, 1, None, None)
.await?;
println!(
"AppId: {}, RecordId: {}",
record.app_id,
record.record_id
);
if let Some(field_data) = record.field_data {
for field in field_data {
println!(
"FieldId: {}, Type: {:?}, Value: {}",
field.field_id,
field.value_type,
field.value
);
}
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
record, _ := client.Records.Get(
context.Background(),
195,
1,
)
fmt.Printf(
"AppId: %d, RecordId: %d\n",
record.AppId,
record.RecordId,
)
for _, field := range record.FieldData {
fmt.Printf(
"FieldId: %d, Type: %s, Value: %v\n",
field.FieldId,
field.Type,
field.Value,
)
}
```
{% /code %}
@@ -41,8 +41,8 @@ for (const app of apps) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import GetRecordsByAppRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import GetRecordsByAppRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -53,22 +53,70 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
request = GetRecordsByAppRequest(appId=195)
response = client.GetRecordsByAppId(request)
response = client.get_records_by_app_id(request)
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}')
print(f'Status Code: {response.status_code}')
print(f'Page Size: {response.data.page_size}')
print(f'Page Number: {response.data.page_number}')
print(f'Total Pages: {response.data.total_pages}')
print(f'Total Records: {response.data.total_records}')
for record in response.data.records:
print(f'AppId: {record.appId}')
print(f'RecordId: {record.recordId}')
print(f'AppId: {record.app_id}')
print(f'RecordId: {record.record_id}')
for field in record.fields:
print(f'Type: {field.type}')
print(f'FieldId: {field.fieldId}')
print(f'Value: {field.GetResultValueString()}')
print(f'FieldId: {field.field_id}')
print(f'Value: {field.value}')
```
```rust
use onspring::{OnspringClient, PagingRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let paging = PagingRequest {
page_number: 1,
page_size: 10,
};
let response = client
.list_records(195, Some(paging), None, None)
.await?;
for record in response.items.unwrap_or_default() {
println!(
"AppId: {}, RecordId: {}",
record.app_id,
record.record_id
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
page, _ := client.Records.List(
context.Background(),
195,
)
for _, record := range page.Items {
fmt.Printf(
"AppId: %d, RecordId: %d\n",
record.AppId,
record.RecordId,
)
}
```
{% /code %}
@@ -68,8 +68,8 @@ for (const record of records) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import GetBatchRecordsRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import GetBatchRecordsRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -80,24 +80,79 @@ url = cfg['prod']['url']
client = OnspringClient(url, key)
request = GetBatchRecordsRequest(
appId=195,
recordIds=[1],
fieldIds=[6983, 6986, 6987, 6985, 6984],
dataFormat='Raw'
app_id=195,
record_ids=[1],
field_ids=[6983, 6986, 6987, 6985, 6984],
data_format='Raw'
)
response = client.GetRecordsByIds(request)
response = client.get_records_by_ids(request)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Count: {response.data.count}')
for record in response.data.records:
print(f'AppId: {record.appId}')
print(f'RecordId: {record.recordId}')
print(f'AppId: {record.app_id}')
print(f'RecordId: {record.record_id}')
for field in record.fields:
print(f'Type: {field.type}')
print(f'FieldId: {field.fieldId}')
print(f'Value: {field.GetResultValueString()}')
print(f'FieldId: {field.field_id}')
print(f'Value: {field.value}')
```
```rust
use onspring::{OnspringClient, BatchGetRecordsRequest, DataFormat};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let request = BatchGetRecordsRequest {
app_id: 195,
record_ids: vec![1],
field_ids: Some(vec![6983, 6986, 6987, 6985, 6984]),
data_format: Some(DataFormat::Raw),
};
let response = client
.batch_get_records(request)
.await?;
for record in response.items.unwrap_or_default() {
println!(
"AppId: {}, RecordId: {}",
record.app_id,
record.record_id
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
batch, _ := client.Records.GetMany(
context.Background(),
onspring.GetManyRecordsRequest{
AppId: 195,
RecordIds: []int{1},
FieldIds: []int{6983, 6986, 6987, 6985, 6984},
DataFormat: "Raw",
},
)
for _, record := range batch.Items {
fmt.Printf(
"AppId: %d, RecordId: %d\n",
record.AppId,
record.RecordId,
)
}
```
{% /code %}
@@ -84,9 +84,9 @@ for (const record of records) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import QueryRecordsRequest
from OnspringApiSdk.Enums import DataFormat
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import QueryRecordsRequest
from onspring_api_sdk.enums import DataFormat
from configparser import ConfigParser
cfg = ConfigParser()
@@ -102,28 +102,83 @@ operator = 'eq'
value = '\'Test Task 5\''
request = QueryRecordsRequest(
appId=195,
app_id=195,
filter=f'{fieldId} {operator} {value}',
fieldIds=[6983, 6986, 6987, 6985, 6984],
dataFormat=DataFormat.Formatted.name,
field_ids=[6983, 6986, 6987, 6985, 6984],
data_format=DataFormat.Formatted.name,
)
response = client.QueryRecords(request)
response = client.query_records(request)
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}')
print(f'Status Code: {response.status_code}')
print(f'Page Size: {response.data.page_size}')
print(f'Page Number: {response.data.page_number}')
print(f'Total Pages: {response.data.total_pages}')
print(f'Total Records: {response.data.total_records}')
for record in response.data.records:
print(f'AppId: {record.appId}')
print(f'RecordId: {record.recordId}')
print(f'AppId: {record.app_id}')
print(f'RecordId: {record.record_id}')
for field in record.fields:
print(f'Type: {field.type}')
print(f'FieldId: {field.fieldId}')
print(f'Value: {field.GetResultValueString()}')
print(f'FieldId: {field.field_id}')
print(f'Value: {field.value}')
```
```rust
use onspring::{OnspringClient, QueryRecordsRequest, DataFormat};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let query = QueryRecordsRequest {
app_id: 195,
filter: "6983 eq 'Test Task 5'".to_string(),
field_ids: Some(vec![6983, 6986, 6987, 6985, 6984]),
data_format: Some(DataFormat::Formatted),
};
let response = client
.query_records(query, None)
.await?;
for record in response.items.unwrap_or_default() {
println!(
"AppId: {}, RecordId: {}",
record.app_id,
record.record_id
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
page, _ := client.Records.Query(
context.Background(),
onspring.QueryRecordsRequest{
AppId: 195,
Filter: "6983 eq 'Test Task 5'",
FieldIds: []int{6983, 6986, 6987, 6985, 6984},
DataFormat: "Formatted",
},
)
for _, record := range page.Items {
fmt.Printf(
"AppId: %d, RecordId: %d\n",
record.AppId,
record.RecordId,
)
}
```
{% /code %}
@@ -87,40 +87,108 @@ console.log(newRecordId);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import StringFieldValue, GuidFieldValue, DateFieldValue, IntegerListValue, Record
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import StringFieldValue, GuidFieldValue, DateFieldValue, IntegerListValue, Record
import uuid
from datetime import datetime
from configparser import ConfigParser
cfg = ConfigParser()
cfg.read('config.ini')
key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
fields = []
fields.append(StringFieldValue(6983, 'A New Test Task'))
fields.append(StringFieldValue(6984, 'This is a test task.'))
fields.append(StringFieldValue(field_id=6983, value='A New Test Task'))
fields.append(StringFieldValue(field_id=6984, value='This is a test task.'))
fields.append(
GuidFieldValue(
6986,
uuid.UUID('4118d53a-9121-4345-8682-07f23d606daa')
)
GuidFieldValue(field_id=6986, value=uuid.UUID('4118d53a-9121-4345-8682-07f23d606daa'))
)
fields.append(
DateFieldValue(
6985,
datetime.datetime(2021, 12, 25)
DateFieldValue(field_id=6985, value=datetime(2021, 12, 25))
)
)
fields.append(IntegerListValue(6987, [4]))
fields.append(IntegerListValue(field_id=6987, value=[4]))
record = Record(
appId=195,
fields
)
record = Record(app_id=195, fields=fields)
response = client.AddOrUpdateRecord(record)
response = client.add_or_update_record(record)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print(f'Id: {response.data.id}')
for warning in response.data.warnings:
print(f'Warning: {warning}')
```
```rust
use onspring::{OnspringClient, SaveRecordRequest};
use std::collections::HashMap;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let mut fields = HashMap::new();
fields.insert(
"6983".to_string(),
serde_json::json!("A New Test Task"),
);
fields.insert(
"6984".to_string(),
serde_json::json!("This is a test task."),
);
fields.insert(
"6985".to_string(),
serde_json::json!("12/25/2021"),
);
fields.insert(
"6986".to_string(),
serde_json::json!("4118d53a-9121-4345-8682-07f23d606daa"),
);
fields.insert(
"6987".to_string(),
serde_json::json!([4]),
);
let request = SaveRecordRequest {
app_id: 195,
record_id: None,
fields,
};
let response = client.save_record(request).await?;
println!("New Record Id is: {}", response.id);
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
response, _ := client.Records.Save(
context.Background(),
onspring.SaveRecordRequest{
AppId: 195,
Fields: map[string]any{
"6983": "A New Test Task",
"6984": "This is a test task.",
"6985": "12/25/2021",
"6986": "4118d53a-9121-4345-8682-07f23d606daa",
"6987": []int{4},
},
},
)
fmt.Printf("New Record Id is: %d\n", response.Id)
```
{% /code %}
@@ -41,8 +41,8 @@ console.log(report);
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from OnspringApiSdk.Models import GetReportByIdRequest
from onspring_api_sdk import OnspringClient
from onspring_api_sdk.models import GetReportByIdRequest
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,16 +52,65 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
request = GetReportByIdRequest(reportId=613)
response = client.GetReportById(request)
request = GetReportByIdRequest(report_id=613)
response = client.get_report_by_id(request)
print(f'Status Code: {response.statusCode}')
print(f'Status Code: {response.status_code}')
print('Columns:')
print(f'{", ".join(response.data.columns)}')
print('Rows:')
for row in response.data.rows:
print(f'Record Id {row.recordId}: {", ".join([str(cell) for cell in row.cells])}')
print(f'Record Id {row.record_id}: {", ".join([str(cell) for cell in row.cells])}')
```
```rust
use onspring::OnspringClient;
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let data = client
.get_report(613, None, None)
.await?;
println!("Columns: {:?}", data.columns);
if let Some(rows) = data.rows {
for row in rows {
println!(
"Record Id {:?}: {:?}",
row.record_id,
row.cells
);
}
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
data, _ := client.Reports.Get(
context.Background(),
613,
)
fmt.Printf("Columns: %v\n", data.Columns)
for _, row := range data.Rows {
fmt.Printf(
"Record Id %v: %v\n",
row.RecordId,
row.Cells,
)
}
```
{% /code %}
@@ -42,7 +42,7 @@ for (const report of reports) {
```
```python
from OnspringApiSdk.OnspringClient import OnspringClient
from onspring_api_sdk import OnspringClient
from configparser import ConfigParser
cfg = ConfigParser()
@@ -52,16 +52,67 @@ key = cfg['prod']['key']
url = cfg['prod']['url']
client = OnspringClient(url, key)
response = client.GetReportsByAppId(appId=195)
app_id = 195
response = client.get_reports_by_app_id(app_id=app_id)
print(f'Status Code: {response.statusCode}')
print(f'App Id: {appId}')
print(f'Status Code: {response.status_code}')
print(f'App Id: {app_id}')
print('Reports:')
for report in response.data.reports:
print(f' Id: {report.id}')
print(f' Name: {report.name}')
print(f' Description: {report.description}')
```
```rust
use onspring::{OnspringClient, PagingRequest};
let client = OnspringClient::builder(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000"
)
.build();
let paging = PagingRequest {
page_number: 1,
page_size: 10,
};
let response = client
.list_reports(195, Some(paging))
.await?;
for report in response.items.unwrap_or_default() {
println!(
"{}, {}, {}",
report.id,
report.app_id,
report.name.unwrap_or_default()
);
}
```
```go
import onspring "github.com/StevanFreeborn/onspring-api-sdk-go"
client := onspring.NewClient(
"000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000",
)
page, _ := client.Reports.List(
context.Background(),
195,
)
for _, report := range page.Items {
fmt.Printf(
"%d, %d, %s\n",
report.Id,
report.AppId,
report.Name,
)
}
```
{% /code %}
+5
View File
@@ -0,0 +1,5 @@
describe('test', () => {
it('should pass', () => {
expect(true).toBe(true);
});
});
-292
View File
@@ -1,292 +0,0 @@
import Clients from '@/app/components/Clients';
import CodeSnippet from '@/app/components/CodeSnippet';
import Fence from '@/app/components/Fence';
import { DOCS_PATH } from '@/app/constants';
import * as MarkdocLibrary from '@/app/lib/markdoc';
import { Doc } from '@/app/types/types';
import { default as Markdoc } from '@markdoc/markdoc';
import fs from 'fs';
import path from 'path';
import React from 'react';
describe('Markdoc lib functions', () => {
describe('getCopyPath', () => {
const version = 'v1.0.0';
const doc: Doc = {
title: 'Title',
folder: 'folder',
copy: 'copy.md',
};
const docPath = 'path/to/doc';
it('returns empty string if doc.copy is undefined', () => {
const doc: Doc = {
title: 'Title',
folder: 'folder',
};
const result = MarkdocLibrary.getCopyPath(
version,
doc,
docPath
);
expect(result).toEqual('');
});
it('returns correct copy path', () => {
const result = MarkdocLibrary.getCopyPath(
version,
doc,
docPath
);
const expected = path.join(
DOCS_PATH,
version,
docPath,
doc.copy!
);
expect(result).toEqual(expected);
});
it('returns correct copy path with leading/trailing slashes in docPath', () => {
const result = MarkdocLibrary.getCopyPath(
version,
doc,
'/path/to/doc/'
);
const expected = path.join(
DOCS_PATH,
version,
docPath,
doc.copy!
);
expect(result).toEqual(expected);
});
it('returns correct copy path with different version', () => {
const result = MarkdocLibrary.getCopyPath(
'v2.0.0',
doc,
docPath
);
const expected = path.join(
DOCS_PATH,
'v2.0.0',
docPath,
doc.copy!
);
expect(result).toEqual(expected);
});
it('returns correct copy path with nested docPath', () => {
const result = MarkdocLibrary.getCopyPath(
version,
doc,
'path/to/nested/doc'
);
const expected = path.join(
DOCS_PATH,
version,
'path/to/nested/doc',
doc.copy!
);
expect(result).toEqual(expected);
});
});
describe('getExamplePath', () => {
const version = 'v1.0.0';
const doc: Doc = {
title: 'Title',
folder: 'folder',
example: 'example.md',
};
const docPath = 'path/to/doc';
it('returns empty string if doc.example is undefined', () => {
const doc: Doc = {
title: 'Title',
folder: 'folder',
};
const result = MarkdocLibrary.getExamplePath(
version,
doc,
docPath
);
expect(result).toEqual('');
});
it('returns correct example path', () => {
const result = MarkdocLibrary.getExamplePath(
version,
doc,
docPath
);
const expected = path.join(
DOCS_PATH,
version,
docPath,
doc.example!
);
expect(result).toEqual(expected);
});
it('returns correct example path with leading/trailing slashes in docPath', () => {
const result = MarkdocLibrary.getExamplePath(
version,
doc,
'/path/to/doc/'
);
const expected = path.join(
DOCS_PATH,
version,
docPath,
doc.example!
);
expect(result).toEqual(expected);
});
it('returns correct example path with different version', () => {
const result = MarkdocLibrary.getExamplePath(
'v2.0.0',
doc,
docPath
);
const expected = path.join(
DOCS_PATH,
'v2.0.0',
docPath,
doc.example!
);
expect(result).toEqual(expected);
});
it('returns correct example path with nested docPath', () => {
const result = MarkdocLibrary.getExamplePath(
version,
doc,
'path/to/nested/doc'
);
const expected = path.join(
DOCS_PATH,
version,
'path/to/nested/doc',
doc.example!
);
expect(result).toEqual(expected);
});
});
describe('parseMarkdown', () => {
const sourcePath = 'test.md';
const sourceContent = '# Test Heading';
beforeAll(() => {
jest
.spyOn(fs, 'readFileSync')
.mockReturnValue(sourceContent);
});
afterAll(() => {
jest.restoreAllMocks();
});
it('should parse markdown file and return react node', () => {
const expected = (
<article>
<h1>Test Heading</h1>
</article>
);
const result =
MarkdocLibrary.parseMarkdown(sourcePath);
expect(result).toEqual(expected);
});
it('should read source file using the correct path', () => {
MarkdocLibrary.parseMarkdown(sourcePath);
expect(fs.readFileSync).toHaveBeenCalledWith(
sourcePath,
'utf8'
);
});
it('should transform the AST using markDocConfig', () => {
const ast = Markdoc.parse(sourceContent);
const spy = jest.spyOn(Markdoc, 'transform');
MarkdocLibrary.parseMarkdown(sourcePath);
expect(spy).toHaveBeenCalledWith(
ast,
MarkdocLibrary.markDocConfig as any
);
});
it('should render react components using Markdoc.renderers', () => {
const ast = Markdoc.parse(sourceContent);
const content = Markdoc.transform(
ast,
MarkdocLibrary.markDocConfig as any
);
const expected = (
<article>
<h1>Test Heading</h1>
</article>
);
const spy = jest.spyOn(Markdoc.renderers, 'react');
const result =
MarkdocLibrary.parseMarkdown(sourcePath);
expect(spy).toHaveBeenCalledWith(content, React, {
components: {
CodeSnippet: CodeSnippet,
Fence: Fence,
Clients: Clients,
},
});
expect(result).toEqual(expected);
});
});
describe('getCopyChild', () => {
it('should return the correct child copy react nodes for the given doc', () => {
const result = MarkdocLibrary.getCopyPath(
'version',
{ title: 'hello', folder: 'hello' },
'hello'
);
expect(result).toEqual('hello');
});
});
});
+21 -7
View File
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"target": "esnext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
@@ -9,10 +13,10 @@
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
@@ -20,9 +24,19 @@
}
],
"paths": {
"@/*": ["./src/*"]
"@/*": [
"./src/*"
]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}