👽 (Maybe) last library API changes
This commit is contained in:
parent
f3eedf50d4
commit
2d2e1d9205
|
@ -13,21 +13,21 @@ import (
|
||||||
// to keep individual author names and profile links for each of their
|
// to keep individual author names and profile links for each of their
|
||||||
// channels. On success, returns an Account object with the regular fields and
|
// channels. On success, returns an Account object with the regular fields and
|
||||||
// an additional access_token field.
|
// an additional access_token field.
|
||||||
func CreateAccount(shortName, authorName, authorURL string) (*Account, error) {
|
func CreateAccount(account *Account) (*Account, error) {
|
||||||
var args http.Args
|
var args http.Args
|
||||||
|
|
||||||
// Account name, helps users with several accounts remember which they are
|
// Account name, helps users with several accounts remember which they are
|
||||||
// currently using. Displayed to the user above the "Edit/Publish" button
|
// currently using. Displayed to the user above the "Edit/Publish" button
|
||||||
// on Telegra.ph, other users don't see this name.
|
// on Telegra.ph, other users don't see this name.
|
||||||
args.Add("short_name", shortName) // required
|
args.Add("short_name", account.ShortName) // required
|
||||||
|
|
||||||
// Default author name used when creating new articles.
|
// Default author name used when creating new articles.
|
||||||
args.Add("author_name", authorName)
|
args.Add("author_name", account.AuthorName)
|
||||||
|
|
||||||
// Default profile link, opened when users click on the author's name
|
// Default profile link, opened when users click on the author's name
|
||||||
// below the title. Can be any link, not necessarily to a Telegram profile
|
// below the title. Can be any link, not necessarily to a Telegram profile
|
||||||
// or channel.
|
// or channel.
|
||||||
args.Add("author_url", authorURL)
|
args.Add("author_url", account.AuthorURL)
|
||||||
|
|
||||||
url := fmt.Sprintf(APIEndpoint, "createAccount")
|
url := fmt.Sprintf(APIEndpoint, "createAccount")
|
||||||
body, err := request(url, &args)
|
body, err := request(url, &args)
|
||||||
|
|
|
@ -11,7 +11,8 @@ func TestContentFormatByWTF(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateInvalidAccount(t *testing.T) {
|
func TestCreateInvalidAccount(t *testing.T) {
|
||||||
_, err := CreateAccount("", "", "")
|
var account Account
|
||||||
|
_, err := CreateAccount(&account)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,12 @@ func TestContentFormatByBytes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateValidAccount(t *testing.T) {
|
func TestCreateValidAccount(t *testing.T) {
|
||||||
account, err := CreateAccount("Sandbox", "Anonymous", "")
|
newAccount := &Account{
|
||||||
|
ShortName: "Sandbox",
|
||||||
|
AuthorName: "Anonymous",
|
||||||
|
}
|
||||||
|
|
||||||
|
account, err := CreateAccount(newAccount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue