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