github.com/schmorrison/Zoho@v1.1.4/invoice/update_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_Update_Recurring_Invoice 10 //func (c *API) UpdateRecurringInvoice(request interface{}, OrganizationID string, params map[string]zoho.Parameter) (data UpdateRecurringInvoiceRequest, err error) { 11 func (c *API) UpdateRecurringInvoice( 12 request interface{}, 13 recurringInvoiceId string, 14 ) (data UpdateRecurringInvoiceResponse, err error) { 15 16 endpoint := zoho.Endpoint{ 17 Name: ContactsModule, 18 URL: fmt.Sprintf( 19 "https://invoice.zoho.%s/api/v3/%s/%s", 20 c.ZohoTLD, 21 RecurringInvoicesModule, 22 recurringInvoiceId, 23 ), 24 Method: zoho.HTTPPut, 25 ResponseData: &UpdateRecurringInvoiceResponse{}, 26 URLParameters: map[string]zoho.Parameter{ 27 "filter_by": "", 28 }, 29 RequestBody: &request, 30 BodyFormat: zoho.JSON_STRING, 31 Headers: map[string]string{ 32 InvoiceAPIEndpointHeader: c.OrganizationID, 33 }, 34 } 35 36 /*for k, v := range params { 37 endpoint.URLParameters[k] = v 38 }*/ 39 40 err = c.Zoho.HTTPRequest(&endpoint) 41 if err != nil { 42 return UpdateRecurringInvoiceResponse{}, fmt.Errorf( 43 "Failed to update recurring invoice: %s", 44 err, 45 ) 46 } 47 48 if v, ok := endpoint.ResponseData.(*UpdateRecurringInvoiceResponse); ok { 49 // Check if the request succeeded 50 if v.Code != 0 { 51 return *v, fmt.Errorf("Failed to update recurring invoice: %s", v.Message) 52 } 53 return *v, nil 54 } 55 return UpdateRecurringInvoiceResponse{}, fmt.Errorf( 56 "Data retrieved was not 'UpdateRecurringInvoiceResponse'", 57 ) 58 } 59 60 type UpdateRecurringInvoiceRequest struct { 61 RecurrenceName string `json:"recurrence_name"` 62 ReferenceNumber string `json:"reference_number,omitempty"` 63 CustomerId string `json:"customer_id"` 64 TemplateId string `json:"template_id,omitempty"` 65 SalespersonId string `json:"salesperson_id,omitempty"` 66 IsInclusiveTax bool `json:"is_inclusive_tax,omitempty"` 67 ContactPersons []string `json:"contact_persons,omitempty"` 68 StartDate string `json:"start_date,omitempty"` 69 EndDate string `json:"end_date,omitempty"` 70 PlaceOfSupply string `json:"place_of_supply,omitempty"` 71 GstTreatment string `json:"gst_treatment,omitempty"` 72 GstNo string `json:"gst_no,omitempty"` 73 RecurrenceFrequency string `json:"recurrence_frequency"` 74 RepeatEvery int64 `json:"repeat_every,omitempty"` 75 PaymentTerms int64 `json:"payment_terms,omitempty"` 76 PaymentTermsLabel string `json:"payment_terms_label,omitempty"` 77 CustomFields []CustomFieldRequest `json:"custom_fields,omitempty"` 78 LineItems []InvoiceLineItem `json:"line_items,omitempty"` 79 TaxId string `json:"tax_id,omitempty"` 80 Email string `json:"email,omitempty"` 81 PaymentOptions PaymentOptions `json:"payment_options,omitempty"` 82 TaxAuthorityId string `json:"tax_authority_id,omitempty"` 83 TaxExemptionId string `json:"tax_exemption_id,omitempty"` 84 } 85 86 type UpdateRecurringInvoiceResponse struct { 87 Code int64 `json:"code"` 88 Message string `json:"message"` 89 RecurringInvoice struct { 90 RecurringInvoiceId string `json:"recurring_invoice_id"` 91 RecurrenceName string `json:"recurrence_name"` 92 ReferenceNumber string `json:"reference_number"` 93 IsPreGst bool `json:"is_pre_gst"` 94 GstNo string `json:"gst_no"` 95 GstTreatment string `json:"gst_treatment"` 96 PlaceOfSupply string `json:"place_of_supply"` 97 CustomerName string `json:"customer_name"` 98 CustomerId string `json:"customer_id"` 99 CurrencyId string `json:"currency_id"` 100 CurrencyCode string `json:"currency_code"` 101 StartDate string `json:"start_date"` 102 EndDate string `json:"end_date"` 103 LastSentDate string `json:"last_sent_date"` 104 NextInvoiceDate string `json:"next_invoice_date"` 105 LineItems []struct { 106 LineItemId string `json:"line_item_id"` 107 Quantity int64 `json:"quantity"` 108 Name string `json:"name"` 109 ItemTotal float64 `json:"item_total"` 110 Sku string `json:"sku"` 111 ProductType string `json:"product_type"` 112 ProjectId string `json:"project_id"` 113 ProjectName string `json:"project_name"` 114 } `json:"line_items"` 115 BillingAddress ContactAddress `json:"billing_address"` 116 ShippingAddress ContactAddress `json:"shipping_address"` 117 CustomFields []struct { 118 CustomfieldId string `json:"customfield_id"` 119 DataType string `json:"data_type"` 120 Index int64 `json:"index"` 121 IsActive bool `json:"is_active"` 122 Label string `json:"label"` 123 ShowInAllPdf bool `json:"show_in_all_pdf"` 124 ShowOnPdf bool `json:"show_on_pdf"` 125 Value string `json:"value"` 126 } `json:"custom_fields"` 127 PaymentOptions PaymentOptions `json:"payment_options"` 128 } 129 }