Passed
Push — main ( d42549...4001cc )
by Acho
01:41
created

transactions_service.go   A

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 19
dl 0
loc 34
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A flutterwave.*transactionsService.Verify 0 19 4
1
package flutterwave
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"fmt"
7
	"net/http"
8
)
9
10
// transactionsService is the API client for the `/v3/transactions` endpoint
11
type transactionsService service
12
13
// Verify the final status of a transaction
14
//
15
// API Docs: https://developer.flutterwave.com/reference/endpoints/transactions
16
func (service *transactionsService) Verify(ctx context.Context, transactionID int64) (*TransactionResponse, *Response, error) {
17
	uri := fmt.Sprintf("/v3/transactions/%d/verify", transactionID)
18
19
	request, err := service.client.newRequest(ctx, http.MethodGet, uri, nil)
20
	if err != nil {
21
		return nil, nil, err
22
	}
23
24
	response, err := service.client.do(request)
25
	if err != nil {
26
		return nil, response, err
27
	}
28
29
	var data TransactionResponse
30
	if err = json.Unmarshal(*response.Body, &data); err != nil {
31
		return nil, response, err
32
	}
33
34
	return &data, response, nil
35
}
36