For the complete documentation index, see llms.txt. This page is also available as Markdown.

Management Client

LicenseSpring’s new Go SDK V2 is now available! This version is a complete rewrite with breaking changes and will receive all future updates and support.

The legacy Go SDK (v1) is deprecated and maintained for backward compatibility only. New users should use v2.

Note: Read Common before this.

Importing the Management Client

imports.go
import(
  "gitlab.com/l3178/sdk-go/management_client"
  management_request "gitlab.com/l3178/sdk-go/management_client/models/request"
)

Creating the Client

client.go
config := management_client.NewManagementClientConfiguration("managementKey")
c := management_client.NewManagementClient(config)

Customer API

customer_api_test.go
ctx := context.Background()

t.Run("Create", func(t *testing.T) {
	resp := c.CustomerApi().CreateCustomer(ctx, management_request.CreateCustomerRequest{
		Email:     "ttt@ttt.ttt",
		FirstName: "Test",
	})
	require.NoError(t, resp.Error)
	id = resp.Value.Id
})

t.Run("List", func(t *testing.T) {
	resp := c.CustomerApi().ListCustomers(ctx, management_request.SearchCustomersRequest{
		Email: "ttt@ttt.ttt",
	})
	assert.NoError(t, resp.Error)
	assert.Equal(t, 1, resp.Count)
})

t.Run("Edit", func(t *testing.T) {
	resp := c.CustomerApi().EditCustomer(ctx, id, management_request.CreateCustomerRequest{
		LastName: "abcd",
	})
	assert.NoError(t, resp.Error)
})

t.Run("Get", func(t *testing.T) {
	resp := c.CustomerApi().ShowCustomer(ctx, id)
	assert.NoError(t, resp.Error)
	assert.Equal(t, "abcd", resp.Value.LastName)
})

t.Run("Delete", func(t *testing.T) {
	err := c.CustomerApi().DeleteCustomer(ctx, id)
	assert.NoError(t, err)
})

t.Run("Create", func(t *testing.T) {
	resp := c.CustomerApi().CreateCustomerLabel(ctx, management_request.CreateCustomerLabelRequest{
		Label: "abcd",
		Color: "efgh",
	})
	require.NoError(t, resp.Error)
	id = resp.Value.Id
})

t.Run("List", func(t *testing.T) {
	resp := c.CustomerApi().ListCustomerLabels(ctx, management_request.SearchRequest{})
	assert.NoError(t, resp.Error)
	assert.Equal(t, 1, resp.Count)
})

t.Run("Edit", func(t *testing.T) {
	resp := c.CustomerApi().EditCustomerLabel(ctx, id, management_request.CreateCustomerLabelRequest{
		Color: "1234",
	})
	assert.NoError(t, resp.Error)
})

t.Run("Get", func(t *testing.T) {
	resp := c.CustomerApi().ShowCustomerLabel(ctx, id)
	assert.NoError(t, resp.Error)
	assert.Equal(t, "1234", resp.Value.Color)
})

t.Run("Delete", func(t *testing.T) {
	err := c.CustomerApi().DeleteCustomerLabel(ctx, id)
	assert.NoError(t, err)
})

t.Run("Create", func(t *testing.T) {
	resp := c.CustomerApi().CreateCustomerAccount(ctx, management_request.CreateCustomerAccountRequest{
		Code: "abcd",
		Name: "efgh",
	})
	require.NoError(t, resp.Error)
	id = resp.Value.Id
})

t.Run("List", func(t *testing.T) {
	resp := c.CustomerApi().ListCustomerAccounts(ctx, management_request.SearchRequest{})
	assert.NoError(t, resp.Error)
	assert.Equal(t, 1, resp.Count)
})

t.Run("Edit", func(t *testing.T) {
	resp := c.CustomerApi().EditCustomerAccount(ctx, id, management_request.CreateCustomerAccountRequest{
		Description: "test",
	})
	assert.NoError(t, resp.Error)
})

t.Run("Get", func(t *testing.T) {
	resp := c.CustomerApi().ShowCustomerAccount(ctx, id)
	assert.NoError(t, resp.Error)
	assert.Equal(t, "test", resp.Value.Description)
})

t.Run("Delete", func(t *testing.T) {
	err := c.CustomerApi().DeleteCustomerAccount(ctx, id)
	assert.NoError(t, err)
})

Device API

License API

Order API

Product API

Was this helpful?