mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Move internal packages to an internal folder
For reference: https://go.dev/doc/go1.4#internalpackages
This commit is contained in:
parent
c234903255
commit
168a870c02
433 changed files with 1121 additions and 1123 deletions
|
@ -1,54 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package notion
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"miniflux.app/v2/http/client"
|
||||
)
|
||||
|
||||
// Client represents a Notion client.
|
||||
type Client struct {
|
||||
token string
|
||||
pageID string
|
||||
}
|
||||
|
||||
// NewClient returns a new Notion client.
|
||||
func NewClient(token, pageID string) *Client {
|
||||
return &Client{token, pageID}
|
||||
}
|
||||
|
||||
func (c *Client) AddEntry(entryURL string, entryTitle string) error {
|
||||
if c.token == "" || c.pageID == "" {
|
||||
return fmt.Errorf("notion: missing credentials")
|
||||
}
|
||||
clt := client.New("https://api.notion.com/v1/blocks/" + c.pageID + "/children")
|
||||
block := &Data{
|
||||
Children: []Block{
|
||||
{
|
||||
Object: "block",
|
||||
Type: "bookmark",
|
||||
Bookmark: Bookmark{
|
||||
Caption: []interface{}{},
|
||||
URL: entryURL,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
clt.WithAuthorization("Bearer " + c.token)
|
||||
customHeaders := map[string]string{
|
||||
"Notion-Version": "2022-06-28",
|
||||
}
|
||||
clt.WithCustomHeaders(customHeaders)
|
||||
response, error := clt.PatchJSON(block)
|
||||
if error != nil {
|
||||
return fmt.Errorf("notion: unable to patch entry: %v", error)
|
||||
}
|
||||
|
||||
if response.HasServerFailure() {
|
||||
return fmt.Errorf("notion: request failed, status=%d", response.StatusCode)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue