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
38 changed files with 7390 additions and 9161 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({
+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>
+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({
+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(
@@ -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 %}
+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"
]
}