aboutsummaryrefslogtreecommitdiffhomepage
path: root/integration/pocket/pocket.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-05-20 15:29:14 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-05-20 15:29:14 -0700
commit7f2fd1fdd85a62b187ad901d4917e561e39e37b2 (patch)
tree635fd7622cda67a0b9a422e093edee0b2bbc7399 /integration/pocket/pocket.go
parent0f3f5e442f81d37a03618d0df5ea8f0524a24029 (diff)
Add Pocket authorization flow in the user interface
Diffstat (limited to 'integration/pocket/pocket.go')
-rw-r--r--integration/pocket/pocket.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/integration/pocket/pocket.go b/integration/pocket/pocket.go
index a46cd30..16a826c 100644
--- a/integration/pocket/pocket.go
+++ b/integration/pocket/pocket.go
@@ -1,4 +1,4 @@
-// Copyright 2017 Frédéric Guillot. All rights reserved.
+// Copyright 2018 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
@@ -16,21 +16,20 @@ type Client struct {
consumerKey string
}
-// Parameters for a Pocket add call.
-type Parameters struct {
- AccessToken string `json:"access_token"`
- ConsumerKey string `json:"consumer_key"`
- Title string `json:"title,omitempty"`
- URL string `json:"url,omitempty"`
-}
-
// AddURL sends a single link to Pocket.
func (c *Client) AddURL(link, title string) error {
if c.consumerKey == "" || c.accessToken == "" {
return fmt.Errorf("pocket: missing credentials")
}
- parameters := &Parameters{
+ type body struct {
+ AccessToken string `json:"access_token"`
+ ConsumerKey string `json:"consumer_key"`
+ Title string `json:"title,omitempty"`
+ URL string `json:"url"`
+ }
+
+ data := &body{
AccessToken: c.accessToken,
ConsumerKey: c.consumerKey,
Title: title,
@@ -38,12 +37,16 @@ func (c *Client) AddURL(link, title string) error {
}
clt := client.New("https://getpocket.com/v3/add")
- response, err := clt.PostJSON(parameters)
+ response, err := clt.PostJSON(data)
+ if err != nil {
+ return fmt.Errorf("pocket: unable to send url: %v", err)
+ }
+
if response.HasServerFailure() {
return fmt.Errorf("pocket: unable to send url, status=%d", response.StatusCode)
}
- return err
+ return nil
}
// NewClient returns a new Pocket client.