Пример #1
0
/*
	funcs
*/
func Get(region Entity.Region, apiKey string) (response Response, err error) {
	url := fmt.Sprintf(URL_FORMAT, region.Host, apiKey)
	var b []byte
	if b, err = Util.Download(url); err != nil {
		return
	}

	if err = json.Unmarshal(b, &response); err != nil {
		return
	}

	return
}
Пример #2
0
/*
	funcs
*/
func Get(realm Entity.Realm, url string) (response *Response) {
	var (
		b   []byte
		err error
	)
	b, err = Util.Download(url)
	if err != nil {
		return nil
	}

	err = json.Unmarshal(b, &response)
	if err != nil {
		return nil
	}

	return response
}
Пример #3
0
/*
	funcs
*/
func Get(realm Entity.Realm, apiKey string) (response *Response, err error) {
	url := fmt.Sprintf(URL_FORMAT, realm.Region.Host, realm.Slug, apiKey)
	var b []byte
	if b, err = Util.Download(url); err != nil {
		err = errors.New(fmt.Sprintf("Util.Download() for %s failed (%s)", url, err.Error()))
		return
	}

	if err = json.Unmarshal(b, &response); err != nil {
		return nil, nil
	}

	if len(response.Files) == 0 {
		return nil, nil
	}

	return response, nil
}
Пример #4
0
/*
	funcs
*/
func Get(character Character.Character, apiKey string) (response *Response, err error) {
	url := fmt.Sprintf(URL_FORMAT,
		character.Realm.Region.Host,
		character.Realm.Slug,
		character.Name,
		apiKey,
	)
	var b []byte
	if b, err = Util.Download(url); err != nil {
		err = errors.New(fmt.Sprintf("Util.Download() for %s failed (%s)", url, err.Error()))
		return
	}

	if err = json.Unmarshal(b, &response); err != nil {
		return nil, err
	}

	return response, nil
}