diff --git a/client.go b/client.go index 5254c3b..3cad0a7 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "io" - "io/ioutil" "net/http" "sync" ) @@ -127,7 +126,7 @@ func (client *Client) do(req *http.Request) (*Response, error) { return resp, err } - _, err = io.Copy(ioutil.Discard, httpResponse.Body) + _, err = io.Copy(io.Discard, httpResponse.Body) if err != nil { return resp, err } @@ -140,7 +139,7 @@ func (client *Client) newResponse(httpResponse *http.Response) (*Response, error response := new(Response) response.HTTPResponse = httpResponse - buf, err := ioutil.ReadAll(response.HTTPResponse.Body) + buf, err := io.ReadAll(response.HTTPResponse.Body) if err != nil { return nil, err } diff --git a/collection_service.go b/collection_service.go index 09f2046..86b8f84 100644 --- a/collection_service.go +++ b/collection_service.go @@ -23,7 +23,7 @@ func (service *collectionService) Token(ctx context.Context) (*AuthToken, *Respo response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } authToken := new(AuthToken) @@ -87,7 +87,7 @@ func (service *collectionService) GetRequestToPayStatus( response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } status := new(CollectionTransactionStatus) @@ -118,7 +118,7 @@ func (service *collectionService) GetAccountBalance(ctx context.Context) (*Accou response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } balance := new(AccountBalance) diff --git a/disbursement_service.go b/disbursement_service.go index b548da0..c04104c 100644 --- a/disbursement_service.go +++ b/disbursement_service.go @@ -23,7 +23,7 @@ func (service *disbursementsService) Token(ctx context.Context) (*AuthToken, *Re response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } authToken := new(AuthToken) @@ -87,7 +87,7 @@ func (service *disbursementsService) GetTransferStatus( response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } status := new(DisbursementTransactionStatus) @@ -118,7 +118,7 @@ func (service *disbursementsService) GetAccountBalance(ctx context.Context) (*Ac response, err := service.client.do(request) if err != nil { - return nil, nil, err + return nil, response, err } balance := new(AccountBalance) diff --git a/go.mod b/go.mod index 58d33eb..1588530 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,20 @@ module github.com/NdoleStudio/mtnmomo-go go 1.17 require ( + github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 github.com/davecgh/go-spew v1.1.1 + github.com/dustin/go-humanize v1.0.1 + github.com/fatih/color v1.17.0 github.com/google/uuid v1.3.0 github.com/stretchr/testify v1.8.1 ) +require ( + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + golang.org/x/sys v0.24.0 // indirect +) + require ( github.com/NdoleStudio/orangemoney-go v0.0.1 github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 791c328..fefd32f 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,22 @@ github.com/NdoleStudio/orangemoney-go v0.0.1 h1:VRCPb18BlSOwAy106t8k3mz95FT6w5fTwtJnt1vlW3A= github.com/NdoleStudio/orangemoney-go v0.0.1/go.mod h1:FIed5i5iG+NHrItYivX1fX7nxMLXyPeHB57CrOHC7zU= +github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 h1:ZBbLwSJqkHBuFDA6DUhhse0IGJ7T5bemHyNILUjvOq4= +github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2/go.mod h1:VSw57q4QFiWDbRnjdX8Cb3Ow0SFncRw+bA/ofY6Q83w= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -17,6 +28,12 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=