github.com/schmorrison/Zoho@v1.1.4/invoice/list_customer_payments.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_List_Recurring_Invoice 10 //func (c *API) ListCustomerPayments(request interface{}, OrganizationID string, params map[string]zoho.Parameter) (data ListCustomerPaymentsResponse, err error) { 11 func (c *API) ListCustomerPayments() (data ListCustomerPaymentsResponse, err error) { 12 13 endpoint := zoho.Endpoint{ 14 Name: CustomerPaymentsModule, 15 URL: fmt.Sprintf( 16 "https://invoice.zoho.%s/api/v3/%s", 17 c.ZohoTLD, 18 CustomerPaymentsModule, 19 ), 20 Method: zoho.HTTPGet, 21 ResponseData: &ListCustomerPaymentsResponse{}, 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 36 err = c.Zoho.HTTPRequest(&endpoint) 37 if err != nil { 38 return ListCustomerPaymentsResponse{}, fmt.Errorf( 39 "Failed to retrieve expense reports: %s", 40 err, 41 ) 42 } 43 44 if v, ok := endpoint.ResponseData.(*ListCustomerPaymentsResponse); ok { 45 // Check if the request succeeded 46 if v.Code != 0 { 47 return *v, fmt.Errorf("Failed to list customer payments: %s", v.Message) 48 } 49 return *v, nil 50 } 51 return ListCustomerPaymentsResponse{}, fmt.Errorf( 52 "Data retrieved was not 'ListCustomerPaymentsResponse'", 53 ) 54 } 55 56 type ListCustomerPaymentsResponse struct { 57 Code int `json:"code"` 58 Message string `json:"message"` 59 CustomerPayments []struct { 60 PaymentId string `json:"payment_id"` 61 PaymentNumber string `json:"payment_number"` 62 InvoiceNumber string `json:"invoice_number"` 63 Date string `json:"date"` 64 PaymentMode string `json:"payment_mode"` 65 Amount float64 `json:"amount"` 66 BcyAmount float64 `json:"bcy_amount"` 67 } `json:"customerpayments"` 68 }