tatsu_api

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Tatsu API Go

Official Go wrapper for Tatsu's API

Install

go get github.com/tatsuworks/tatsu-api-go

Example 1: using background context

import tatsuapi "github.com/tatsuworks/tatsu-api-go"

client := tatsuapi.New("YOUR_API_KEY")

user, err := client.GetUserProfile("172002275412279296")
if err == nil {
    fmt.Println("Rep: " + user.Reputation)
}

Example 2: using timeout context

import tatsuapi "github.com/tatsuworks/tatsu-api-go"

client := tatsuapi.New("YOUR_API_KEY")

ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()

user, err := client.GetUserProfileWithContext(ctx, "172002275412279296")
if err == nil {
    fmt.Println("Rep: " + user.Reputation)
}

License

Copyright ©2021 Tatsu Works.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action added in v1.2.0

type Action uint8
const (
	ActionAdd    Action = iota
	ActionRemove Action = iota
)

type ApiError added in v1.1.0

type ApiError struct {
	Code    uint   `json:"code"`
	Message string `json:"message"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(apikey string) *Client

func (*Client) GetAllTimeGuildMemberRanking

func (c *Client) GetAllTimeGuildMemberRanking(guildID string, userID string) (*GuildMemberRanking, error)

GetAllTimeGuildMemberRanking wraps around GetAllTimeGuildMemberRankingWithContext using the background context.

func (*Client) GetAllTimeGuildMemberRankingWithContext

func (c *Client) GetAllTimeGuildMemberRankingWithContext(ctx context.Context, guildID string,
	userID string) (*GuildMemberRanking, error)

GetAllTimeGuildMemberRankingWithContext gets a guild member's all time ranking using the specified context.

func (*Client) GetAllTimeGuildRankings

func (c *Client) GetAllTimeGuildRankings(guildID string, offset uint64) (*GuildRankings, error)

GetAllTimeGuildRankings wraps around GetAllTimeGuildRankingsWithContext using a background context.

func (*Client) GetAllTimeGuildRankingsWithContext

func (c *Client) GetAllTimeGuildRankingsWithContext(ctx context.Context, guildID string,
	offset uint64) (*GuildRankings, error)

GetAllTimeGuildRankingsWithContext gets a guild's all time rankings using the specified context.

func (*Client) GetCurrentMonthGuildMemberRanking added in v1.1.0

func (c *Client) GetCurrentMonthGuildMemberRanking(guildID string, userID string) (*GuildMemberRanking, error)

GetCurrentMonthGuildMemberRanking wraps around GetCurrentMonthGuildMemberRankingWithContext using the background context.

func (*Client) GetCurrentMonthGuildMemberRankingWithContext added in v1.1.0

func (c *Client) GetCurrentMonthGuildMemberRankingWithContext(ctx context.Context, guildID string,
	userID string) (*GuildMemberRanking, error)

GetCurrentMonthGuildMemberRankingWithContext gets a guild member's current month ranking using the specified context.

func (*Client) GetCurrentMonthGuildRankings added in v1.1.0

func (c *Client) GetCurrentMonthGuildRankings(guildID string, offset uint64) (*GuildRankings, error)

GetCurrentMonthGuildRankings wraps around GetCurrentMonthGuildRankingsWithContext using a background context.

func (*Client) GetCurrentMonthGuildRankingsWithContext added in v1.1.0

func (c *Client) GetCurrentMonthGuildRankingsWithContext(ctx context.Context, guildID string,
	offset uint64) (*GuildRankings, error)

GetCurrentMonthGuildRankingsWithContext gets a guild's current month rankings using the specified context.

func (*Client) GetCurrentWeekGuildMemberRanking added in v1.1.0

func (c *Client) GetCurrentWeekGuildMemberRanking(guildID string, userID string) (*GuildMemberRanking, error)

GetCurrentWeekGuildMemberRanking wraps around GetCurrentWeekGuildMemberRankingWithContext using the background context.

func (*Client) GetCurrentWeekGuildMemberRankingWithContext added in v1.1.0

func (c *Client) GetCurrentWeekGuildMemberRankingWithContext(ctx context.Context, guildID string,
	userID string) (*GuildMemberRanking, error)

GetCurrentWeekGuildMemberRankingWithContext gets a guild member's current week ranking using the specified context.

func (*Client) GetCurrentWeekGuildRankings added in v1.1.0

func (c *Client) GetCurrentWeekGuildRankings(guildID string, offset uint64) (*GuildRankings, error)

GetCurrentWeekGuildRankings wraps around GetCurrentWeekGuildRankingsWithContext using a background context.

func (*Client) GetCurrentWeekGuildRankingsWithContext added in v1.1.0

func (c *Client) GetCurrentWeekGuildRankingsWithContext(ctx context.Context, guildID string,
	offset uint64) (*GuildRankings, error)

GetCurrentWeekGuildRankingsWithContext gets a guild's current week rankings using the specified context.

func (*Client) GetStoreListing added in v1.2.0

func (c *Client) GetStoreListing(listingID string) (*StoreListing, error)

GetStoreListing wraps around GetStoreListingWithContext using the background context.

func (*Client) GetStoreListingWithContext added in v1.2.0

func (c *Client) GetStoreListingWithContext(ctx context.Context, listingID string) (*StoreListing, error)

GetStoreListingWithContext gets a store listing using the specified context.

func (*Client) GetUserProfile

func (c *Client) GetUserProfile(userID string) (*User, error)

GetUserProfile wraps around GetUserProfileWithContext using the background context.

func (*Client) GetUserProfileWithContext

func (c *Client) GetUserProfileWithContext(ctx context.Context, userID string) (*User, error)

GetUserProfileWithContext gets a user's profile using the specified context.

func (*Client) ModifyGuildMemberScore added in v1.2.0

func (c *Client) ModifyGuildMemberScore(guildID string, userID string, action Action,
	amount uint32) (*GuildMemberScore, error)

ModifyGuildMemberScore wraps around ModifyGuildMemberScore using the background context.

func (*Client) ModifyGuildMemberScoreWithContext added in v1.2.0

func (c *Client) ModifyGuildMemberScoreWithContext(ctx context.Context, guildID string, userID string,
	action Action, amount uint32) (*GuildMemberScore, error)

ModifyGuildMemberScoreWithContext modifies a guild member's score using the specified context.

type GuildMemberRanking

type GuildMemberRanking struct {
	GuildID string `json:"guild_id"`
	Rank    int64  `json:"rank"`
	Score   uint64 `json:"score"`
	UserID  string `json:"user_id"`
}

type GuildMemberScore added in v1.2.0

type GuildMemberScore struct {
	GuildID string `json:"guild_id"`
	Score   uint64 `json:"score"`
	UserID  string `json:"user_id"`
}

type GuildRanking

type GuildRanking struct {
	Rank   int64  `json:"rank"`
	Score  uint64 `json:"score"`
	UserID string `json:"user_id"`
}

type GuildRankings

type GuildRankings struct {
	GuildID  string          `json:"guild_id"`
	Rankings []*GuildRanking `json:"rankings"`
}

type StoreCurrency added in v1.2.0

type StoreCurrency uint8
const (
	StoreCurrencyCredits StoreCurrency = iota
	StoreCurrencyTokens
	StoreCurrencyEmeralds
	StoreCurrencyCandyCane
	StoreCurrencyUSD
	StoreCurrencyCandyCorn
)

type StoreListing added in v1.2.0

type StoreListing struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Summary     string        `json:"summary"`
	Description string        `json:"description"`
	New         bool          `json:"new"`
	Preview     string        `json:"preview"`
	Prices      []*StorePrice `json:"prices"`
	Categories  []string      `json:"categories"`
	Tags        []string      `json:"tags"`
}

type StorePrice added in v1.2.0

type StorePrice struct {
	Currency StoreCurrency `json:"currency"`
	Amount   float32       `json:"amount"`
}

type Timestamp added in v1.1.0

type Timestamp string

func (Timestamp) Parse added in v1.1.0

func (t Timestamp) Parse() (time.Time, error)

type User

type User struct {
	AvatarURL           string    `json:"avatar_url"`
	Credits             uint64    `json:"credits"`
	Discriminator       string    `json:"discriminator"`
	ID                  string    `json:"id"`
	InfoBox             string    `json:"info_box"`
	Reputation          uint64    `json:"reputation"`
	SubscriptionRenewal Timestamp `json:"subscription_renewal"`
	SubscriptionType    uint8     `json:"subscription_type"`
	Title               string    `json:"title"`
	Tokens              uint64    `json:"tokens"`
	Username            string    `json:"username"`
	XP                  uint64    `json:"xp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL