Skip to content

Commit

Permalink
adds bank account tracking adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Alican Akkus committed Nov 9, 2023
1 parent 08637f8 commit b32d0cb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
16 changes: 16 additions & 0 deletions adapter/bank_account_tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package adapter

import (
"context"
"fmt"
"net/http"
)

Expand All @@ -23,3 +24,18 @@ func (api *BankAccountTracking) SearchRecords(ctx context.Context, request Searc

return response.Data, nil
}

func (api *BankAccountTracking) RetrieveRecords(ctx context.Context, id int64) (*BankAccountTrackingRecordResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/bank-account-tracking/v1/merchant-bank-account-trackings/records/%d", id), nil)
if err != nil {
return nil, err
}
response := &Response[BankAccountTrackingRecordResponse]{}
err = api.Client.Do(ctx, newRequest, response)

if err != nil {
return nil, err
}

return response.Data, nil
}
13 changes: 11 additions & 2 deletions tests/bank_account_tracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"testing"
)

var bankAccountTrackingClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io")
var bankAccountTrackingClient, _ = craftgate.New("api-key", "secret-key", "http://localhost:8000")

func TestPayment_SearchBankAccountTrackingRecords(t *testing.T) {
func TestBankAccountTracking_SearchBankAccountTrackingRecords(t *testing.T) {
request := adapter.SearchBankAccountTrackingRecordRequest{
Page: 0,
Size: 10,
Expand All @@ -24,3 +24,12 @@ func TestPayment_SearchBankAccountTrackingRecords(t *testing.T) {
t.Errorf("Error %s", err)
}
}

func TestBankAccountTracking_RetrieveRecord(t *testing.T) {
res, err := bankAccountTrackingClient.BankAccountTracking.RetrieveRecords(context.Background(), 1)
_, _ = spew.Printf("%#v\n", res)

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

0 comments on commit b32d0cb

Please sign in to comment.