👽 (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
|
||||
// channels. On success, returns an Account object with the regular fields and
|
||||
// an additional access_token field.
|
||||
func CreateAccount(shortName, authorName, authorURL string) (*Account, error) {
|
||||
func CreateAccount(account *Account) (*Account, error) {
|
||||
var args http.Args
|
||||
|
||||
// Account name, helps users with several accounts remember which they are
|
||||
// currently using. Displayed to the user above the "Edit/Publish" button
|
||||
// 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.
|
||||
args.Add("author_name", authorName)
|
||||
args.Add("author_name", account.AuthorName)
|
||||
|
||||
// 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
|
||||
// or channel.
|
||||
args.Add("author_url", authorURL)
|
||||
args.Add("author_url", account.AuthorURL)
|
||||
|
||||
url := fmt.Sprintf(APIEndpoint, "createAccount")
|
||||
body, err := request(url, &args)
|
||||
|
|
|
@ -11,7 +11,8 @@ func TestContentFormatByWTF(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCreateInvalidAccount(t *testing.T) {
|
||||
_, err := CreateAccount("", "", "")
|
||||
var account Account
|
||||
_, err := CreateAccount(&account)
|
||||
if err == nil {
|
||||
t.Error()
|
||||
}
|
||||
|
|
|
@ -23,7 +23,12 @@ func TestContentFormatByBytes(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 {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue