celitech

package module
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 12 Imported by: 0

README

Celitech Go SDK 2.0.4

Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.

Versions

  • API version: 2.0.4
  • SDK version: 2.0.4

About the API

Welcome to the CELITECH API documentation!

Useful links: Homepage | Support email | Blog

Table of Contents

Setup & Configuration

Supported Language Versions

This SDK is compatible with the following versions: Go >= 1.19.0

Authentication

OAuth Authentication

The Celitech API uses OAuth for authentication.

You need to provide the OAuth parameters when initializing the SDK.

config := celitech.NewConfig()
config.SetClientID("CLIENT_ID")
config.SetClientSecret("CLIENT_SECRET")
client := celitech.NewCelitech(config)

Environment Variables

These are the environment variables for the SDK:

Name Description
CLIENT_ID Client ID parameter
CLIENT_SECRET Client Secret parameter

Environment variables are a way to configure your application outside the code. You can set these environment variables on the command line or use your project's existing tooling for managing environment variables.

If you are using a .env file, a template with the variable names is provided in the .env.example file located in the same directory as this README.

Setting a Custom Timeout

You can set a custom timeout for the SDK's HTTP requests as follows:

import "time"

config := celitech.NewConfig()

sdk := celitech.NewCelitech(config)

sdk.SetTimeout(10 * time.Second)

Sample Usage

Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:

import (
  "fmt"
  "encoding/json"
  "context"
  "github.com/Celitech/CelitechSDKGo/v2"
)

config := celitech.NewConfig()
config.SetClientID("CLIENT_ID")
config.SetClientSecret("CLIENT_SECRET")
client := celitech.NewCelitech(config)

response, err := client.Destinations.ListDestinations(context.Background())
if err != nil {
  panic(err)
}

fmt.Println(response)

Services

The SDK provides various services to interact with the API.

Below is a list of all available services with links to their detailed documentation:
Name
Destinations
Packages
Purchases
ESim
IFrame
Response Wrappers

All services use response wrappers to provide a consistent interface to return the responses from the API.

The response wrapper itself is a generic struct that contains the response data and metadata.

Below are the response wrappers used in the SDK:
CelitechResponse[T]

This response wrapper is used to return the response data from the API. It contains the following fields:

Name Type Description
Data T The body of the API response
Metadata CelitechResponseMetadata Status code and headers returned by the API
CelitechError[T]

This response wrapper is used to return an error. It contains the following fields:

Name Type Description
Err error The error that occurred
Data *T The deserialized error response data (nil if unmarshaling failed)
Body []byte The raw body of the API response
Metadata CelitechErrorMetadata Status code and headers returned by the API
CelitechResponseMetadata

This struct is shared by both response wrappers and contains the following fields:

Name Type Description
Headers map[string]string A map containing the headers returned by the API
StatusCode int The status code returned by the API

Models

The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.

Below is a list of all available models with links to their detailed documentation:
Name Description
ListDestinationsOkResponse
ListPackagesOkResponse
CreatePurchaseV2OkResponse
CreatePurchaseV2Request
ListPurchasesOkResponse
CreatePurchaseOkResponse
CreatePurchaseRequest
TopUpEsimOkResponse
TopUpEsimRequest
EditPurchaseOkResponse
EditPurchaseRequest
GetPurchaseConsumptionOkResponse
GetEsimOkResponse
GetEsimDeviceOkResponse
GetEsimHistoryOkResponse
TokenOkResponse
GrantType

License

This SDK is licensed under the MIT License.

See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

NewConfig creates a Config with spec-derived defaults.

NewOAuthToken creates a new OAuthToken — use when implementing a custom TokenCache.

NewRetryConfig returns a RetryConfig initialized with spec-derived defaults.

WithBaseURL returns a RequestOption that overrides BaseURL for a single request.

WithClientID returns a RequestOption that overrides ClientID for a single request.

WithClientSecret returns a RequestOption that overrides ClientSecret for a single request.

WithOAuthBaseURL returns a RequestOption that overrides OAuthBaseURL for a single request.

WithRetryConfig returns a RequestOption that overrides the RetryConfig for a single request.

WithTimeout returns a RequestOption that overrides Timeout for a single request.

Functions

func Null

func Null[T any]() *param.Nullable[T]

Null returns a *param.Nullable[T] with IsNull set to true, signalling an explicit JSON null.

func Nullable

func Nullable[T any](v T) *param.Nullable[T]

Nullable returns a *param.Nullable[T] set to v — use for nullable fields with a value.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v — use when no type-specific helper exists.

Types

type Celitech

type Celitech struct {
	Destinations *destinations.Service
	Packages     *packages.Service
	Purchases    *purchases.Service
	ESim         *esim.Service
	IFrame       *iframe.Service
	// contains filtered or unexported fields
}

Celitech is the main SDK client that provides access to all service endpoints. It manages configuration, authentication, and service instances with centralized settings.

func NewCelitech

func NewCelitech(config Config) *Celitech

func (*Celitech) SetBaseURL

func (c *Celitech) SetBaseURL(baseURL string)

func (*Celitech) SetClientID

func (c *Celitech) SetClientID(clientID string)

func (*Celitech) SetClientSecret

func (c *Celitech) SetClientSecret(clientSecret string)

func (*Celitech) SetEnvironment

func (c *Celitech) SetEnvironment(environment Environment)

SetEnvironment configures the SDK to use the specified environment's base URL.

func (*Celitech) SetOAuthBaseURL

func (c *Celitech) SetOAuthBaseURL(oAuthBaseURL string)

func (*Celitech) SetTimeout

func (c *Celitech) SetTimeout(timeout time.Duration)

func (*Celitech) SetTokenCache

func (c *Celitech) SetTokenCache(cache TokenCache)

SetTokenCache attaches a persistent token cache to the SDK.

type Config

type Config = celitechconfig.Config

Config holds all configuration parameters for the SDK client.

type Environment

type Environment = celitechconfig.Environment

Environment defines the available API base URLs.

const (
	DefaultEnvironment Environment = celitechconfig.DefaultEnvironment
)

Environment constants for the available API base URLs.

type OAuthToken

type OAuthToken = oauthtokenmanager.OAuthToken

OAuthToken represents a cached OAuth access token with scopes and optional expiry.

type RequestOption

type RequestOption = celitechconfig.RequestOption

RequestOption is a function that configures a single request.

type RetryConfig

type RetryConfig = celitechconfig.RetryConfig

RetryConfig holds all runtime-configurable retry parameters.

type TokenCache

type TokenCache = oauthtokenmanager.TokenCache

TokenCache is the interface for persisting OAuth access tokens across process restarts. Implement this interface and pass it to SetTokenCache to enable token persistence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL