-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: update code and fixtures to reflect a change in the payload s…
…chema
- Loading branch information
Showing
4 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/dnsimple/dnsimple-go/dnsimple" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
func main() { | ||
tc := dnsimple.StaticTokenHTTPClient(context.Background(), "dnsimpletest_a_fYkucvRnKzn86cVlODVnX0L6LaUbrnUa") | ||
|
||
// new client | ||
client := dnsimple.NewClient(tc) | ||
client.BaseURL = "http://api.dnsimple.localhost:3000" | ||
|
||
// get the current authenticated account (if you don't know who you are) | ||
whoamiResponse, err := client.Identity.Whoami(context.Background()) | ||
if err != nil { | ||
fmt.Printf("Whoami() returned error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Println(whoamiResponse.Data.Account) | ||
|
||
// either assign the account ID or fetch it from the response | ||
// if you are authenticated with an account token | ||
accountID := strconv.FormatInt(whoamiResponse.Data.Account.ID, 10) | ||
|
||
// get the list of domains | ||
dnsAnalyticsResponse, err := client.DnsAnalytics.Query(context.Background(), accountID, nil) | ||
if err != nil { | ||
fmt.Printf("DnsAnalytics.Query() returned error: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
// iterate over all the domains in the | ||
// paginated response. | ||
for _, entry := range dnsAnalyticsResponse.Data { | ||
fmt.Println(entry) | ||
} | ||
|
||
fmt.Println(dnsAnalyticsResponse) | ||
} |