v1.0.0
This commit is contained in:
@@ -5,11 +5,10 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (l Locations) GetUrl(ctx context.Context) (string, error) {
|
||||
url := "/locations/getUrl"
|
||||
prefix := "/cloudapi"
|
||||
// GetURL gets the portal URL
|
||||
func (l Locations) GetURL(ctx context.Context) (string, error) {
|
||||
url := "/cloudapi/locations/getUrl"
|
||||
|
||||
url = prefix + url
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -6,27 +6,32 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Request struct for get list of locations
|
||||
type ListRequest struct {
|
||||
Page uint64 `url:"page"`
|
||||
Size uint64 `url:"size"`
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty"`
|
||||
}
|
||||
|
||||
func (l Locations) List(ctx context.Context, req ListRequest) (LocationsList, error) {
|
||||
url := "/locations/list"
|
||||
prefix := "/cloudapi"
|
||||
// List gets list all locations
|
||||
func (l Locations) List(ctx context.Context, req ListRequest) (ListLocations, error) {
|
||||
url := "/cloudapi/locations/list"
|
||||
|
||||
url = prefix + url
|
||||
locationsListRaw, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
locationsList := LocationsList{}
|
||||
err = json.Unmarshal(locationsListRaw, &locationsList)
|
||||
list := ListLocations{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return locationsList, nil
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
// API Actor api for managing locations
|
||||
package locations
|
||||
|
||||
import (
|
||||
"github.com/rudecs/decort-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to locations
|
||||
type Locations struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for locations endpoints
|
||||
func New(client interfaces.Caller) *Locations {
|
||||
return &Locations{
|
||||
client,
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
package locations
|
||||
|
||||
type Location struct {
|
||||
GID uint64 `json:"gid"`
|
||||
ID uint64 `json:"id"`
|
||||
GUID uint64 `json:"guid"`
|
||||
LocationCode string `json:"locationCode"`
|
||||
Name string `json:"name"`
|
||||
Flag string `json:"flag"`
|
||||
Meta []interface{} `json:"_meta"`
|
||||
CKey string `json:"_ckey"`
|
||||
// Main information about locations
|
||||
type ItemLocation struct {
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// Location code
|
||||
LocationCode string `json:"locationCode"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Flag
|
||||
Flag string `json:"flag"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
}
|
||||
|
||||
type LocationsList []Location
|
||||
// List of locations
|
||||
type ListLocations []ItemLocation
|
||||
|
||||
Reference in New Issue
Block a user