From 005f4d693fc2519d051a4d3c183fc0ee780a69ac Mon Sep 17 00:00:00 2001 From: Nathan R Date: Mon, 30 Dec 2019 12:01:11 +0000 Subject: [PATCH 01/18] Added decrypt and product api methods --- api.go | 36 ++++++++++++++++++++++++++++++++++++ client.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/api.go b/api.go index 86b6424..2c48a6d 100644 --- a/api.go +++ b/api.go @@ -199,6 +199,42 @@ func (a *API) ValidateLogin(v *ValidateLogin) (r *ValidateLoginResult, err error return } +func (a *API) GetClientsProducts(v *GetClientsProducts) (r *GetClientsProductsResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("GetClientsProducts", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &GetClientsProductsResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + return +} + +func (a *API) DecryptPassword(v *DecryptPassword) (r *DecryptPasswordResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("DecryptPassword", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &DecryptPasswordResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + return +} + + + func (a *API) UpdateClientProduct(p *ClientProduct) (r *UpdateClientProductResult, err error) { err = p.Error() diff --git a/client.go b/client.go index 8686429..fe574e0 100644 --- a/client.go +++ b/client.go @@ -45,6 +45,32 @@ type ValidateLogin struct { Password2 string `json:"password2"` } + +type DecryptPassword struct{ + Password2 string `json:"password2"` +} + + + + +type GetClientsProducts struct { + ServiceId int `json:"serviceid"` +} + + +type GetClientsProductsResult struct { + Result string `json:"result"` + ClientID int64 `json:"clientid"` + ServiceID string `json:"serviceid"` + Pid int64 `json:"pid"` + Domain string `json:"domain"` + TotalResults int64 `json:"totalresults"` + StartNumber int64 `json:"startnumber"` + NumReturned int64 `json:"numreturned"` +} + + + // AddClientResult is the WHMCS response when adding a client. type AddClientResult struct { ClientID int64 `json:"clientid"` @@ -60,6 +86,12 @@ type ValidateLoginResult struct { Message string `json:"message"` } +type DecryptPasswordResult struct { + Result string `json:"result"` + Password string `json:"password"` +} + + // ClientDetailsReq is the struct of parameters available to retrieve client details. type ClientDetailsReq struct { ClientID string `json:"clientid,omitempty"` @@ -74,3 +106,12 @@ func (c *NewClient) Error() error { func (v *ValidateLogin) Error() error { return nil } + +func (v *GetClientsProducts) Error() error { + return nil +} + +func (v *DecryptPassword) Error() error { + return nil +} + From 944e916db6d9a278f914e3b9946f0b3c0238c6c4 Mon Sep 17 00:00:00 2001 From: Nathan R Date: Mon, 30 Dec 2019 12:49:47 +0000 Subject: [PATCH 02/18] Added ResetPassword api method --- api.go | 82 +++++++++++++++++++++++++++++++++---------------------- client.go | 11 ++++++++ 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/api.go b/api.go index 2c48a6d..baf9d00 100644 --- a/api.go +++ b/api.go @@ -187,54 +187,52 @@ func (a *API) ValidateLogin(v *ValidateLogin) (r *ValidateLoginResult, err error body, err := a.Do("validatelogin", &v) if err != nil { - err = fmt.Errorf("gowhmcs validatelogin error: %v", err) + err = fmt.Errorf("%v", err) return } r = &ValidateLoginResult{} if err = json.Unmarshal(body, &r); err != nil { - err = fmt.Errorf("gowhmcs validatelogin error: %v", err) + err = fmt.Errorf("%v", err) } return } func (a *API) GetClientsProducts(v *GetClientsProducts) (r *GetClientsProductsResult, err error) { - err = v.Error() - if err != nil { - return - } - body, err := a.Do("GetClientsProducts", &v) - if err != nil { - err = fmt.Errorf("%v", err) - return - } - r = &GetClientsProductsResult{} - if err = json.Unmarshal(body, &r); err != nil { - err = fmt.Errorf("%v", err) - } - return + err = v.Error() + if err != nil { + return + } + body, err := a.Do("GetClientsProducts", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &GetClientsProductsResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + return } func (a *API) DecryptPassword(v *DecryptPassword) (r *DecryptPasswordResult, err error) { - err = v.Error() - if err != nil { - return - } - body, err := a.Do("DecryptPassword", &v) - if err != nil { - err = fmt.Errorf("%v", err) - return - } - r = &DecryptPasswordResult{} - if err = json.Unmarshal(body, &r); err != nil { - err = fmt.Errorf("%v", err) - } - return + err = v.Error() + if err != nil { + return + } + body, err := a.Do("DecryptPassword", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &DecryptPasswordResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + return } - - func (a *API) UpdateClientProduct(p *ClientProduct) (r *UpdateClientProductResult, err error) { err = p.Error() @@ -256,3 +254,23 @@ func (a *API) UpdateClientProduct(p *ClientProduct) (r *UpdateClientProductResul return } + +// Reset account password + +func (a *API) ResetPassword(v *ResetPassword) (r *ResetPasswordResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("ResetPassword", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &ResetPasswordResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + + return +} diff --git a/client.go b/client.go index fe574e0..be74471 100644 --- a/client.go +++ b/client.go @@ -51,6 +51,9 @@ type DecryptPassword struct{ } +type ResetPassword struct{ + Email string `json:"email"` +} type GetClientsProducts struct { @@ -91,6 +94,9 @@ type DecryptPasswordResult struct { Password string `json:"password"` } +type ResetPasswordResult struct{ + Result string `json:"result"` +} // ClientDetailsReq is the struct of parameters available to retrieve client details. type ClientDetailsReq struct { @@ -107,6 +113,11 @@ func (v *ValidateLogin) Error() error { return nil } +func (v *ResetPassword) Error() error { + return nil +} + + func (v *GetClientsProducts) Error() error { return nil } From 579078389c757d055beb44c34d341221d89f7ca5 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Mon, 9 Mar 2020 12:23:27 +0000 Subject: [PATCH 03/18] Sevice struct and terminate service implementation --- api.go | 20 ++++++++++++++++++- client.go | 60 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 29 deletions(-) diff --git a/api.go b/api.go index baf9d00..714a9b4 100644 --- a/api.go +++ b/api.go @@ -256,7 +256,6 @@ func (a *API) UpdateClientProduct(p *ClientProduct) (r *UpdateClientProductResul } // Reset account password - func (a *API) ResetPassword(v *ResetPassword) (r *ResetPasswordResult, err error) { err = v.Error() if err != nil { @@ -274,3 +273,22 @@ func (a *API) ResetPassword(v *ResetPassword) (r *ResetPasswordResult, err error return } + +//Terminate a service +func (a *API) TerminateService(v *TerminateService) (r *TerminateServiceResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("ModuleTerminate", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &TerminateServiceResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + + return +} diff --git a/client.go b/client.go index be74471..7ff4472 100644 --- a/client.go +++ b/client.go @@ -45,34 +45,32 @@ type ValidateLogin struct { Password2 string `json:"password2"` } - -type DecryptPassword struct{ - Password2 string `json:"password2"` +type DecryptPassword struct { + Password2 string `json:"password2"` } - -type ResetPassword struct{ - Email string `json:"email"` +type ResetPassword struct { + Email string `json:"email"` } - -type GetClientsProducts struct { - ServiceId int `json:"serviceid"` +type TerminateService struct { + Id string `json:"id"` } - -type GetClientsProductsResult struct { - Result string `json:"result"` - ClientID int64 `json:"clientid"` - ServiceID string `json:"serviceid"` - Pid int64 `json:"pid"` - Domain string `json:"domain"` - TotalResults int64 `json:"totalresults"` - StartNumber int64 `json:"startnumber"` - NumReturned int64 `json:"numreturned"` +type GetClientsProducts struct { + ServiceId int `json:"serviceid"` } - +type GetClientsProductsResult struct { + Result string `json:"result"` + ClientID int64 `json:"clientid"` + ServiceID string `json:"serviceid"` + Pid int64 `json:"pid"` + Domain string `json:"domain"` + TotalResults int64 `json:"totalresults"` + StartNumber int64 `json:"startnumber"` + NumReturned int64 `json:"numreturned"` +} // AddClientResult is the WHMCS response when adding a client. type AddClientResult struct { @@ -90,12 +88,16 @@ type ValidateLoginResult struct { } type DecryptPasswordResult struct { - Result string `json:"result"` - Password string `json:"password"` + Result string `json:"result"` + Password string `json:"password"` } -type ResetPasswordResult struct{ - Result string `json:"result"` +type ResetPasswordResult struct { + Result string `json:"result"` +} + +type TerminateServiceResult struct { + Result string `json:"result"` } // ClientDetailsReq is the struct of parameters available to retrieve client details. @@ -114,15 +116,17 @@ func (v *ValidateLogin) Error() error { } func (v *ResetPassword) Error() error { - return nil + return nil } - func (v *GetClientsProducts) Error() error { - return nil + return nil } func (v *DecryptPassword) Error() error { - return nil + return nil } +func (v *TerminateService) Error() error { + return nil +} From 12513e37306b47ff833ff2870c225a7b5be73540 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Mon, 9 Mar 2020 12:28:22 +0000 Subject: [PATCH 04/18] Fixed service struct --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 7ff4472..34992dd 100644 --- a/client.go +++ b/client.go @@ -54,7 +54,7 @@ type ResetPassword struct { } type TerminateService struct { - Id string `json:"id"` + Id int64 `json:"id"` } type GetClientsProducts struct { From b3c8e4f31a354d9cb3a573dc5bcd91150bc27f5d Mon Sep 17 00:00:00 2001 From: WeVPN Date: Tue, 10 Mar 2020 12:29:46 +0000 Subject: [PATCH 05/18] FIxed clientupdate struct --- client_update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_update.go b/client_update.go index 245738e..ce1fba3 100644 --- a/client_update.go +++ b/client_update.go @@ -10,7 +10,7 @@ var ( ) type ExistingClient struct { - ClientID string `"json:clientid,omitempty"` + ClientID int64 `"json:clientid,omitempty"` ClientEmail string `json:"clientemail,omitempty"` Firstname string `json:"firstname,omitempty"` From 81a16883434fc2b9d047664724f138cefe5c76e4 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Tue, 10 Mar 2020 13:03:58 +0000 Subject: [PATCH 06/18] Fixed update client variable types --- api.go | 6 +++--- client_update.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api.go b/api.go index 714a9b4..79412f6 100644 --- a/api.go +++ b/api.go @@ -71,19 +71,19 @@ func (a *API) UpdateExistingClient(c *ExistingClient) (r *UpdateClientResult, er err = c.Error() if err != nil { - err = fmt.Errorf("gowhmcs updateexistingclient error: %v", err) + err = fmt.Errorf("Error: %v", err) return } body, err := a.Do("updateclient", &c) if err != nil { - err = fmt.Errorf("gowhmcs updateexistingclient error: %v", err) + err = fmt.Errorf("Error: %v", err) return } r = &UpdateClientResult{} if err = json.Unmarshal(body, r); err != nil { - err = fmt.Errorf("gowhmcs updateexistingclient error: %v", err) + err = fmt.Errorf("Error: %v", err) } return diff --git a/client_update.go b/client_update.go index ce1fba3..66bc4ef 100644 --- a/client_update.go +++ b/client_update.go @@ -52,11 +52,11 @@ type ExistingClient struct { // UpdateClientResult is the WHMCS response when updating a client. type UpdateClientResult struct { Result string `json:"result"` - ClientID int64 `json:"clientid,string"` + ClientID int64 `json:"clientid"` } func (c *ExistingClient) Error() error { - if c.ClientID == "" && c.ClientEmail == "" { + if c.ClientID == 0 && c.ClientEmail == "" { return ErrNoClientDetails } return nil @@ -68,6 +68,6 @@ func (c *ExistingClient) ByEmail(email string) { } // ByID sets the client's ID with the given id string -func (c *ExistingClient) ByID(id string) { +func (c *ExistingClient) ByID(id int64) { c.ClientID = id } From 948fae89f99e48afdaafe0dee06e71fad29c9dfc Mon Sep 17 00:00:00 2001 From: WeVPN Date: Tue, 10 Mar 2020 20:34:10 +0000 Subject: [PATCH 07/18] AddInvoicePayment api method implementation --- api.go | 25 +++++++++++++++++++++++++ invoice.go | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/api.go b/api.go index 79412f6..5110f7f 100644 --- a/api.go +++ b/api.go @@ -24,6 +24,31 @@ func (a *API) AddTransaction(t *Transaction) error { return nil } + +// AddInvoicePayment +func (a *API) AddInvoicePayment(i *AddInvoicePaymentRequest) (r *AddInvoicePaymentResponse, err error) { + + err = i.Error() + if err != nil { + return + } + + body, err := a.Do("AddInvoicePayment", i) + if err != nil { + err = fmt.Errorf("gowhmcs updateinvoice error: %v", err) + return + } + + r = &UpdateInvoiceResponse{} + if err = json.Unmarshal(body, r); err != nil { + err = fmt.Errorf("gowhmcs updateinvoice error: %v", err) + } + + return + +} + + // UpdateInvoice updates the invoice with the given parameters of `r`. func (a *API) UpdateInvoice(i *UpdateInvoiceRequest) (r *UpdateInvoiceResponse, err error) { diff --git a/invoice.go b/invoice.go index f78062f..9417418 100644 --- a/invoice.go +++ b/invoice.go @@ -51,3 +51,20 @@ type UpdateInvoiceRequest struct { func (r *UpdateInvoiceRequest) Error() error { return nil } + +// AddInvoicePaymentRequest +type AddInvoicePaymentRequest struct { + InvoiceID int64 `json:"invoiceid` + TransID string `json:"transid` + Gateway string `json:"gateway` +} + +type AddInvoicePaymentResponse struct { + Result string `json:"result"` +} + + +func (r *UpdateInvoiceRequest) Error() error { + return nil +} + From 5ddc53eff92eca0ae5078533c5e5a36aa44d487c Mon Sep 17 00:00:00 2001 From: WeVPN Date: Tue, 10 Mar 2020 20:40:01 +0000 Subject: [PATCH 08/18] AddInvoicePayment api method implementation --- api.go | 2 +- invoice.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 5110f7f..4b1e8c1 100644 --- a/api.go +++ b/api.go @@ -39,7 +39,7 @@ func (a *API) AddInvoicePayment(i *AddInvoicePaymentRequest) (r *AddInvoicePayme return } - r = &UpdateInvoiceResponse{} + r = &AddInvoicePaymentResponse{} if err = json.Unmarshal(body, r); err != nil { err = fmt.Errorf("gowhmcs updateinvoice error: %v", err) } diff --git a/invoice.go b/invoice.go index 9417418..cd98387 100644 --- a/invoice.go +++ b/invoice.go @@ -64,7 +64,7 @@ type AddInvoicePaymentResponse struct { } -func (r *UpdateInvoiceRequest) Error() error { +func (r *AddInvoicePaymentRequest) Error() error { return nil } From a719c4e3a533de561509c3183ea29b3069e4e394 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Tue, 10 Mar 2020 21:50:48 +0000 Subject: [PATCH 09/18] Invoice request struct fix --- invoice.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/invoice.go b/invoice.go index cd98387..573d9f4 100644 --- a/invoice.go +++ b/invoice.go @@ -54,9 +54,9 @@ func (r *UpdateInvoiceRequest) Error() error { // AddInvoicePaymentRequest type AddInvoicePaymentRequest struct { - InvoiceID int64 `json:"invoiceid` - TransID string `json:"transid` - Gateway string `json:"gateway` + InvoiceID int64 `json:"invoiceid,string"` + TransID string `json:"transid"` + Gateway string `json:"gateway"` } type AddInvoicePaymentResponse struct { From 00800c667849764492bcc7f906ebe16ca960ced6 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Wed, 11 Mar 2020 20:03:47 +0000 Subject: [PATCH 10/18] Added service creation/termination --- api.go | 30 +++++++++++++++++++++++++----- client.go | 14 ++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/api.go b/api.go index 4b1e8c1..3d4e66f 100644 --- a/api.go +++ b/api.go @@ -27,21 +27,21 @@ func (a *API) AddTransaction(t *Transaction) error { // AddInvoicePayment func (a *API) AddInvoicePayment(i *AddInvoicePaymentRequest) (r *AddInvoicePaymentResponse, err error) { - + err = i.Error() if err != nil { return } - - body, err := a.Do("AddInvoicePayment", i) + + body, err := a.Do("addinvoicepayment", i) if err != nil { - err = fmt.Errorf("gowhmcs updateinvoice error: %v", err) + err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) return } r = &AddInvoicePaymentResponse{} if err = json.Unmarshal(body, r); err != nil { - err = fmt.Errorf("gowhmcs updateinvoice error: %v", err) + err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) } return @@ -317,3 +317,23 @@ func (a *API) TerminateService(v *TerminateService) (r *TerminateServiceResult, return } + +//Terminate a service +func (a *API) CreateService(v *CreateService) (r *CreateServiceResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("ModuleCreate", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &CreateServiceResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + + return +} + diff --git a/client.go b/client.go index 34992dd..d57ace8 100644 --- a/client.go +++ b/client.go @@ -57,6 +57,11 @@ type TerminateService struct { Id int64 `json:"id"` } +type CreateService struct { + Id int64 `json:"serviceid"` +} + + type GetClientsProducts struct { ServiceId int `json:"serviceid"` } @@ -100,6 +105,11 @@ type TerminateServiceResult struct { Result string `json:"result"` } +type CreateServiceResult struct { + Result string `json:"result"` +} + + // ClientDetailsReq is the struct of parameters available to retrieve client details. type ClientDetailsReq struct { ClientID string `json:"clientid,omitempty"` @@ -130,3 +140,7 @@ func (v *DecryptPassword) Error() error { func (v *TerminateService) Error() error { return nil } +func (v *CreateService) Error() error { + return nil +} + From fd41edb862e38a037a65e175abf560cdb358213b Mon Sep 17 00:00:00 2001 From: WeVPN Date: Thu, 12 Mar 2020 12:37:23 +0000 Subject: [PATCH 11/18] ModuleTerminate parameter fix --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index d57ace8..b12f6c0 100644 --- a/client.go +++ b/client.go @@ -54,7 +54,7 @@ type ResetPassword struct { } type TerminateService struct { - Id int64 `json:"id"` + Id int64 `json:"serviceid"` } type CreateService struct { From b474bcc9943dbe2a89221f661e6ebd6106d863fb Mon Sep 17 00:00:00 2001 From: WeVPN Date: Fri, 13 Mar 2020 17:22:47 +0000 Subject: [PATCH 12/18] Added OpenTicket --- api.go | 88 ++++++++++++++++++++++++++++-------------------- client.go | 22 +++++++++--- client_update.go | 2 +- invoice.go | 6 ++-- 4 files changed, 72 insertions(+), 46 deletions(-) diff --git a/api.go b/api.go index 3d4e66f..037017e 100644 --- a/api.go +++ b/api.go @@ -24,30 +24,28 @@ func (a *API) AddTransaction(t *Transaction) error { return nil } - // AddInvoicePayment func (a *API) AddInvoicePayment(i *AddInvoicePaymentRequest) (r *AddInvoicePaymentResponse, err error) { - - err = i.Error() - if err != nil { - return - } - - body, err := a.Do("addinvoicepayment", i) - if err != nil { - err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) - return - } - - r = &AddInvoicePaymentResponse{} - if err = json.Unmarshal(body, r); err != nil { - err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) - } - - return -} + err = i.Error() + if err != nil { + return + } + + body, err := a.Do("addinvoicepayment", i) + if err != nil { + err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) + return + } + + r = &AddInvoicePaymentResponse{} + if err = json.Unmarshal(body, r); err != nil { + err = fmt.Errorf("gowhmcs addinvoicepayment error: %v", err) + } + + return +} // UpdateInvoice updates the invoice with the given parameters of `r`. func (a *API) UpdateInvoice(i *UpdateInvoiceRequest) (r *UpdateInvoiceResponse, err error) { @@ -91,6 +89,25 @@ func (a *API) CreateInvoice(i *CreateInvoiceRequest) (r *CreateInvoiceResponse, } +// Open ticket +func (a *API) OpenTicket(t *OpenTicketRequest) (r *OpenTicketResponse, err error) { + + err = t.Error() + if err != nil { + return + } + + body, err := a.Do("openticket", t) + if err != nil { + return + } + + r = &OpenTicketResponse{} + err = json.Unmarshal(body, r) + return + +} + // UpdateExistingClient updates an existing client. func (a *API) UpdateExistingClient(c *ExistingClient) (r *UpdateClientResult, err error) { @@ -320,20 +337,19 @@ func (a *API) TerminateService(v *TerminateService) (r *TerminateServiceResult, //Terminate a service func (a *API) CreateService(v *CreateService) (r *CreateServiceResult, err error) { - err = v.Error() - if err != nil { - return - } - body, err := a.Do("ModuleCreate", &v) - if err != nil { - err = fmt.Errorf("%v", err) - return - } - r = &CreateServiceResult{} - if err = json.Unmarshal(body, &r); err != nil { - err = fmt.Errorf("%v", err) - } - - return -} + err = v.Error() + if err != nil { + return + } + body, err := a.Do("ModuleCreate", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &CreateServiceResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + return +} diff --git a/client.go b/client.go index b12f6c0..e8670f7 100644 --- a/client.go +++ b/client.go @@ -54,13 +54,19 @@ type ResetPassword struct { } type TerminateService struct { - Id int64 `json:"serviceid"` + Id int64 `json:"id"` } type CreateService struct { - Id int64 `json:"serviceid"` + Id int64 `json:"serviceid"` } +type OpenTicketRequest struct { + DeptId int64 `json:"deptid"` + Subject string `json:"subject"` + Message string `json:"message"` + ClientId int64 `json:"clientid"` +} type GetClientsProducts struct { ServiceId int `json:"serviceid"` @@ -106,10 +112,9 @@ type TerminateServiceResult struct { } type CreateServiceResult struct { - Result string `json:"result"` + Result string `json:"result"` } - // ClientDetailsReq is the struct of parameters available to retrieve client details. type ClientDetailsReq struct { ClientID string `json:"clientid,omitempty"` @@ -141,6 +146,13 @@ func (v *TerminateService) Error() error { return nil } func (v *CreateService) Error() error { - return nil + return nil +} + +func (v *OpenTicketRequest) Error() error { + return nil } +type OpenTicketResponse struct { + Result string `json:"result"` +} diff --git a/client_update.go b/client_update.go index 66bc4ef..5fe2c51 100644 --- a/client_update.go +++ b/client_update.go @@ -10,7 +10,7 @@ var ( ) type ExistingClient struct { - ClientID int64 `"json:clientid,omitempty"` + ClientID int64 `"json:clientid,omitempty"` ClientEmail string `json:"clientemail,omitempty"` Firstname string `json:"firstname,omitempty"` diff --git a/invoice.go b/invoice.go index 573d9f4..4f9b637 100644 --- a/invoice.go +++ b/invoice.go @@ -60,11 +60,9 @@ type AddInvoicePaymentRequest struct { } type AddInvoicePaymentResponse struct { - Result string `json:"result"` + Result string `json:"result"` } - func (r *AddInvoicePaymentRequest) Error() error { - return nil + return nil } - From 527a7fe7a2648b5eae6806d9fa0b2226e1d5809b Mon Sep 17 00:00:00 2001 From: WeVPN Date: Fri, 13 Mar 2020 17:24:17 +0000 Subject: [PATCH 13/18] Service struct fix --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index e8670f7..b663420 100644 --- a/client.go +++ b/client.go @@ -54,7 +54,7 @@ type ResetPassword struct { } type TerminateService struct { - Id int64 `json:"id"` + Id int64 `json:"serviceid"` } type CreateService struct { From a13ff8ed4743defc00262321fd98aae5338eece2 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Sun, 15 Mar 2020 21:23:40 +0000 Subject: [PATCH 14/18] Ticket data structure update --- client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index b663420..13e6a70 100644 --- a/client.go +++ b/client.go @@ -54,7 +54,7 @@ type ResetPassword struct { } type TerminateService struct { - Id int64 `json:"serviceid"` + Id int64 `json:"id"` } type CreateService struct { @@ -154,5 +154,6 @@ func (v *OpenTicketRequest) Error() error { } type OpenTicketResponse struct { - Result string `json:"result"` + Result string `json:"result"` + TicketId string `json:"tid"` } From 8b380fbc9885eb6ee3d40a1b722933b58e6a9726 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Sun, 15 Mar 2020 21:25:12 +0000 Subject: [PATCH 15/18] Ticket data structure update --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 13e6a70..2657a2c 100644 --- a/client.go +++ b/client.go @@ -54,7 +54,7 @@ type ResetPassword struct { } type TerminateService struct { - Id int64 `json:"id"` + Id int64 `json:"serviceid"` } type CreateService struct { From a0b4a1388ad168dbb8022209f6060ce8dd8b8f9e Mon Sep 17 00:00:00 2001 From: WeVPN Date: Thu, 9 Jul 2020 10:24:47 +0000 Subject: [PATCH 16/18] Added SendEmail method --- api.go | 19 +++++++++++++++++++ client.go | 13 +++++++++++++ 2 files changed, 32 insertions(+) diff --git a/api.go b/api.go index 037017e..0dd2472 100644 --- a/api.go +++ b/api.go @@ -353,3 +353,22 @@ func (a *API) CreateService(v *CreateService) (r *CreateServiceResult, err error return } + +//Send email +func (a *API) SendEmail(v *SendEmail) (r *SendEmailResult, err error) { + err = v.Error() + if err != nil { + return + } + body, err := a.Do("SendEmail", &v) + if err != nil { + err = fmt.Errorf("%v", err) + return + } + r = &SendEmailResult{} + if err = json.Unmarshal(body, &r); err != nil { + err = fmt.Errorf("%v", err) + } + + return +} diff --git a/client.go b/client.go index 2657a2c..99756cf 100644 --- a/client.go +++ b/client.go @@ -61,6 +61,11 @@ type CreateService struct { Id int64 `json:"serviceid"` } +type SendEmail struct { + MessageName string `json:"messagename"` + Id int64 `json:"id"` +} + type OpenTicketRequest struct { DeptId int64 `json:"deptid"` Subject string `json:"subject"` @@ -115,6 +120,10 @@ type CreateServiceResult struct { Result string `json:"result"` } +type SendEmailResult struct { + Result string `json:"result"` +} + // ClientDetailsReq is the struct of parameters available to retrieve client details. type ClientDetailsReq struct { ClientID string `json:"clientid,omitempty"` @@ -149,6 +158,10 @@ func (v *CreateService) Error() error { return nil } +func (v *SendEmail) Error() error { + return nil +} + func (v *OpenTicketRequest) Error() error { return nil } From bd774075366d6a3738b0987877d28be444392073 Mon Sep 17 00:00:00 2001 From: WeVPN Date: Thu, 9 Jul 2020 10:29:54 +0000 Subject: [PATCH 17/18] Added invoice fees --- invoice.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/invoice.go b/invoice.go index 4f9b637..c884b9b 100644 --- a/invoice.go +++ b/invoice.go @@ -54,9 +54,10 @@ func (r *UpdateInvoiceRequest) Error() error { // AddInvoicePaymentRequest type AddInvoicePaymentRequest struct { - InvoiceID int64 `json:"invoiceid,string"` - TransID string `json:"transid"` - Gateway string `json:"gateway"` + InvoiceID int64 `json:"invoiceid,string"` + TransID string `json:"transid"` + Gateway string `json:"gateway"` + Fees float64 `json:"fees"` } type AddInvoicePaymentResponse struct { From 3f46c8c4a4d33a1190fce224de5e74b9ee80b514 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 31 Aug 2021 10:29:09 +0000 Subject: [PATCH 18/18] Removed request/body stdin logging --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 3daf292..028c63a 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( "errors" "fmt" "io/ioutil" - "log" + //"log" "net/http" "net/url" "strings" @@ -154,7 +154,7 @@ func (a *API) Do(cmd string, data interface{}) ([]byte, error) { } // POST it. - log.Printf("Send: %+v", m) + //log.Printf("Send: %+v", m) url := fmt.Sprintf("%s/includes/api.php", a.Endpoint) r, err := http.PostForm(url, form) if err != nil { @@ -171,12 +171,12 @@ func (a *API) Do(cmd string, data interface{}) ([]byte, error) { // attempt to get the JSON and ignore the PHP error output. body = bytes.TrimSpace(body) if bytes.HasSuffix(body, []byte("}")) && !bytes.HasPrefix(body, []byte("{")) { - log.Printf("Body probably displaying errors") + //log.Printf("Body probably displaying errors") if idx := bytes.Index(body, []byte("{")); idx > -1 { body = body[idx:] } } - log.Printf("Body: %s", body) + //log.Printf("Body: %s", body) // The most basic responses have no message, so allow for that here. s := APIBasicResponse{}