github.com/schmorrison/Zoho@v1.1.4/invoice/stop_recurring_invoice.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/#Recurring_Invoices_Stop_a_Recurring_Invoice 10 //func (c *API) StopRecurringInvoice(request interface{}, OrganizationID string, params map[string]zoho.Parameter) (data StopRecurringInvoiceResponse, err error) { 11 func (c *API) StopRecurringInvoice( 12 recurringInvoiceId string, 13 ) (data StopRecurringInvoiceResponse, err error) { 14 15 endpoint := zoho.Endpoint{ 16 Name: RecurringInvoicesModule, 17 URL: fmt.Sprintf( 18 "https://invoice.zoho.%s/api/v3/%s/status/stop", c.ZohoTLD, recurringInvoiceId, 19 ), 20 Method: zoho.HTTPPost, 21 ResponseData: &StopRecurringInvoiceResponse{}, 22 URLParameters: map[string]zoho.Parameter{ 23 "filter_by": "", 24 }, 25 BodyFormat: zoho.JSON_STRING, 26 Headers: map[string]string{ 27 InvoiceAPIEndpointHeader: c.OrganizationID, 28 }, 29 } 30 31 /*for k, v := range params { 32 endpoint.URLParameters[k] = v 33 }*/ 34 35 err = c.Zoho.HTTPRequest(&endpoint) 36 if err != nil { 37 return StopRecurringInvoiceResponse{}, fmt.Errorf( 38 "Failed to stop recurring invoice: %s", 39 err, 40 ) 41 } 42 43 if v, ok := endpoint.ResponseData.(*StopRecurringInvoiceResponse); ok { 44 // Check if the request succeeded 45 if v.Code != 0 { 46 return *v, fmt.Errorf("Failed to stop recurring invoice: %s", v.Message) 47 } 48 return *v, nil 49 } 50 return StopRecurringInvoiceResponse{}, fmt.Errorf( 51 "Data retrieved was not 'StopRecurringInvoiceResponse'", 52 ) 53 } 54 55 type StopRecurringInvoiceResponse struct { 56 Code int `json:"code"` 57 Message string `json:"message"` 58 }