Skip to content

Commit

Permalink
changes module name and creating tag for versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Alican Akkus committed Dec 2, 2022
1 parent 53ef5db commit 5ae6999
Show file tree
Hide file tree
Showing 14 changed files with 901 additions and 891 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
This repo contains the Go library for Craftgate API.

## Requirements
- Go 1.18 or newer
- Go 1.19 or newer

## Installation

```sh
go get github.com/craftgate/craftgate-go-client/v1.0.0
go get github.com/craftgate/craftgate-go-client@v1.0.0
```

## Usage
Expand All @@ -27,12 +27,12 @@ To access the Craftgate API you'll first need to obtain API credentials (e.g. an
Once you've obtained your API credentials, you can start using Craftgate by instantiating a `Craftgate` with your credentials.

```go
client := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>")
client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://api.craftgate.io")

request := adapter.SearchInstallmentsRequest{
request := craftgate.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.Currency(craftgate.TRY),
Currency: craftgate.TRY,
}

res, err := client.Installment.SearchInstallments(context.Background(), request)
Expand All @@ -56,10 +56,20 @@ Let's quickly review an example where we implement a credit card payment scenari
> For more examples covering almost all use-cases, check out the [examples in the `tests/` folder](./tests)
```go
client := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://sandbox-api.craftgate.io");
client, _ := craftgate.New("<YOUR API KEY>", "<YOUR SECRET KEY>", "https://sandbox-api.craftgate.io");

res, err := paymentClient.Payment.CreatePayment(context.Background(), request)
spew.Printf("%#v\n", res)
request := craftgate.CreatePaymentRequest{
Price: 100,
PaidPrice: 100,
Currency: craftgate.TRY,
...
}

res, err := client.Payment.CreatePayment(context.Background(), request)

if err != nil {
t.Errorf("Error %s", err)
}
```

### Contributions
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/craftgate/craftgate-go-client/v1.0.0
module github.com/craftgate/craftgate-go-client

go 1.19

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package main

import (
"fmt"
craftgate "github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package main

import (
"context"
craftgate "github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"strings"
"testing"

Expand Down
30 changes: 15 additions & 15 deletions tests/file_reporting_test.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package tests

import (
"context"
"github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
craftgate "github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
"time"
"context"
"github.com/craftgate/craftgate-go-client/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
"time"
)

var fileReportingClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")

func TestFileReporting_RetrieveDailyTransactionReport(t *testing.T) {
request := adapter.RetrieveDailyTransactionReportRequest{
ReportDate: craftgate.DateOf(time.Date(2022, 11, 11, 0, 0, 0, 0, time.UTC)),
FileType: craftgate.CSV,
}
request := adapter.RetrieveDailyTransactionReportRequest{
ReportDate: craftgate.DateOf(time.Date(2022, 11, 11, 0, 0, 0, 0, time.UTC)),
FileType: craftgate.CSV,
}

res, err := fileReportingClient.FileReporting.RetrieveDailyTransactionReport(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)
res, err := fileReportingClient.FileReporting.RetrieveDailyTransactionReport(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}
88 changes: 44 additions & 44 deletions tests/fraud_test.go
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
package tests

import (
"context"
"github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
craftgate "github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
"context"
"github.com/craftgate/craftgate-go-client/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"github.com/davecgh/go-spew/spew"
"testing"
)

var fraudClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")

func Test_SearchFraudChecks(t *testing.T) {
request := adapter.SearchFraudChecksRequest{
Page: 0, Size: 10,
}
request := adapter.SearchFraudChecksRequest{
Page: 0, Size: 10,
}

res, err := fraudClient.Fraud.SearchFraudChecks(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)
res, err := fraudClient.Fraud.SearchFraudChecks(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_RetrieveAllFraudValueList(t *testing.T) {
res, err := fraudClient.Fraud.RetrieveAllFraudValueList(context.Background())
_, _ = spew.Printf("%#v\n", res)
res, err := fraudClient.Fraud.RetrieveAllFraudValueList(context.Background())
_, _ = spew.Printf("%#v\n", res)

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_RetrieveFraudValueList(t *testing.T) {
res, err := fraudClient.Fraud.RetrieveFraudValueList(context.Background(), "blockedBuyerIdList")
_, _ = spew.Printf("%#v\n", res)
res, err := fraudClient.Fraud.RetrieveFraudValueList(context.Background(), "blockedBuyerIdList")
_, _ = spew.Printf("%#v\n", res)

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_CreateFraudValueList(t *testing.T) {
err := fraudClient.Fraud.CreateFraudValueList(context.Background(), "myTestList")
err := fraudClient.Fraud.CreateFraudValueList(context.Background(), "myTestList")

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_DeleteFraudValueList(t *testing.T) {
err := fraudClient.Fraud.DeleteFraudValueList(context.Background(), "myTestList")
err := fraudClient.Fraud.DeleteFraudValueList(context.Background(), "myTestList")

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_AddValueToFraudValueList(t *testing.T) {
request := adapter.FraudValueListRequest{
ListName: "ipList",
Value: "999.999.999.999",
}
err := fraudClient.Fraud.AddValueToFraudValueList(context.Background(), request)

if err != nil {
t.Errorf("Error %s", err)
}
request := adapter.FraudValueListRequest{
ListName: "ipList",
Value: "999.999.999.999",
}
err := fraudClient.Fraud.AddValueToFraudValueList(context.Background(), request)

if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_RemoveValueFromFraudValueList(t *testing.T) {
err := fraudClient.Fraud.RemoveValueFromFraudValueList(context.Background(), "ipList", "999.999.999.999")
err := fraudClient.Fraud.RemoveValueFromFraudValueList(context.Background(), "ipList", "999.999.999.999")

if err != nil {
t.Errorf("Error %s", err)
}
if err != nil {
t.Errorf("Error %s", err)
}
}
40 changes: 20 additions & 20 deletions tests/installment_test.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
package tests

import (
"context"
"github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
craftgate "github.com/craftgate/craftgate-go-client/v1.0.0/adapter"
"github.com/stretchr/testify/require"
"testing"
"context"
"github.com/craftgate/craftgate-go-client/adapter"
craftgate "github.com/craftgate/craftgate-go-client/adapter"
"github.com/stretchr/testify/require"
"testing"
)

var installmentClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")

func Test_RetrieveBinNumber(t *testing.T) {
res, err := installmentClient.Installment.RetrieveBinNumber(context.Background(), "487074")
res, err := installmentClient.Installment.RetrieveBinNumber(context.Background(), "487074")

require.Equal(t, *res.BinNumber, "487074")
if err != nil {
t.Errorf("Error %s", err)
}
require.Equal(t, *res.BinNumber, "487074")
if err != nil {
t.Errorf("Error %s", err)
}
}

func Test_SearchInstallments(t *testing.T) {
request := adapter.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.Currency(craftgate.TRY),
}
res, err := installmentClient.Installment.SearchInstallments(context.Background(), request)
request := adapter.SearchInstallmentsRequest{
BinNumber: "487074",
Price: 100,
Currency: craftgate.Currency(craftgate.TRY),
}
res, err := installmentClient.Installment.SearchInstallments(context.Background(), request)

require.Equal(t, *res.Items[0].BinNumber, "487074")
if err != nil {
t.Errorf("Error %s", err)
}
require.Equal(t, *res.Items[0].BinNumber, "487074")
if err != nil {
t.Errorf("Error %s", err)
}
}
Loading

0 comments on commit 5ae6999

Please sign in to comment.