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.
Completed
Pull Request — master (#88)
by
unknown
01:13
created

examples.EnableGiftCardIssuer   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
nop 0
1
package examples
2
3
import (
4
	"fmt"
5
	"log"
6
	"os"
7
8
	"github.com/VictorAvelar/mollie-api-go/mollie"
9
)
10
var(
11
	profileID string = "pfl_jmWPWbFgeh"
12
)
13
14
// Sets the mollie api token on an environment variable.
15
func init() {
16
	_ = os.Setenv(mollie.APITokenEnv, "YOUR_API_TOKEN")
17
	_ = os.Setenv(mollie.OrgTokenEnv, "YOUR_ORG_TOKEN")
18
19
	config := mollie.NewConfig(true, mollie.OrgTokenEnv)
20
	client, _ = mollie.NewClient(nil, config)
21
	
22
}
23
24
//CreateProfile code sample for creating a new profile.
25
func CreateProfile() {
26
27
	newProfile := &mollie.Profile{
28
		Name:         "My website name",            //Brand name or trademark of the website profile
29
		Website:      "https://www.mywebsite.com",  //The profiles website URL (The URL must be compliant to RFC3986)
30
		Email:        "[email protected]",         //Email address for the profile
31
		Phone:        "+31208202071",               //Phone number for the profile
32
		CategoryCode: mollie.GeneralMerchandise,    //Optional value for the websites associated industry
33
		Mode:         mollie.TestMode,              //Mode: "Test" for testing or "Live" for the live use of the api
34
	}
35
36
	profile, err := client.Profiles.Create(newProfile) 
37
38
	if err != nil {
39
		log.Fatal(err) 
40
	}
41
42
	fmt.Println(profile)
43
}
44
45
//GetProfile code sample for getting a specific profile using a profile ID.
46
func GetProfile() {
47
48
	profile, err := client.Profiles.Get(profileID)
49
	if err != nil {
50
		log.Fatal(err)
51
	}
52
53
	fmt.Println(profile)
54
}
55
56
//CurrentProfile code sample for getting the current profile belonging to the API key.
57
func CurrentProfile() {
58
59
	newConfig := mollie.NewConfig(true, mollie.APITokenEnv) //Requires a API key 
60
	newClient, _ := mollie.NewClient(nil,newConfig)
61
	
62
	profile, err := newClient.Profiles.Current()
63
	if err != nil {
64
		log.Fatal(err)
65
	}
66
	fmt.Println(profile)
67
68
}
69
70
//UpdateProfile code sample for updating a specific profile.
71
func UpdateProfile() {
72
73
	updatedProfile := &mollie.Profile{
74
		Name:    "My Website Name",
75
		Website: "http://www.mywebsite.com",
76
		Email:   "[email protected]",
77
	}
78
79
	profile, err := client.Profiles.Update(profileID, updatedProfile)
80
	if err != nil {
81
		log.Fatal(err)
82
	}
83
84
	fmt.Println(profile)
85
}
86
87
//DeleteProfile code sample for deleting a specific profile using a profile ID.
88
func DeleteProfile() {
89
90
	err := client.Profiles.Delete(profileID)
91
92
	if err != nil {
93
		log.Fatal(err)
94
	}
95
}
96
97
//ListProfiles code sample for list all profiles.
98
func ListProfiles() {
99
100
	list, err := client.Profiles.List(nil) //Optional list options 
101
	if err != nil {
102
		log.Fatal(err)
103
	}
104
105
	for _, profile := range list.Embedded.Profiles{
106
		fmt.Println(profile)
107
	}
108
}
109
110
//EnablePaymentMethod code sample for enabling a payment method on a profile.
111
func EnablePaymentMethod() {
112
113
	paymentMethodInfo, err := client.Profiles.EnablePaymentMethod(profileID, mollie.IDeal)
114
115
	if err != nil {
116
		log.Fatal(err)
117
	}
118
119
	fmt.Println(paymentMethodInfo)
120
}
121
122
//DisablePaymentMethod code sample for disabling a payment method on a profile.
123
func DisablePaymentMethod() {
124
125
	err := client.Profiles.DisablePaymentMethod(profileID, mollie.IDeal)
126
127
	if err != nil {
128
		log.Fatal(err)
129
	}
130
131
}
132
133
//EnableGiftCardIssuer code sample for enabling gift card issuer on a specific profile to use with payments.
134
func EnableGiftCardIssuer() {
135
136
	gc, err := client.Profiles.EnableGiftCardIssuer(profileID, mollie.Festivalcadeau)
137
	if err != nil{
138
		log.Fatal(err)
139
	}
140
141
	fmt.Println(gc)
142
}
143
144
//DisableGiftCardIssuer code sample for disabling gift card issuer on a specific profile.
145
func DisableGiftCardIssuer() {
146
147
	err := client.Profiles.DisableGiftCardIssuer(profileID, mollie.Festivalcadeau)
148
	if err != nil{
149
		log.Fatal(err)
150
	}
151
}