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 (#82)
by
unknown
01:13
created

examples.EnablePaymentMethod   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
dl 0
loc 9
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
	
60
	newConfig := mollie.NewConfig(true, mollie.APITokenEnv) //Requires a API key 
61
	newClient, _ := mollie.NewClient(nil,newConfig)
62
	
63
	profile, err := newClient.Profiles.Current()
64
	if err != nil {
65
		log.Fatal(err)
66
	}
67
	fmt.Println(profile)
68
69
}
70
71
//UpdateProfile code sample for updating a specific profile.
72
func UpdateProfile() {
73
74
	updatedProfile := &mollie.Profile{
75
		Name:    "My Website Name",
76
		Website: "http://www.mywebsite.com",
77
		Email:   "[email protected]",
78
	}
79
80
	profile, err := client.Profiles.Update(profileID, updatedProfile)
81
	if err != nil {
82
		log.Fatal(err)
83
	}
84
85
	fmt.Println(profile)
86
}
87
88
//DeleteProfile code sample for deleting a specific profile using a profile ID.
89
func DeleteProfile() {
90
91
	err := client.Profiles.Delete(profileID)
92
93
	if err != nil {
94
		log.Fatal(err)
95
	}
96
}
97
98
//ListProfiles code sample for list all profiles.
99
func ListProfiles() {
100
101
	list, err := client.Profiles.List(nil) //Optional list options 
102
	if err != nil {
103
		log.Fatal(err)
104
	}
105
106
	for _, profile := range list.Embedded.Profiles{
107
		fmt.Println(profile)
108
	}
109
}
110
111
//EnablePaymentMethod code sample for enabling a payment method on a profile.
112
func EnablePaymentMethod() {
113
114
	paymentMethodInfo, err := client.Profiles.EnablePaymentMethod(profileID, mollie.IDeal)
115
116
	if err != nil {
117
		log.Fatal(err)
118
	}
119
120
	fmt.Println(paymentMethodInfo)
121
}
122
123
//DisablePaymentMethod code sample for disabling a payment method on a profile.
124
func DisablePaymentMethod() {
125
126
	err := client.Profiles.DisablePaymentMethod(profileID, mollie.IDeal)
127
128
	if err != nil {
129
		log.Fatal(err)
130
	}
131
132
}
133