👽 (Maybe) last library API changes

This commit is contained in:
Maxim Lebedev 2017-07-01 17:16:17 +05:00
parent f3eedf50d4
commit 2d2e1d9205
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
3 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -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()
}

View File

@ -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)
}