Skip to content

Commit

Permalink
Fix response
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Aug 10, 2024
1 parent 5e62077 commit 97f3ea8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
5 changes: 2 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"sync"
)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions collection_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions disbursement_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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=
Expand Down

0 comments on commit 97f3ea8

Please sign in to comment.