Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-10-28 13:41:00 +00:00
parent ec8910b174
commit fced949d94
43 changed files with 4129 additions and 0 deletions

48
go/id/id.go Executable file
View File

@@ -0,0 +1,48 @@
package id
import (
"github.com/m3o/m3o-go/client"
)
func NewIdService(token string) *IdService {
return &IdService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type IdService struct {
client *client.Client
}
// Generate a unique ID. Defaults to uuid.
func (t *IdService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
rsp := &GenerateResponse{}
return rsp, t.client.Call("id", "Generate", request, rsp)
}
// List the types of IDs available. No query params needed.
func (t *IdService) Types(request *TypesRequest) (*TypesResponse, error) {
rsp := &TypesResponse{}
return rsp, t.client.Call("id", "Types", request, rsp)
}
type GenerateRequest struct {
// type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit)
Type string `json:"type"`
}
type GenerateResponse struct {
// the unique id generated
Id string `json:"id"`
// the type of id generated
Type string `json:"type"`
}
type TypesRequest struct {
}
type TypesResponse struct {
Types []string `json:"types"`
}