tfd

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 5 Imported by: 0

README

The First Descendant Go Client

Go Version GoDoc License

Overview

go-tfd-client is a Go client library for interacting with "The First Descendant" game API. This client wraps all the API endpoints listed in the NEXON Open API documentation, providing an easy-to-use interface for Go developers to integrate with the game's services.

Features

  • Full coverage of all API endpoints.
  • Easy-to-use and idiomatic Go interface.
  • Support for authentication and authorization.

Installation

To install the library, use the following command:

go get github.com/DevZoneLabs/go-tfd-client/v2

Usage

Here is a basic example of how to use the client:

package main

import (
    "fmt"
    "log"
    "net/http"

    tfd "github.com/DevZoneLabs/go-tfd-client"
)

func main() {
    // Initialize the client without an API key
    client := tfd.NewClient()

    // Set your API key using SetAccessKey
    client.SetAccessKey("YOUR_API_KEY")

    // Optionally, you can set a custom HTTP client
    customHTTPClient := &http.Client{}
    client.CustomHTTPClient(customHTTPClient)

    // Example: Get AccountIdentifier
    accIdentifier, err := client.GetAccountIdentifier("PLAYER_ID")
    if err != nil {
        log.Fatalf("Error fetching account identifier: %v", err)
    }

    fmt.Printf("Account Identifier: %s\n", accIdentifier.OUID)
}

Documentation

Full documentation is available on GoDocs v2

API Coverage

The client covers the following API endpoints:

Account
  • GetAccountIdentifier(userName string) (*models.AccountIdentifier, error)

  • GetUserInfo(ouid string) (*UserBasic, error)

  • GetUserDescendant(ouid string) (*models.UserDescendant, error)

  • GetUserWeapons(ouid string, language LanguageCode) (*models.UserWeapon, error)

  • GetUserReactor(ouid string, language LanguageCode) (*models.UserReactor, error)

  • GetExternalComponent(ouid string, language LanguageCode) (*models.UserExternalComponent, error)

Metadata
  • GetDescendantsMetadata(language LanguageCode) ([]models.Descendant, error)

  • GetWeaponsMetadata(language LanguageCode) ([]models.Weapon, error)

  • GetModulesMetadata(language LanguageCode) ([]models.Module, error)

  • GetReactorsMetadata(language LanguageCode) ([]models.Reactor, error)

  • GetExternalComponentsMetadata(language LanguageCode) ([]models.ExternalComponent, error)

  • GetRewardsMetadata(language LanguageCode) ([]models.Reward, error)

  • GetStatsMetadata(language LanguageCode) ([]models.StatMeta, error)

  • GetVoidBattlesMetadata(language LanguageCode) (*models.VoidBattleResponse, error)

  • GetVoidBattlesMetadata(language LanguageCode) (*models.VoidBattleResponse, error)

  • GetTitlesMetadata(language LanguageCode) (*models.TitleResponse, error)

Module Recommendation
  • GetModuleRecommendation(opts ModuleRecommendationOpts) (*models.ModuleRecommendationResponse, error)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LanguageCodes = struct {
	Korean             LanguageCode
	English            LanguageCode
	Danish             LanguageCode
	French             LanguageCode
	Japanese           LanguageCode
	ChineseSimplified  LanguageCode
	ChineseTraditional LanguageCode
	Italian            LanguageCode
	Polish             LanguageCode
	Portuguese         LanguageCode
	Russian            LanguageCode
	Spanish            LanguageCode
}{
	"ko", "en", "de", "fr", "ja", "zh-CN", "zh-TW", "it", "pl", "pt", "ru", "es",
}

Functions

This section is empty.

Types

type AccountIdentifier added in v2.1.0

type AccountIdentifier struct {
	OUID string `json:"ouid"` // OUID
}

type BaseStat added in v2.1.0

type BaseStat struct {
	ID    string  `json:"stat_id"`
	Value float64 `json:"stat_value"`
}

type BattleZone added in v2.1.0

type BattleZone struct {
	ID      string       `json:"battle_zone_id"`
	Name    string       `json:"battle_zone_name"`
	Rewards []RewardInfo `json:"reward"`
}

BattleZone represents information about a battlefield

type Client

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

Client represents a client for The First Descendant's API.

func NewClient

func NewClient() *Client

NewClient create and returns a new instance of the TFD Client

func (*Client) AccessKey

func (c *Client) AccessKey() string

AccessKey returns the current API key used by the Client. This key is required for making authenticated requests to the Nexus OpenAPI.

func (*Client) GetAccountIdentifier

func (c *Client) GetAccountIdentifier(userName string) (*AccountIdentifier, error)

GetAccountIdentifier retrieves the account identifier (OUID) for a given username.

func (*Client) GetDescendantsMetadata

func (c *Client) GetDescendantsMetadata(language LanguageCode) ([]Descendant, error)

GetDescendantsMetadata retrieves metadata for descendants in the specified language. It returns a slice of Descendant models and an error if the request fails.

func (*Client) GetExternalComponent

func (c *Client) GetExternalComponent(ouid string, language LanguageCode) (*UserExternalComponent, error)

GetExternalComponent retrieves external component information for the user identified by the given OUID and language.

func (*Client) GetExternalComponentsMetadata

func (c *Client) GetExternalComponentsMetadata(language LanguageCode) ([]ExternalComponent, error)

GetExternalComponentsMetadata retrieves metadata for external components in the specified language. It returns a slice of Weapon models and an error if the request fails.

func (*Client) GetModulesMetadata

func (c *Client) GetModulesMetadata(language LanguageCode) ([]Module, error)

GetModulesMetadata retrieves metadata for modules in the specified language. It returns a slice of Module models and an error if the request fails.

func (*Client) GetReactorsMetadata

func (c *Client) GetReactorsMetadata(language LanguageCode) ([]Reactor, error)

GetReactorsMetadata retrieves metadata for reactors in the specified language. It returns a slice of Reactor models and an error if the request fails.

func (*Client) GetRewardsMetadata

func (c *Client) GetRewardsMetadata(language LanguageCode) ([]Reward, error)

GetRewardsMetadata retrieves metadata for rewards in the specified language. It returns a slice of Reward models and an error if the request fails.

func (*Client) GetStatsMetadata

func (c *Client) GetStatsMetadata(language LanguageCode) ([]StatMeta, error)

GetStatsMetadata retrieves metadata for stats in the specified language. It returns a slice of StatMeta models and an error if the request fails.

func (*Client) GetTitlesMetadata

func (c *Client) GetTitlesMetadata(language LanguageCode) ([]TitleResponse, error)

GetTitlesMetadata retrieves metadata for titles in the specified language. It returns a slice of TitleResponse models and an error if the request fails.

func (*Client) GetUserDescendant

func (c *Client) GetUserDescendant(ouid string) (*UserDescendant, error)

GetUserDescendant retrieves descendant information for the user identified by the given OUID.

func (*Client) GetUserInfo added in v2.1.0

func (c *Client) GetUserInfo(ouid string) (*UserBasic, error)

GetBasicInformation retrieves basic information about the user identified by the given OUID.

func (*Client) GetUserReactor

func (c *Client) GetUserReactor(ouid string, language LanguageCode) (*UserReactor, error)

GetUserReactor retrieves reactor information for the user identified by the given OUID and language.

func (*Client) GetUserWeapons

func (c *Client) GetUserWeapons(ouid string, language LanguageCode) (*UserWeapon, error)

GetUserWeapons retrieves weapon information for the user identified by the given OUID and language.

func (*Client) GetVoidBattlesMetadata

func (c *Client) GetVoidBattlesMetadata(language LanguageCode) ([]VoidBattleResponse, error)

GetVoidBattlesMetadata retrieves metadata for void battles in the specified language. It returns a slice of VoidBattleResponse models and an error if the request fails.

func (*Client) GetWeaponsMetadata

func (c *Client) GetWeaponsMetadata(language LanguageCode) ([]Weapon, error)

GetWeaponsMetadata retrieves metadata for weapons in the specified language. It returns a slice of Weapon models and an error if the request fails.

func (*Client) SetAccessKey

func (c *Client) SetAccessKey(key string)

SetAccessKey sets the API key for the Client. This key is used for authenticating requests to the Nexus OpenAPI.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

SetHTTPClient allows setting a custom http.Client for the Client. This is useful for customizing request behavior, such as setting timeouts or using a different transport.

type Descendant added in v2.1.0

type Descendant struct {
	ID       string            `json:"descendant_id"`        // Descendant identifier
	Name     string            `json:"descendant_name"`      // Descendant name
	ImageURL string            `json:"descendant_image_url"` // Descendant image path
	Stats    []DescendantStats `json:"descendant_stat"`      // Descendant stat information
	Skills   []Skill           `json:"descendant_skill"`     // Descendant skill
}

type DescendantStats added in v2.1.0

type DescendantStats struct {
	Level   int64        `json:"level"`
	Details []StatDetail `json:"stat_detail"`
}

type EnchantmentEffect added in v2.1.0

type EnchantmentEffect struct {
	Level    int64   `json:"enchant_level"`
	StatType string  `json:"stat_type"`
	Value    float64 `json:"value"`
}

Enchantment represents enchantment effect by level information

type Error

type Error struct {
	Name    string `json:"name"`
	Message string `json:"message"`
}

Error represents the detailed error information.

type ErrorMessage

type ErrorMessage struct {
	Details Error `json:"error"`
}

ErrorMessage represents the structure of the error message returned by the server. The JSON response from the server is expected to contain an "error" object with "name" and "message" fields. This structure corresponds to the JSON response format when an HTTP request fails.

func (*ErrorMessage) Error

func (e *ErrorMessage) Error() string

Error implements the error interface for ErrorMessage. It marshals the error details into a JSON string and returns it. This method allows the error to be displayed as a JSON string, providing details about the error encountered.

type ExternalComponent added in v2.1.0

type ExternalComponent struct {
	ID            string `json:"external_component_id"`             // External component identifier
	Name          string `json:"external_component_name"`           // External component name
	ImageURL      string `json:"image_url"`                         // External component image path
	EquipmentType string `json:"external_component_equipment_type"` // External component equipment part
	Tier          string `json:"external_component_tier"`           // External component tier
	BaseStat      []struct {
		BaseStat
		Level int64 `json:"level"` // External component level
	} `json:"base_stat"` // External component effect by level information
	SetOptionDetail []SetOptionDetail `json:"set_option_detail"` // External component set option information
}

ExternalComponent represents the information of an external component

type ExternalComponentAdditionalStats added in v2.1.0

type ExternalComponentAdditionalStats struct {
	AdditionalStats      string `json:"additional_stat_name"`  // External component random option name
	AdditionalStatsValue string `json:"additional_stat_value"` // External component random option value
}

type ExternalComponentInfo added in v2.1.0

type ExternalComponentInfo struct {
	SlotID          string                             `json:"external_component_slot_id"`         // External component slot identifier
	ID              string                             `json:"external_component_id"`              // External component identifier (Refer to /meta/external-component API)
	Level           int64                              `json:"external_component_level"`           // External component level
	AdditionalStats []ExternalComponentAdditionalStats `json:"external_component_additional_stat"` // External component random option information
}

type FireArm added in v2.1.0

type FireArm struct {
	FireArmType  string  `json:"firearm_atk_type"`
	FireArmValue float64 `json:"firearm_atk_value"`
}

type FireArmATK added in v2.1.0

type FireArmATK struct {
	Level   int64     `json:"level"`
	FireArm []FireArm `json:"firearm"`
}

type LanguageCode

type LanguageCode string

type Module added in v2.1.0

type Module struct {
	Name       string       `json:"module_name"`
	ID         string       `json:"module_id"`
	ImageURL   string       `json:"image_url"`
	Type       string       `json:"module_type"`
	Tier       string       `json:"module_tier"`
	SocketType string       `json:"module_socket_type"`
	Class      string       `json:"module_class"`
	Stat       []ModuleStat `json:"module_stat"`
}

type ModuleInfo added in v2.1.0

type ModuleInfo struct {
	SlotID       string `json:"module_slot_id"`       // Module slot identifier
	ID           string `json:"module_id"`            // Module identifier (Refer to /meta/module API)
	EnchantLevel int64  `json:"module_enchant_level"` // Module enchantment level
}

type ModuleStat added in v2.1.0

type ModuleStat struct {
	Level          int64  `json:"level"`
	ModuleCapacity int64  `json:"module_capacity"`
	Value          string `json:"value"`
}

type Reactor added in v2.1.0

type Reactor struct {
	ID                     string       `json:"reactor_id"`
	Name                   string       `json:"reactor_name"`
	ImageURL               string       `json:"image_url"`
	Tier                   string       `json:"reactor_tier"`
	SkillPower             []SkillPower `json:"reactor_skill_power"`
	OptimizedConditionType string       `json:"optimized_condition_type"`
}

Reactor represents information about a reactor

type ReactorAdditionalStats added in v2.1.0

type ReactorAdditionalStats struct {
	AdditionalStats     string `json:"additional_stat_name"`  // Reactor random option name
	AdditionalStatValue string `json:"additional_stat_value"` // Reactor random option value
}

type Reward added in v2.1.0

type Reward struct {
	MapID       string       `json:"map_id"`
	MapName     string       `json:"map_name"`
	BattleZones []BattleZone `json:"battle_zone"`
}

Reward represents information about a reward

type RewardInfo added in v2.1.0

type RewardInfo struct {
	Rotation           int64  `json:"rotation"`
	Type               string `json:"reward_type"` // Reward Type
	ReactorElementType string `json:"reactor_element_type"`
	WeaponRoundsType   string `json:"weapon_rounds_type"`
	ArcheType          string `json:"arche_type"`
}

RewardInfo represents reward rotation information

type SetOptionDetail added in v2.1.0

type SetOptionDetail struct {
	Option       string `json:"set_option"`        // External component set option type
	Count        int64  `json:"set_count"`         // Number of external component sets
	OptionEffect string `json:"set_option_effect"` // External component set option set effect
}

SetOptionDetail represents the set option information for an external component

type Skill added in v2.1.0

type Skill struct {
	Type             string `json:"skill_type"` // active / passive (respective LanguageCode)
	Name             string `json:"skill_name"`
	Element          string `json:"element_type"`
	ArcheType        string `json:"arche_type"`
	SkillImageUrl    string `json:"skill_image_url"`
	SkillDescription string `json:"skill_description"`
}

type SkillPower added in v2.1.0

type SkillPower struct {
	Level            int64               `json:"level"`
	AtkPower         float64             `json:"skill_atk_power"`
	SubSkillAtkPower float64             `json:"sub_skill_atk_power"`
	PowerCoefficient []SkillPowerBoost   `json:"skill_power_coefficient"`
	EnchantEffect    []EnchantmentEffect `json:"enchant_effect"`
}

SkillPower represents skill power by level information

type SkillPowerBoost added in v2.1.0

type SkillPowerBoost struct {
	CoefficientStatID    string  `json:"coefficient_stat_id"`
	CoefficientStatValue float64 `json:"coefficient_stat_value"`
}

SkillPowerBoost represents skill power boost ratio information

type StatDetail added in v2.1.0

type StatDetail struct {
	Type  string  `json:"stat_type"`
	Value float64 `json:"stat_value"`
}

type StatMeta added in v2.1.0

type StatMeta struct {
	ID   string `json:"stat_id"`
	Name string `json:"stat_name"`
}

type TitleResponse added in v2.1.0

type TitleResponse struct {
	ID   string `json:"title_id"`
	Name string `json:"title_name"`
}

type UserBasic added in v2.1.0

type UserBasic struct {
	AccountIdentifier
	UserName         string `json:"user_name"`          // Nickname
	PlatformType     string `json:"platform_type"`      // Platform type
	MasteryRankLevel int64  `json:"mastery_rank_level"` // Mastery Rank
	MasteryRankExp   int64  `json:"mastery_rank_exp"`   // Mastery EXP
	TitlePrefix      string `json:"title_prefix_id"`    // Prefix title identifier (Refer to /meta/title API)
	TitleSuffix      string `json:"title_suffix_id"`    // Suffix title identifier (Refer to /meta/title API)
	OSLanguage       string `json:"os_language"`        // OS language settings
	GameLanguage     string `json:"game_language"`      // Game language settings
}

type UserDescendant added in v2.1.0

type UserDescendant struct {
	AccountIdentifier
	UserName          string       `json:"user_name"`           // Nickname
	ID                string       `json:"descendant_id"`       // Equipped descendant identifier
	SlotID            string       `json:"descendant_slot_id"`  // Descendant slot identifier
	Level             int64        `json:"descendant_level"`    // Equipped descendant level
	ModuleMaxCapacity int64        `json:"module_max_capacity"` // Max. equippable module capacity
	ModuleCapacity    int64        `json:"module_capacity"`     // Equipped capacity
	Modules           []ModuleInfo `json:"module"`              // Module information
}

type UserExternalComponent added in v2.1.0

type UserExternalComponent struct {
	AccountIdentifier
	UserName           string                  `json:"user_name"`          // Nickname
	ExternalComponents []ExternalComponentInfo `json:"external_component"` // External component information
}

type UserReactor added in v2.1.0

type UserReactor struct {
	AccountIdentifier
	UserName        string                   `json:"user_name"`                // Nickname
	ID              string                   `json:"reactor_id"`               // Reactor identifier (Refer to /meta/reactor API)
	SlotID          string                   `json:"reactor_slot_id"`          // Reactor slot identifier
	Level           int64                    `json:"reactor_level"`            // Reactor level
	AdditionalStats []ReactorAdditionalStats `json:"reactor_additional_stats"` // Reactor information
	EnchantLevel    int64                    `json:"reactor_enchant_level"`    // Reactor enchantment level
}

type UserWeapon added in v2.1.0

type UserWeapon struct {
	AccountIdentifier
	UserName string       `json:"user_name"` // Nickname
	Weapons  []WeaponInfo `json:"weapon"`    // Weapon information
}

type VoidBattleResponse added in v2.1.0

type VoidBattleResponse struct {
	ID   string `json:"void_battle_id"`
	Name string `json:"void_battle_name"`
}

type Weapon added in v2.1.0

type Weapon struct {
	Name               string       `json:"weapon_name"`
	ID                 string       `json:"weapon_id"`
	ImageURL           string       `json:"image_url"`
	Type               string       `json:"weapon_type"`
	Tier               string       `json:"weapon_tier"`
	Rounds             string       `json:"weapon_rounds_type"`
	BaseStat           []BaseStat   `json:"base_stat"`
	FireArmATK         []FireArmATK `json:"firearm_atk"`
	PerkAbilityName    string       `json:"weapon_perk_ability_name"`
	AbilityDescription string       `json:"weapon_perk_ability_description"`
	AbilityImageURL    string       `json:"weapon_perk_ability_image_url"`
}

type WeaponAdditionalStats added in v2.1.0

type WeaponAdditionalStats struct {
	AdditionalStats     string `json:"additional_stat_name"`  // Weapon random option name
	AdditionalStatValue string `json:"additional_stat_value"` // Weapon random option value
}

type WeaponInfo added in v2.1.0

type WeaponInfo struct {
	ModuleMaxCapacity           int64                   `json:"module_max_capacity"`        // Max. equipable module capacity
	ModuleCapacity              int64                   `json:"module_capacity"`            // Equipped capacity
	SlotID                      string                  `json:"weapon_slot_id"`             // Weapon slot identifier
	ID                          string                  `json:"weapon_id"`                  // Weapon identifier (Refer to /meta/weapon API)
	Level                       int64                   `json:"weapon_level"`               // Weapon level
	PerkAbilityEnchantmentLevel int64                   `json:"perk_ability_enchant_level"` // Weapon Unique Ability enchantment level
	AdditionalStats             []WeaponAdditionalStats `json:"weapon_additional_stat"`     // Weapon random option information
	Module                      []ModuleInfo            `json:"module"`                     // Module information
}

Jump to

Keyboard shortcuts

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