github.com/schmorrison/Zoho@v1.1.4/bookings/workspace.go (about) 1 package bookings 2 3 import ( 4 "fmt" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 func (c *API) FetchWorkspaces(workspacesID zoho.Parameter) (data WorkspaceResponse, err error) { 10 endpoint := zoho.Endpoint{ 11 Name: FetchWorkspacesModule, 12 URL: fmt.Sprintf( 13 "https://www.zohoapis.%s/bookings/v1/json/%s", 14 c.ZohoTLD, 15 FetchWorkspacesModule, 16 ), 17 Method: zoho.HTTPGet, 18 ResponseData: &WorkspaceResponse{}, 19 URLParameters: map[string]zoho.Parameter{ 20 "filter_by": "", 21 }, 22 } 23 24 if workspacesID != "" { 25 endpoint.URLParameters["workspace_id"] = workspacesID 26 } 27 28 err = c.Zoho.HTTPRequest(&endpoint) 29 if err != nil { 30 return WorkspaceResponse{}, fmt.Errorf("Failed to retrieve workspaces: %s", err) 31 } 32 33 if v, ok := endpoint.ResponseData.(*WorkspaceResponse); ok { 34 return *v, nil 35 } 36 return WorkspaceResponse{}, fmt.Errorf("Data retrieved was not 'Workspace Response'") 37 } 38 39 type WorkspaceResponse struct { 40 Response struct { 41 ReturnValue struct { 42 Data []struct { 43 Name string `json:"name"` 44 Id string `json:"id"` 45 } `json:"data"` 46 } `json:"returnvalue"` 47 Status string `json:"status"` 48 } `json:"response"` 49 }