connector

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package connector contains functions that interface with Pocket's API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJSON

func GetJSON(params models.PocketParam, pocketClient *PocketClient) ([]byte, error)

GetJSON combines given request params and Pocket client information into a single JSON byte array

Types

type PocketClient

type PocketClient struct {
	ConsumerKey string `json:"consumer_key"`
	AccessToken string `json:"access_token"`
	// contains filtered or unexported fields
}

PocketClient represents a client connection to Pocket

func CreatePocketClient

func CreatePocketClient(consumerKey string, accessToken string) *PocketClient

CreatePocketClient creates a PocketClient instance that can be used to interface with Pocket API functions

func (*PocketClient) Add

func (client *PocketClient) Add(params models.PocketAdd) (*models.PocketAddResult, error)

Add calls Pocket API's Add method to add the URL in parameter to the Pocket list of the user associated with access token

func (*PocketClient) Authorize

func (client *PocketClient) Authorize(code string) (string, error)

Authorize authorizes a user associated with an OAuth request token with the Pocket API and returns an access token that can then be used to make calls to the Pocket API for that user

func (*PocketClient) Modify

func (client *PocketClient) Modify(params models.PocketModify) (*models.PocketModifyResult, error)

Modify calls Pocket API's Modify method with provided arguments from actions parameter

func (*PocketClient) RequestOAuthCode

func (client *PocketClient) RequestOAuthCode(redirectURI string) (string, error)

RequestOAuthCode requests an OAuth request token from Pocket's API to provide to a user

func (*PocketClient) Retrieve

func (client *PocketClient) Retrieve(params models.PocketRetrieve) (*models.PocketRetrieveResult, error)

Retrieve calls Pocket API's Retrieve method given arguments in params

func (*PocketClient) SetAccessToken

func (client *PocketClient) SetAccessToken(accessToken string)

SetAccessToken sets the access token on a PocketClient instance

type PocketConnector

type PocketConnector interface {
	SetAccessToken(accessToken string)
	Retrieve(params models.PocketRetrieve) (*models.PocketRetrieveResult, error)
	Add(params models.PocketAdd) (*models.PocketAddResult, error)
	Modify(params models.PocketModify) (*models.PocketModifyResult, error)
	RequestOAuthCode(redirectURI string) (string, error)
	Authorize(code string) (string, error)
}

PocketConnector is an interface for methods that call Pocket API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL