diff --git a/create_account.go b/create_account.go index 17b5337..32a2632 100644 --- a/create_account.go +++ b/create_account.go @@ -1,8 +1,6 @@ package telegraph import ( - "fmt" - json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) @@ -53,8 +51,7 @@ func CreateAccount(account *Account) (*Account, error) { // or channel. args.Add("author_url", account.AuthorURL) - url := fmt.Sprintf(APIEndpoint, "createAccount") - body, err := request(url, &args) + body, err := request("createAccount", "", args) if err != nil { return nil, err } diff --git a/create_page.go b/create_page.go index 1676430..c3eb344 100644 --- a/create_page.go +++ b/create_page.go @@ -1,7 +1,6 @@ package telegraph import ( - "fmt" "strconv" json "github.com/pquerna/ffjson/ffjson" @@ -75,8 +74,7 @@ func (account *Account) CreatePage(page *Page, returnContent bool) (*Page, error // Content of the page. args.Add("content", string(content)) // required - url := fmt.Sprintf(APIEndpoint, "createPage") - body, err := request(url, &args) + body, err := request("createPage", "", args) if err != nil { return nil, err } diff --git a/edit_account_info.go b/edit_account_info.go index da808ec..28bc197 100644 --- a/edit_account_info.go +++ b/edit_account_info.go @@ -1,8 +1,6 @@ package telegraph import ( - "fmt" - json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) @@ -27,8 +25,7 @@ func (account *Account) EditAccountInfo(update *Account) (*Account, error) { // or channel. args.Add("author_url", update.AuthorURL) - url := fmt.Sprintf(APIEndpoint, "editAccountInfo") - body, err := request(url, &args) + body, err := request("editAccountInfo", "", args) if err != nil { return nil, err } diff --git a/edit_page.go b/edit_page.go index 28f8915..835e990 100644 --- a/edit_page.go +++ b/edit_page.go @@ -1,7 +1,6 @@ package telegraph import ( - "fmt" "strconv" json "github.com/pquerna/ffjson/ffjson" @@ -42,8 +41,7 @@ func (account *Account) EditPage(update *Page, returnContent bool) (*Page, error // Content of the page. args.Add("content", string(content)) // required - url := fmt.Sprintf(PathEndpoint, "editPage", update.Path) - body, err := request(url, &args) + body, err := request("editPage", update.Path, args) if err != nil { return nil, err } diff --git a/get_account_info.go b/get_account_info.go index 78776d7..a0af9ad 100644 --- a/get_account_info.go +++ b/get_account_info.go @@ -20,8 +20,7 @@ func (account *Account) GetAccountInfo(fields ...string) (*Account, error) { // author_name, author_url, auth_url, page_count. args.Add("fields", fmt.Sprint(`["`, strings.Join(fields, `","`), `"]`)) - url := fmt.Sprintf(APIEndpoint, "getAccountInfo") - body, err := request(url, &args) + body, err := request("getAccountInfo", "", args) if err != nil { return nil, err } diff --git a/get_page.go b/get_page.go index 8f410d4..3ee7694 100644 --- a/get_page.go +++ b/get_page.go @@ -1,7 +1,6 @@ package telegraph import ( - "fmt" "strconv" json "github.com/pquerna/ffjson/ffjson" @@ -15,8 +14,7 @@ func GetPage(path string, returnContent bool) (*Page, error) { // If true, content field will be returned in Page object. args.Add("return_content", strconv.FormatBool(returnContent)) - url := fmt.Sprintf(PathEndpoint, "getPage", path) - body, err := request(url, &args) + body, err := request("getPage", path, args) if err != nil { return nil, err } diff --git a/get_page_list.go b/get_page_list.go index a776909..ba0beae 100644 --- a/get_page_list.go +++ b/get_page_list.go @@ -1,7 +1,6 @@ package telegraph import ( - "fmt" "strconv" json "github.com/pquerna/ffjson/ffjson" @@ -32,8 +31,7 @@ func (account *Account) GetPageList(offset, limit int) (*PageList, error) { // Limits the number of pages to be retrieved. args.Add("limit", strconv.Itoa(limit)) - url := fmt.Sprintf(APIEndpoint, "getPageList") - body, err := request(url, &args) + body, err := request("getPageList", "", args) if err != nil { return nil, err } diff --git a/get_views.go b/get_views.go index 27178fd..ac86860 100644 --- a/get_views.go +++ b/get_views.go @@ -1,7 +1,6 @@ package telegraph import ( - "fmt" "strconv" json "github.com/pquerna/ffjson/ffjson" @@ -43,8 +42,7 @@ func GetViews(path string, hour, day, month, year int) (*PageViews, error) { args.Add("year", strconv.Itoa(year)) } - url := fmt.Sprintf(PathEndpoint, "getViews", path) - body, err := request(url, &args) + body, err := request("getViews", path, args) if err != nil { return nil, err } diff --git a/revoke_access_token.go b/revoke_access_token.go index 80c687d..b114480 100644 --- a/revoke_access_token.go +++ b/revoke_access_token.go @@ -1,8 +1,6 @@ package telegraph import ( - "fmt" - json "github.com/pquerna/ffjson/ffjson" http "github.com/valyala/fasthttp" ) @@ -17,8 +15,7 @@ func (account *Account) RevokeAccessToken() (*Account, error) { // Access token of the Telegraph account. args.Add("access_token", account.AccessToken) // required - url := fmt.Sprintf(APIEndpoint, "revokeAccessToken") - body, err := request(url, &args) + body, err := request("revokeAccessToken", "", args) if err != nil { return nil, err }