Skip to content

speakeasy-sdks/optional-v1-go

Repository files navigation

github.com/speakeasy-sdks/optional-v1-go

SDK Installation

go get github.com/speakeasy-sdks/optional-v1-go

SDK Example Usage

package main

import (
	"context"
	optionalv1go "github.com/speakeasy-sdks/optional-v1-go"
	"github.com/speakeasy-sdks/optional-v1-go/pkg/models/operations"
	"github.com/speakeasy-sdks/optional-v1-go/pkg/models/shared"
	"log"
)

func main() {
	s := optionalv1go.New()

	ctx := context.Background()
	res, err := s.Body.SendChild(ctx, operations.SendChildRequest{
		ChildClass: shared.ChildClass{
			ChildClassArray: []shared.ChildClass{
				shared.ChildClass{},
			},
			GrandParentRequired:         "string",
			GrandParentRequiredNullable: "string",
			ParentRequired:              "string",
			ParentRequiredNullable:      "string",
			Required:                    "string",
			RequiredNullable:            "string",
		},
		Field:     "string",
		SetToNull: false,
		UnSet:     false,
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.ServerResponse != nil {
		// handle response
	}
}

Available Resources and Operations

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned response object will have a Next method that can be called to pull down the next group of results. If the return value of Next is nil, then there are no more pages to be fetched.

Here's an example of one such pagination call:

Special Types

This SDK defines the following custom types to assist with marshalling and unmarshalling data.

Date

types.Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".

Usage

d1 := types.NewDate(time.Now()) // returns *types.Date

d2 := types.DateFromTime(time.Now()) // returns types.Date

d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error

d4, err := types.DateFromString("2019-01-01") // returns types.Date, error

d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error

d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on error

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy