mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-14 03:34:49 +00:00
48 lines
897 B
Go
Executable File
48 lines
897 B
Go
Executable File
package app
|
|
|
|
import (
|
|
"go.m3o.com/client"
|
|
)
|
|
|
|
func NewAppService(token string) *AppService {
|
|
return &AppService{
|
|
client: client.NewClient(&client.Options{
|
|
Token: token,
|
|
}),
|
|
}
|
|
}
|
|
|
|
type AppService struct {
|
|
client *client.Client
|
|
}
|
|
|
|
// Reserve your app name
|
|
func (t *AppService) Reserve(request *ReserveRequest) (*ReserveResponse, error) {
|
|
|
|
rsp := &ReserveResponse{}
|
|
return rsp, t.client.Call("app", "Reserve", request, rsp)
|
|
|
|
}
|
|
|
|
type Reservation struct {
|
|
// time of reservation
|
|
Created string `json:"created"`
|
|
// time reservation expires
|
|
Expires string `json:"expires"`
|
|
// name of the app
|
|
Name string `json:"name"`
|
|
// owner id
|
|
Owner string `json:"owner"`
|
|
// associated token
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
type ReserveRequest struct {
|
|
// name of your app e.g helloworld
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type ReserveResponse struct {
|
|
Reservation *Reservation `json:"reservation"`
|
|
}
|