github.com/schmorrison/Zoho@v1.1.4/invoice/get_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_Get_a_Recurring_Invoice 10 //func (c *API) GetRecurringInvoice(request interface{}, OrganizationID string, params map[string]zoho.Parameter) (data ListContactsResponse, err error) { 11 func (c *API) GetRecurringInvoice( 12 recurringInvoiceId string, 13 ) (data RecurringInvoiceResponse, err error) { 14 15 endpoint := zoho.Endpoint{ 16 Name: RecurringInvoicesModule, 17 URL: fmt.Sprintf( 18 "https://invoice.zoho.%s/api/v3/%s/%s", 19 c.ZohoTLD, 20 RecurringInvoicesModule, 21 recurringInvoiceId, 22 ), 23 Method: zoho.HTTPGet, 24 ResponseData: &RecurringInvoiceResponse{}, 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 39 err = c.Zoho.HTTPRequest(&endpoint) 40 if err != nil { 41 return RecurringInvoiceResponse{}, fmt.Errorf( 42 "Failed to retrieve recurring invoice: %s", 43 err, 44 ) 45 } 46 47 if v, ok := endpoint.ResponseData.(*RecurringInvoiceResponse); ok { 48 // Check if the request succeeded 49 if v.Code != 0 { 50 return *v, fmt.Errorf("Failed to retrieve recurring invoice: %s", v.Message) 51 } 52 return *v, nil 53 } 54 return RecurringInvoiceResponse{}, fmt.Errorf( 55 "Data retrieved was not 'RecurringInvoiceResponse'", 56 ) 57 } 58 59 type RecurringInvoiceResponse struct { 60 Code int64 `json:"code"` 61 Message string `json:"message"` 62 RecurringInvoice struct { 63 RecurringInvoiceId string `json:"recurring_invoice_id"` 64 RecurrenceName string `json:"recurrence_name"` 65 ReferenceNumber string `json:"reference_number"` 66 CustomerName string `json:"customer_name"` 67 CustomerId string `json:"customer_id"` 68 IsPreGst bool `json:"is_pre_gst"` 69 GstNo string `json:"gst_no"` 70 GstTreatment string `json:"gst_treatment"` 71 PlaceOfSupply string `json:"place_of_supply"` 72 RecurrenceFrequency string `json:"recurrence_frequency"` 73 CompanyName string `json:"company_name"` 74 CustomerEmail string `json:"customer_email"` 75 CustomerMobilePhone string `json:"customer_mobile_phone"` 76 CustomerPhone string `json:"customer_phone"` 77 PhotoUrl string `json:"photo_url"` 78 CurrencyId string `json:"currency_id"` 79 CurrencyCode string `json:"currency_code"` 80 StartDate string `json:"start_date"` 81 EndDate string `json:"end_date"` 82 LastSentDate string `json:"last_sent_date"` 83 NextInvoiceDate string `json:"next_invoice_date"` 84 LineItems []struct { 85 LineItemId string `json:"line_item_id"` 86 ItemId string `json:"item_id"` 87 ItemOrder float64 `json:"item_order"` 88 DiscountAmount float64 `json:"discount_amount"` 89 Quantity int64 `json:"quantity"` 90 Rate float64 `json:"rate"` 91 Discount float64 `json:"discount"` 92 Name string `json:"name"` 93 ItemTotal float64 `json:"item_total"` 94 Sku string `json:"sku"` 95 ProductType string `json:"product_type"` 96 ProjectId string `json:"project_id"` 97 ProjectName string `json:"project_name"` 98 ItemCustomFields []struct { 99 CustomfieldID string `json:"customfield_id,omitempty"` 100 Label string `json:"label"` 101 Value string `json:"value,omitempty"` 102 } `json:"item_custom_fields"` 103 } `json:"line_items"` 104 PaidInvoicesTotal float64 `json:"paid_invoices_total"` 105 UnpaidInvoicesBalance float64 `json:"unpaid_invoices_balance"` 106 BillingAddress ContactAddress `json:"billing_address"` 107 ShippingAddress ContactAddress `json:"shipping_address"` 108 /*CustomFields []struct { 109 CustomfieldId int64 `json:"customfield_id"` 110 DataType string `json:"data_type"` 111 Index int64 `json:"index"` 112 IsActive bool `json:"is_active"` 113 Label string `json:"label"` 114 ShowInAllPdf bool `json:"show_in_all_pdf"` 115 ShowOnPdf bool `json:"show_on_pdf"` 116 Value string `json:"value"` 117 } `json:"custom_fields"`*/ 118 PaymentOptions PaymentOptions `json:"payment_options"` 119 } `json:"recurring_invoice"` 120 }