This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample_test.go
82 lines (73 loc) · 1.64 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package improvmx_test
import (
"context"
"fmt"
"log"
"occult.work/improvmx"
)
func Example_account() {
session, error := improvmx.New("token")
if error != nil {
log.Fatal(error)
}
account, error := session.Account.Read(context.Background())
if error != nil {
log.Fatal(error)
}
fmt.Printf("Name: %s\tPlan: %s\n", account.CompanyName, account.Plan.Name)
}
func Example_aliases() {
session, error := improvmx.New("token")
if error != nil {
log.Fatal(error)
}
options := improvmx.NewListOption().
SetIsActive(true).
SetStartsWith("r")
aliases, error := session.Aliases.List(context.Background(), "example.com", options)
if error != nil {
log.Fatal(error)
}
for _, alias := range aliases {
fmt.Printf("%s <%s>\n", alias.Name, alias.Address)
}
}
func Example_credentials() {
session, error := improvmx.New("token")
if error != nil {
log.Fatal(error)
}
ctx := context.Background()
account, error := session.Account.Read(ctx)
if error != nil {
log.Fatal(error)
}
if !account.Premium {
log.Fatal("SMTP Credentials are a premium account feature")
}
credentials, error := session.Credentials.List(ctx, "example.com")
if error != nil {
log.Fatal(error)
}
for _, credential := range credentials {
fmt.Println(credential.Username)
}
}
func Example_domains() {
}
func Example_logs() {
session, error := improvmx.New("token")
if error != nil {
log.Fatal(error)
}
logs, error := session.Aliases.Logs(context.Background(), "example.com", "richard")
if error != nil {
log.Fatal(error)
}
for _, entry := range logs {
fmt.Printf("ID: %s, Hostname: %s, Subject: %s",
entry.ID,
entry.Hostname,
entry.Subject)
}
}