diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-20 23:11:52 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-09-20 23:11:52 +0530 |
commit | f23dae307e06d95499b35dbdd8e341b45756b330 (patch) | |
tree | b46c707a8cd62f8c63c78eb4018dc9bc0da1cffe /content/docs/mal2go/v4/user |
First commit
Diffstat (limited to 'content/docs/mal2go/v4/user')
-rw-r--r-- | content/docs/mal2go/v4/user/_index.md | 5 | ||||
-rw-r--r-- | content/docs/mal2go/v4/user/anime/_index.md | 10 | ||||
-rw-r--r-- | content/docs/mal2go/v4/user/get-self-user-info/_index.md | 48 | ||||
-rw-r--r-- | content/docs/mal2go/v4/user/manga/_index.md | 9 | ||||
-rw-r--r-- | content/docs/mal2go/v4/user/setting-up/_index.md | 34 |
5 files changed, 106 insertions, 0 deletions
diff --git a/content/docs/mal2go/v4/user/_index.md b/content/docs/mal2go/v4/user/_index.md new file mode 100644 index 0000000..02c62bc --- /dev/null +++ b/content/docs/mal2go/v4/user/_index.md @@ -0,0 +1,5 @@ +--- +title: User +description: Actions related to a user's account/lists +weight: 3 +--- diff --git a/content/docs/mal2go/v4/user/anime/_index.md b/content/docs/mal2go/v4/user/anime/_index.md new file mode 100644 index 0000000..0728945 --- /dev/null +++ b/content/docs/mal2go/v4/user/anime/_index.md @@ -0,0 +1,10 @@ +--- +title: User's Animelist +description: Actions related to a user's animelist +weight: 3 +--- + +The `MAL2Go/user/anime` package supports updating the currently authenticated user's anime list along with reading the anime lists of the current user as well as other users. + + +## coming soon! diff --git a/content/docs/mal2go/v4/user/get-self-user-info/_index.md b/content/docs/mal2go/v4/user/get-self-user-info/_index.md new file mode 100644 index 0000000..31b943c --- /dev/null +++ b/content/docs/mal2go/v4/user/get-self-user-info/_index.md @@ -0,0 +1,48 @@ +--- +title: Getting authenticated user's info +description: Returns information about currenlty logged in user +weight: 2 +--- + +## Getting self user's info + +The `GetSelfUserInfo` function can be used to get information about the currently logged in user. + +``` go +package main + +import ( + "fmt" + "log" + "github.com/MikunoNaka/MAL2Go/v4/user" +) + +func main() { + authToken := "YOUR_TOKEN_HERE" + myClient := user.Client { + AuthToken: "Bearer " + authToken, + } + + userInfo, err := myClient.GetSelfUserInfo() + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Username: %s\n", userInfo.Name) + fmt.Printf("Profile Picture: %s\n", userInfo.Picture) + fmt.Printf("Gender: %s\n", userInfo.Gender) + fmt.Printf("Location: %s\n", userInfo.Location) + fmt.Printf("Birthday: %s\n", userInfo.Birthday) + fmt.Printf("Time Zone: %s\n", userInfo.TimeZone) + fmt.Printf("Joined At: %s\n", userInfo.JoinedAt) + fmt.Printf("User ID: %d\n", userInfo.Id) + + if userInfo.IsSupporter { + fmt.Println("You are a MyAnimeList Supporter.") + } else { + fmt.Println("You are not a MyAnimeList Supporter.") + } +} +``` + +**MyAnimeList's Official API only allows getting info about the currently logged in user.** diff --git a/content/docs/mal2go/v4/user/manga/_index.md b/content/docs/mal2go/v4/user/manga/_index.md new file mode 100644 index 0000000..fd87fc8 --- /dev/null +++ b/content/docs/mal2go/v4/user/manga/_index.md @@ -0,0 +1,9 @@ +--- +title: User's Mangalist +description: Actions related to a user's mangalist +weight: 4 +--- + +The `MAL2Go/user/manga` package supports updating the currently authenticated user's manga list along with reading the manga lists of the current user as well as other users. + +## coming soon! diff --git a/content/docs/mal2go/v4/user/setting-up/_index.md b/content/docs/mal2go/v4/user/setting-up/_index.md new file mode 100644 index 0000000..0b2b890 --- /dev/null +++ b/content/docs/mal2go/v4/user/setting-up/_index.md @@ -0,0 +1,34 @@ +--- +title: "Setting up" +description: "Install MAL2Go/user and write some boilerplate" +weight: 1 +--- + +How to use the user package: + +1. Install the user package using this command + +``` fish +go get github.com/MikunoNaka/MAL2Go/v4/user +``` + +2. Import and initialise the user client. The client holds the authentication token of the user. The OAuth token should be set as "Bearer TOKEN". Refer to below example + +``` go +package main + +import ( + "github.com/MikunoNaka/MAL2Go/v4/user" +) + +func main() { + // you should never hard-code tokens. This is just an example + authToken := "YOUR_TOKEN_HERE" + myClient := user.Client { + AuthToken: "Bearer " + authToken, + } +} +``` + +Every program using MAL2Go needs something like this to initialise everything (that you need). +And now we are ready to use the MAL2Go/anime package! |