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
@@ -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 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 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 heading="RESPONSE" defaultLanguage="json" %}
@@ -68,4 +68,18 @@ 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 %}
@@ -67,6 +67,21 @@ 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 %}
{% 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 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 heading="RESPONSE" defaultLanguage="json" %}
@@ -121,6 +121,29 @@ 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 %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -73,4 +73,23 @@ 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 %}
@@ -95,6 +95,27 @@ 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 %}
{% code heading="RESPONSE" defaultLanguage="text" %}
@@ -69,6 +69,24 @@ 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 %}
{% code heading="RESPONSE" defaultLanguage="json" %}
@@ -85,4 +85,22 @@ 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 %}
@@ -111,6 +111,29 @@ let response = client
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 heading="RESPONSE" defaultLanguage="json" %}
@@ -71,4 +71,22 @@ 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 %}
@@ -91,4 +91,24 @@ 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 %}
@@ -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 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 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 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 heading="RESPONSE" defaultLanguage="json" %}
@@ -165,6 +165,30 @@ 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 %}
{% 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 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 heading="RESPONSE" defaultLanguage="json" %}