1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Move internal packages to an internal folder

For reference: https://go.dev/doc/go1.4#internalpackages
This commit is contained in:
Frédéric Guillot 2023-08-10 19:46:45 -07:00
parent c234903255
commit 168a870c02
433 changed files with 1121 additions and 1123 deletions

View file

@ -0,0 +1,52 @@
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package pinboard // import "miniflux.app/v2/internal/integration/pinboard"
import (
"fmt"
"net/url"
"miniflux.app/v2/internal/http/client"
)
// Client represents a Pinboard client.
type Client struct {
authToken string
}
// NewClient returns a new Pinboard client.
func NewClient(authToken string) *Client {
return &Client{authToken: authToken}
}
// AddBookmark sends a link to Pinboard.
func (c *Client) AddBookmark(link, title, tags string, markAsUnread bool) error {
if c.authToken == "" {
return fmt.Errorf("pinboard: missing credentials")
}
toRead := "no"
if markAsUnread {
toRead = "yes"
}
values := url.Values{}
values.Add("auth_token", c.authToken)
values.Add("url", link)
values.Add("description", title)
values.Add("tags", tags)
values.Add("toread", toRead)
clt := client.New("https://api.pinboard.in/v1/posts/add?" + values.Encode())
response, err := clt.Get()
if err != nil {
return fmt.Errorf("pinboard: unable to send bookmark: %v", err)
}
if response.HasServerFailure() {
return fmt.Errorf("pinboard: unable to send bookmark, status=%d", response.StatusCode)
}
return nil
}