feat: add Go SDK support and examples to documentation

This commit is contained in:
Stevan Freeborn
2026-03-26 22:09:26 -05:00
parent fb0e177d91
commit 3c569db660
24 changed files with 457 additions and 0 deletions
+14
View File
@@ -78,6 +78,20 @@ export default function Clients({
`, `,
official: false, official: false,
}, },
{
name: 'Go',
repoLink:
'https://github.com/StevanFreeborn/onspring-api-sdk-go',
installCommand:
'go get github.com/StevanFreeborn/onspring-api-sdk-go',
svg: `
<svg width="30" height="30" viewBox="0 0 640 640" xmlns="http://www.w3.org/2000/svg">
<rect width="640" height="640" fill="#29BEB0"/>
<path d="M400.1 258.8C389.2 261.6 380.2 263.1 371 266.4C363.7 268.3 356.3 270.3 347.8 272.5L347.2 272.6C343 273.8 342.6 273.9 338.7 269.4C334 264.1 330.6 260.7 324.1 257.5C304.4 247.9 285.4 250.7 267.7 262.2C246.5 275.9 235.6 296.2 235.9 321.4C236.2 346.4 253.3 366.9 277.1 370.3C299.1 373.1 316.9 365.7 330.9 349.8C333 347.2 334.9 344.5 337 341.5C337.8 340.5 338.5 339.4 339.3 338.2L279.2 338.2C272.7 338.2 271.1 334.2 273.3 328.9C277.3 319.2 284.8 303 289.2 294.9C290.1 293.1 292.3 289.1 296.1 289.1L397.2 289.1C401.7 275.7 409 262.2 418.8 249.4C441.5 219.5 468.1 203.9 506 197.4C537.8 191.8 567.7 194.9 594.9 213.3C619.5 230.1 634.7 252.9 638.8 282.8C644.1 324.9 631.9 359.1 602.1 388.4C582.4 409.3 557.2 422.4 528.2 428.3C522.6 429.3 517.1 429.8 511.7 430.3C508.8 430.5 506 430.8 503.2 431.1C474.9 430.5 449 422.4 427.2 403.7C411.9 390.4 401.3 374.1 396.1 355.2C392.4 362.5 388.1 369.6 382.1 376.3C360.5 405.9 331.2 424.3 294.2 429.2C263.6 433.3 235.3 427.4 210.3 408.7C187.3 391.2 174.2 368.2 170.8 339.5C166.7 305.5 176.7 274.1 197.2 248.2C219.4 219.2 248.7 200.8 284.5 194.3C313.8 188.1 341.8 192.4 367.1 209.6C383.6 220.5 395.4 235.4 403.2 253.5C405.1 256.3 403.8 257.9 400.1 258.8zM48.3 264.4C47 264.4 46.7 263.8 47.4 262.8L54 254.4C54.6 253.5 56.2 252.9 57.4 252.9L168.7 252.9C169.9 252.9 170.2 253.8 169.6 254.7L164.3 262.8C163.7 263.8 162.1 264.7 161.2 264.7L48.4 264.4zM1.2 293.1C0 293.1-.4 292.4 .3 291.5L6.8 283.1C7.4 282.2 9 281.5 10.2 281.5L152.3 281.5C153.5 281.5 154.1 282.5 153.8 283.4L151.3 290.9C151 292.1 149.8 292.8 148.5 292.8L1.2 293.1zM75.7 319.9C75.1 320.8 75.4 321.7 76.6 321.7L144.6 322C145.5 322 146.8 321.1 146.8 319.9L147.4 312.4C147.4 311.1 146.8 310.2 145.5 310.2L83.2 310.2C82 310.2 80.7 311.1 80.1 312.1L75.7 319.9zM577.2 301.9C577 299.3 576.9 297.1 576.5 294.9C570.9 264.1 542.5 246.6 512.9 253.5C483.9 260 465.2 278.4 458.4 307.7C452.8 332 464.6 356.6 487 366.6C504.2 374.1 521.3 373.2 537.8 364.7C562.4 351.1 575.8 332 577.4 305.2C577.3 304 577.3 302.9 577.2 301.9z"/>
</svg>
`,
official: false,
},
], ],
} as { } as {
[key: string]: { [key: string]: {
+1
View File
@@ -4,6 +4,7 @@ import 'prismjs/components/prism-csharp';
import 'prismjs/components/prism-json'; import 'prismjs/components/prism-json';
import 'prismjs/components/prism-python'; import 'prismjs/components/prism-python';
import 'prismjs/components/prism-rust'; import 'prismjs/components/prism-rust';
import 'prismjs/components/prism-go';
import './prism-custom.css'; import './prism-custom.css';
export default function Fence({ export default function Fence({
@@ -73,6 +73,21 @@ println!(
); );
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -90,6 +90,22 @@ for app in response.items.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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -87,6 +87,23 @@ for app in response.items.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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -68,4 +68,18 @@ client.ping().await?;
println!("Connected to the Onspring API successfully."); 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 %} {% /code %}
@@ -67,6 +67,21 @@ let field = client.get_field(6986).await?;
println!("Field Id: {}", field.id); 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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -84,6 +84,23 @@ for field in response.items.unwrap_or_default() {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -79,6 +79,23 @@ for field in response.items.unwrap_or_default() {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -121,6 +121,29 @@ let response = client.upload_file(request).await?;
println!("New File Id is: {}", response.id); 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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -73,4 +73,23 @@ client.delete_file(140, 6989, 1904).await?;
println!("File deleted successfully"); 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 %} {% /code %}
@@ -95,6 +95,27 @@ println!("Size: {} bytes", file.data.len());
std::fs::write(&file.file_name, &file.data)?; 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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="text" %} {% code heading="RESPONSE" defaultLanguage="text" %}
@@ -69,6 +69,24 @@ println!("Name: {:?}", info.name);
println!("Content Type: {:?}", info.content_type); 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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -85,4 +85,22 @@ client.delete_list_item(906, item_id).await?;
println!("List item deleted"); 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 %} {% /code %}
@@ -111,6 +111,29 @@ let response = client
println!("Id: {}", response.id); 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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -71,4 +71,22 @@ client.delete_record(195, 140).await?;
println!("Record deleted"); 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 %} {% /code %}
@@ -91,4 +91,24 @@ client.batch_delete_records(request).await?;
println!("Records deleted successfully"); 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 %} {% /code %}
@@ -100,6 +100,35 @@ if let Some(field_data) = record.field_data {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -97,6 +97,27 @@ for record in response.items.unwrap_or_default() {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -128,6 +128,32 @@ for record in response.items.unwrap_or_default() {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -154,6 +154,32 @@ for record in response.items.unwrap_or_default() {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -165,6 +165,30 @@ let response = client.save_record(request).await?;
println!("New Record Id is: {}", response.id); 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 %} {% /code %}
{% code heading="Response" defaultLanguage="json" %} {% code heading="Response" defaultLanguage="json" %}
@@ -89,6 +89,29 @@ if let Some(rows) = data.rows {
} }
``` ```
```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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}
@@ -91,6 +91,28 @@ for report in response.items.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 %} {% /code %}
{% code heading="RESPONSE" defaultLanguage="json" %} {% code heading="RESPONSE" defaultLanguage="json" %}