github.com/schmorrison/Zoho@v1.1.4/invoice/delete_contact_person.go (about) 1 package invoice 2 3 import ( 4 "fmt" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 //https://www.zoho.com/invoice/api/v3/#Contact_Persons_Delete_a_contact_person 10 //func (c *API) DeleteContactPerson(request interface{}, OrganizationID string, params map[string]zoho.Parameter) (data DeleteContactPersonResponse, err error) { 11 func (c *API) DeleteContactPerson( 12 contactPersonID string, 13 ) (data DeleteContactPersonResponse, err error) { 14 15 endpoint := zoho.Endpoint{ 16 Name: ContactsModule, 17 URL: fmt.Sprintf( 18 "https://invoice.zoho.%s/api/v3/%s/%s/%s", c.ZohoTLD, 19 ContactsModule, 20 ContactsPersonSubModule, 21 contactPersonID, 22 ), 23 Method: zoho.HTTPDelete, 24 ResponseData: &DeleteContactPersonResponse{}, 25 URLParameters: map[string]zoho.Parameter{ 26 "filter_by": "", 27 }, 28 BodyFormat: zoho.JSON_STRING, 29 Headers: map[string]string{ 30 InvoiceAPIEndpointHeader: c.OrganizationID, 31 }, 32 } 33 34 /*for k, v := range params { 35 endpoint.URLParameters[k] = v 36 }*/ 37 38 err = c.Zoho.HTTPRequest(&endpoint) 39 if err != nil { 40 return DeleteContactPersonResponse{}, fmt.Errorf("Failed to delete contact person: %s", err) 41 } 42 43 if v, ok := endpoint.ResponseData.(*DeleteContactPersonResponse); ok { 44 // Check if the request succeeded 45 if v.Code != 0 { 46 return *v, fmt.Errorf("Failed to delete contact person: %s", v.Message) 47 } 48 return *v, nil 49 } 50 return DeleteContactPersonResponse{}, fmt.Errorf( 51 "Data retrieved was not 'DeleteContactPersonResponse'", 52 ) 53 } 54 55 type DeleteContactPersonResponse struct { 56 Code int `json:"code"` 57 Message string `json:"message"` 58 }