GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#79)
by Victor Hugo
03:12
created

examples/chargebacks.go   A

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 12
eloc 38
dl 0
loc 76
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A examples.init 0 4 1
A examples.ListAllPaymentsWithOptions 0 11 3
A examples.ListAllPaymentsForAccount 0 9 3
A examples.GetSingleGhargeback 0 7 2
A examples.ListAllPaymentRelatedChargebacks 0 9 3
1
package examples
2
3
import (
4
	"fmt"
5
	"log"
6
	"os"
7
8
	"github.com/VictorAvelar/mollie-api-go/mollie"
9
)
10
11
var (
12
	config       *mollie.Config
13
	client       *mollie.Client
14
	paymentID    string = "tr_WDqYK6vllg"
15
	chargebackID string = "chb_n9z0tp"
16
)
17
18
// Sets the mollie api token on a environment variable.
19
func init() {
20
	_ = os.Setenv(mollie.APITokenEnv, "YOUR_API_TOKEN")
21
	config = mollie.NewConfig(true, mollie.APITokenEnv)
22
	client, _ = mollie.NewClient(nil, config)
23
}
24
25
// GetSingleGhargeback code samples shows how  a payment chargeback for the matching
26
// payment and chargeback id should be retrieved.
27
func GetSingleGhargeback() {
28
	chargeback, err := client.Chargebacks.Get(paymentID, chargebackID, nil)
29
	if err != nil {
30
		log.Fatal(err)
31
	}
32
33
	fmt.Printf("%+v", chargeback)
34
}
35
36
// ListAllPaymentRelatedChargebacks code sample shows how to retrieve all received
37
// chargebacks for a payment.
38
func ListAllPaymentRelatedChargebacks() {
39
	list, err := client.Chargebacks.ListForPayment(paymentID, nil)
40
41
	if err != nil {
42
		log.Fatal(err)
43
	}
44
45
	for _, c := range list.Embedded.Chargebacks {
46
		fmt.Printf("%+v\n", c)
47
	}
48
}
49
50
// ListAllPaymentsForAccount code sample shows how to retrieve all received
51
// chargebacks for your account.
52
func ListAllPaymentsForAccount() {
53
	list, err := client.Chargebacks.List(nil)
54
55
	if err != nil {
56
		log.Fatal(err)
57
	}
58
59
	for _, c := range list.Embedded.Chargebacks {
60
		fmt.Printf("%+v\n", c)
61
	}
62
}
63
64
// ListAllPaymentsWithOptions code sample shows how to retrieve all received
65
// chargebacks for your account.
66
func ListAllPaymentsWithOptions() {
67
	list, err := client.Chargebacks.List(&mollie.ListChargebackOptions{
68
		Include: "payments", // will include the payments these chargebacks were issued for.
69
	})
70
71
	if err != nil {
72
		log.Fatal(err)
73
	}
74
75
	for _, c := range list.Embedded.Chargebacks {
76
		fmt.Printf("%+v\n", c)
77
	}
78
}
79