Skip to content

Commit

Permalink
config update--overall refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Sogbey committed Aug 16, 2023
1 parent a8c9f95 commit 8f4fa3a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ import (
"fmt"
"log"
"os"
"github.com/Daniel-Sogbey/go-paystack/client"

"github.com/Daniel-Sogbey/go-paystack/paystack"
"github.com/Daniel-Sogbey/go-paystack/pkg/transactions/initialize"
"github.com/Daniel-Sogbey/go-paystack/pkg/transactions/verify"
)

func main() {

//SET UP AN HTTP CLIENT WITH AUTHORIZATION KEY AND CONTENT TYPE
client := &client.Client{
client := &paystack.Client{
Authorization: os.Getenv("PAYSTACK_API_KEY"),
ContentType: "application/json",
}
Expand Down Expand Up @@ -60,6 +61,7 @@ func main() {
fmt.Println("JSON RESPONSE : ", verifyTransactionResponse)

}

```

## Run Sample Test
Expand All @@ -74,12 +76,13 @@ package initialize
import (
"testing"
"os"
"github.com/Daniel-Sogbey/go-paystack/client"

"github.com/Daniel-Sogbey/go-paystack/paystack"
)

func TestInitializeTransactions(t *testing.T) {

client := &client.Client{
client := &paystack.Client{
Authorization: os.Getenv("PAYSTACK_API_KEY"),
ContentType: "application/json",
}
Expand All @@ -101,6 +104,7 @@ func TestInitializeTransactions(t *testing.T) {

}


```


Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"fmt"
"log"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/paystack"
"github.com/Daniel-Sogbey/go-paystack/pkg/transactions/initialize"
"github.com/Daniel-Sogbey/go-paystack/pkg/transactions/verify"
)

func main() {

//SET UP AN HTTP CLIENT WITH AUTHORIZATION KEY AND CONTENT TYPE
client := &client.Client{
client := &paystack.Client{
Authorization: "sk_test_f572197fbc13951b13afafc0d0f6517ed7ec12eb",
ContentType: "application/json",
}
Expand Down
2 changes: 1 addition & 1 deletion client/client.go → paystack/paystack.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client
package paystack

import "net/http"

Expand Down
4 changes: 2 additions & 2 deletions pkg/transactions/initialize/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"log"
"net/http"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/internal"
"github.com/Daniel-Sogbey/go-paystack/paystack"
)

type CustomField struct {
Expand Down Expand Up @@ -42,7 +42,7 @@ type InitializeTransactionRequest struct {
Amount string `json:"amount"`
}

func InitializeTransaction(c *client.Client, request *InitializeTransactionRequest) (InitializeTransactionResponse, error) {
func InitializeTransaction(c *paystack.Client, request *InitializeTransactionRequest) (InitializeTransactionResponse, error) {
c.Client = &http.Client{}

apiUrl := "https://api.paystack.co/transaction/initialize"
Expand Down
4 changes: 2 additions & 2 deletions pkg/transactions/initialize/initialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package initialize
import (
"testing"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/paystack"
)

func TestInitializeTransactions(t *testing.T) {

client := &client.Client{
client := &paystack.Client{
Authorization: "sk_test_f572197fbc13951b13afafc0d0f6517ed7ec12eb",
ContentType: "application/json",
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/transactions/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package listTransactions
import (
"testing"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/paystack"
)

func TestListTransactions(t *testing.T) {
client := &client.Client{
client := &paystack.Client{
Authorization: "sk_test_f572197fbc13951b13afafc0d0f6517ed7ec12eb",
ContentType: "application/json",
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/transactions/verify/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"log"
"net/http"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/internal"
"github.com/Daniel-Sogbey/go-paystack/paystack"
)

type VerificationRequest struct {
Expand Down Expand Up @@ -98,7 +98,7 @@ type VerificationResponse struct {
Data TransactionData `json:"data"`
}

func VerifyTransaction(c *client.Client, request *VerificationRequest) (VerificationResponse, error) {
func VerifyTransaction(c *paystack.Client, request *VerificationRequest) (VerificationResponse, error) {
c.Client = &http.Client{}

apiUrl := "https://api.paystack.co/transaction/verify/" + request.Reference
Expand Down
4 changes: 2 additions & 2 deletions pkg/transactions/verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package verify
import (
"testing"

"github.com/Daniel-Sogbey/go-paystack/client"
"github.com/Daniel-Sogbey/go-paystack/paystack"
)

func TestVerifyTransaction(t *testing.T) {

client := &client.Client{
client := &paystack.Client{
Authorization: "sk_test_f572197fbc13951b13afafc0d0f6517ed7ec12eb",
ContentType: "application/json",
}
Expand Down

0 comments on commit 8f4fa3a

Please sign in to comment.