Merge pull request #7 from StevanFreeborn/stevanfreeborn/feat/add-rust-sdk-and-examples

feat: add rust sdk examples
This commit is contained in:
Stevan Freeborn authored and GitHub committed 2026-03-26 21:56:17 -05:00
commit fb0e177d91
38 files changed
+10084 -6406

No files matched your search

+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;
+9409 -6332
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.5",
"jest": "^30.3.0",
"jest-environment-jsdom": "^30.3.0",
"prettier": "^3.8.1",
"ts-node": "^10.9.2"
}
}
+13
View File
@@ -65,6 +65,19 @@ export default function Clients({
`,
official: false,
},
{
name: 'Rust',
repoLink:
'https://github.com/StevanFreeborn/onspring-api-sdk-rust',
installCommand: 'cargo add onspring-api-sdk-rust',
svg: `
<svg width="30" height="30" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg" >
<rect width="640" height="640" fill="#D34516"/>
<path d="M572.5 313.8L550.7 300.3C550.5 298.3 550.4 296.4 550.2 294.4L568.9 276.9C569.8 276 570.5 275 570.9 273.8C571.3 272.6 571.4 271.3 571.1 270.1C570.8 268.9 570.3 267.7 569.5 266.8C568.7 265.9 567.7 265.1 566.5 264.7L542.5 255.7C542 253.8 541.4 251.9 540.8 250.1L555.8 229.3C556.5 228.3 557 227.1 557.1 225.9C557.2 224.7 557.1 223.4 556.6 222.2C556.1 221 555.4 220 554.4 219.3C553.4 218.6 552.3 218 551 217.8L525.6 213.6C524.7 211.9 523.8 210.2 522.9 208.4L533.6 185C534.1 183.9 534.3 182.6 534.2 181.4C534.1 180.2 533.7 179 533 177.9C532.3 176.8 531.4 176 530.2 175.4C529 174.8 527.8 174.6 526.6 174.6L500.8 175.5C499.6 174 498.4 172.6 497.2 171.1L503 145.8C503.3 144.6 503.3 143.3 502.9 142.1C502.5 140.9 501.9 139.8 501 138.9C500.1 138 499 137.4 497.8 137C496.6 136.6 495.3 136.6 494.1 136.9L469 142.9C467.6 141.7 466.1 140.5 464.6 139.3L465.5 113.5C465.6 112.2 465.3 111 464.7 109.9C464.1 108.8 463.3 107.8 462.2 107.1C461.1 106.4 460 106 458.7 105.9C457.4 105.8 456.2 106 455 106.5L431.7 117.2C430 116.3 428.3 115.4 426.6 114.5L422.4 89.1C422.2 87.9 421.7 86.7 420.9 85.7C420.1 84.7 419.1 84 418 83.5C416.9 83 415.6 82.8 414.3 83C413 83.2 411.9 83.6 410.9 84.3L390 99.3C388.1 98.7 386.2 98.2 384.4 97.6L375.4 73.6C375 72.4 374.2 71.4 373.3 70.6C372.4 69.8 371.2 69.2 370 69C368.8 68.8 367.5 68.8 366.3 69.2C365.1 69.6 364 70.3 363.2 71.2L345.6 89.9C343.6 89.7 341.7 89.5 339.7 89.4L326.3 67.5C325.6 66.4 324.7 65.6 323.6 64.9C322.5 64.2 321.3 64 320 64C318.7 64 317.5 64.3 316.4 64.9C315.3 65.5 314.4 66.4 313.7 67.5L300.2 89.3C298.2 89.5 296.3 89.6 294.3 89.9L276.9 71.1C276 70.2 275 69.5 273.8 69.1C272.6 68.7 271.3 68.6 270.1 68.9C268.9 69.2 267.7 69.7 266.8 70.5C265.9 71.3 265.1 72.3 264.7 73.5L255.7 97.5C253.8 98.1 251.9 98.6 250 99.2L229.2 84.2C228.2 83.5 227 83 225.8 82.9C224.6 82.8 223.3 82.9 222.1 83.4C220.9 83.9 219.9 84.6 219.2 85.6C218.5 86.6 217.9 87.7 217.7 89L213.5 114.4C211.8 115.3 210.1 116.2 208.3 117.1L184.9 106.6C183.8 106.1 182.5 105.9 181.2 106C179.9 106.1 178.7 106.5 177.7 107.2C176.7 107.9 175.8 108.9 175.2 110C174.6 111.1 174.4 112.4 174.4 113.6L175.3 139.4C173.8 140.6 172.3 141.8 170.9 143L145.8 137C144.6 136.7 143.3 136.7 142.1 137.1C140.9 137.5 139.8 138.1 138.9 139C138 139.9 137.4 141 137 142.2C136.6 143.4 136.6 144.7 136.9 145.9L142.9 171C141.7 172.4 140.5 173.9 139.3 175.4L113.5 174.5C112.2 174.5 111 174.7 109.9 175.3C108.8 175.9 107.8 176.7 107.1 177.7C106.4 178.7 106 179.9 105.9 181.2C105.8 182.5 106 183.7 106.5 184.8L117.2 208.2C116.3 209.9 115.4 211.6 114.5 213.4L89.1 217.5C87.9 217.7 86.7 218.2 85.7 219C84.7 219.8 84 220.8 83.5 221.9C83 223 82.8 224.3 83 225.6C83.2 226.9 83.6 228 84.3 229L99.3 249.8C98.7 251.7 98.2 253.6 97.6 255.5L73.6 264.5C72.4 264.9 71.4 265.7 70.6 266.6C69.8 267.5 69.2 268.7 69 269.9C68.8 271.1 68.8 272.4 69.2 273.6C69.6 274.8 70.3 275.9 71.2 276.7L89.9 294.2C89.7 296.2 89.5 298.1 89.3 300.1L67.5 313.8C66.4 314.5 65.6 315.4 64.9 316.5C64.2 317.6 64 318.8 64 320.1C64 321.4 64.3 322.6 64.9 323.7C65.5 324.8 66.4 325.7 67.5 326.4L89.3 339.9C89.5 341.9 89.6 343.8 89.9 345.8L71.1 363.1C70.2 364 69.5 365 69.1 366.2C68.7 367.4 68.6 368.7 68.9 369.9C69.2 371.1 69.7 372.3 70.5 373.2C71.3 374.1 72.3 374.9 73.5 375.3L97.5 384.3C98.1 386.2 98.6 388.1 99.2 389.9L84.2 410.7C83.5 411.7 83 412.9 82.9 414.1C82.8 415.3 82.9 416.6 83.4 417.8C83.9 419 84.6 420 85.6 420.7C86.6 421.4 87.7 422 89 422.2L114.4 426.4C115.3 428.1 116.2 429.8 117.1 431.5L106.6 455.1C106.1 456.2 105.9 457.5 106 458.7C106.1 459.9 106.5 461.2 107.2 462.2C107.9 463.3 108.8 464.1 109.9 464.7C111 465.3 112.3 465.5 113.5 465.5L139.3 464.6C140.5 466.1 141.7 467.5 142.9 469L137 494.2C136.7 495.4 136.7 496.7 137.1 497.9C137.5 499.1 138.1 500.2 139 501.1C139.9 502 141 502.6 142.2 503C143.4 503.4 144.7 503.4 145.9 503.1L171.1 497.2C172.6 498.4 174 499.6 175.5 500.8L174.6 526.6C174.6 527.9 174.8 529.1 175.4 530.2C176 531.3 176.8 532.3 177.9 533C179 533.7 180.1 534.1 181.4 534.2C182.7 534.3 183.9 534.1 185 533.6L208.4 522.9C210.1 523.8 211.8 524.7 213.5 525.6L217.7 551C217.9 552.2 218.4 553.4 219.2 554.4C220 555.4 221 556.2 222.1 556.6C223.2 557 224.5 557.3 225.8 557.1C227.1 556.9 228.2 556.5 229.2 555.8L250 540.8C251.9 541.4 253.8 541.9 255.6 542.5L264.6 566.5C265 567.7 265.8 568.7 266.7 569.5C267.6 570.3 268.8 570.9 270 571.1C271.2 571.3 272.5 571.3 273.7 570.9C274.9 570.5 276 569.8 276.8 568.9L294.3 550.2C296.3 550.4 298.2 550.6 300.2 550.8L313.7 572.6C314.4 573.7 315.3 574.5 316.4 575.2C317.5 575.9 318.7 576.1 320 576.1C321.3 576.1 322.5 575.8 323.6 575.2C324.7 574.6 325.6 573.7 326.3 572.6L339.8 550.8C341.8 550.6 343.7 550.5 345.7 550.2L363.2 568.9C364.1 569.8 365.1 570.5 366.3 570.9C367.5 571.3 368.8 571.4 370 571.1C371.2 570.8 372.4 570.3 373.3 569.5C374.2 568.7 375 567.7 375.4 566.5L384.4 542.5C386.3 541.9 388.2 541.4 390 540.8L410.8 555.8C411.8 556.5 413 557 414.2 557.1C415.4 557.2 416.7 557.1 417.9 556.6C419.1 556.1 420.1 555.4 420.8 554.4C421.5 553.4 422.1 552.3 422.3 551L426.5 525.6C428.2 524.7 429.9 523Line truncated
</svg>
`,
official: false,
},
],
} as {
[key: string]: {
+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>
+1
View File
@@ -3,6 +3,7 @@ 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 './prism-custom.css';
export default function Fence({
+4 -1
View File
@@ -1,3 +1,4 @@
import { ChangeEvent } from 'react';
import { useSectionContext } from '../context/section';
import { Doc, DocsStructure } from '../types/types';
import { toKebabCase } from '../utils/stringUtils';
@@ -9,7 +10,9 @@ export default function SectionDropdown({
version: DocsStructure;
}) {
const { section, setSection } = useSectionContext();
const handleSelectChange = (e: any) => {
const handleSelectChange = (
e: ChangeEvent<HTMLSelectElement>
) => {
setSection(e.target.value);
location.hash = e.target.value;
};
+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>
+6 -5
View File
@@ -15,11 +15,12 @@ export const metadata = {
},
],
},
viewport: {
width: 'device-width',
initialScale: 1,
maximumScale: 1,
},
};
export const viewport = {
width: 'device-width',
initialScale: 1,
maximumScale: 1,
};
export default function RootLayout({
+15 -3
View File
@@ -83,7 +83,7 @@ function parseMarkdown(sourcePath: string): ReactNode {
const ast = Markdoc.parse(source);
const content = Markdoc.transform(
ast,
markDocConfig as any
markDocConfig as never
);
const children = Markdoc.renderers.react(content, React, {
components: {
@@ -102,7 +102,13 @@ function getCopyChild(
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(
@@ -111,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(
@@ -56,6 +56,23 @@ 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()
);
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -66,6 +66,30 @@ for app in response.data.apps:
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()
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -67,6 +67,26 @@ for app in response.data.apps:
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()
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -56,4 +56,16 @@ 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.");
```
{% /code %}
@@ -54,6 +54,19 @@ print(f'Status Code: {response.statusCode}')
print(f'Field Id: {response.data.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);
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -64,6 +64,26 @@ 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);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -63,6 +63,22 @@ 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);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -96,6 +96,31 @@ print(f'Status Code: {response.statusCode}')
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);
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -60,4 +60,17 @@ 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");
```
{% /code %}
@@ -76,6 +76,25 @@ with open(filePath, "wb") as file:
print(f'File Location: {filePath}')
```
```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)?;
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="text" %}
@@ -53,6 +53,22 @@ print(f'Name: {response.data.fileInfo.name}')
print(f'Content Type: {response.data.fileInfo.contentType}')
```
```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);
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -67,4 +67,22 @@ print(f'Status Code: {response.statusCode}')
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");
```
{% /code %}
@@ -89,6 +89,28 @@ print(f'Status Code: {response.statusCode}')
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);
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -58,4 +58,17 @@ print(f'Status Code: {response.statusCode}')
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");
```
{% /code %}
@@ -73,4 +73,22 @@ print(f'Status Code: {response.statusCode}')
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");
```
{% /code %}
@@ -70,6 +70,36 @@ for field in response.data.fields:
print(f'Value: {field.GetResultValueString()}')
```
```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
);
}
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -71,6 +71,32 @@ for record in response.data.records:
print(f'Value: {field.GetResultValueString()}')
```
```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
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -100,6 +100,34 @@ for record in response.data.records:
print(f'Value: {field.GetResultValueString()}')
```
```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
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -126,6 +126,34 @@ for record in response.data.records:
print(f'Value: {field.GetResultValueString()}')
```
```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
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -123,6 +123,48 @@ 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);
```
{% /code %}
{% code heading="Response" defaultLanguage="json" %}
@@ -64,6 +64,31 @@ for row in response.data.rows:
print(f'Record Id {row.recordId}: {", ".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
);
}
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -64,6 +64,33 @@ for report in response.data.reports:
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()
);
}
```
{% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %}
+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"
]
}