api

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotificationsTypeFollows NotificationsType = "follows"
	NotificationsTypeLikes   NotificationsType = "likes"
	NotificationsTypeRecasts NotificationsType = "recasts"
	NotificationsTypeMention NotificationsType = "mention"
	NotificationsTypeReply   NotificationsType = "reply"

	CastReactionObjTypeLikes   CastReactionObjType = "likes"
	CastReactionObjTypeRecasts CastReactionObjType = "recasts"
)

Variables

This section is empty.

Functions

func SetSigner

func SetSigner(s *Signer)

Types

type BulkUsersResponse

type BulkUsersResponse struct {
	Users []*User `json:"users"`
}

type Cast

type Cast struct {
	Object       string `json:"object"`
	Hash         string `json:"hash"`
	ThreadHash   string `json:"thread_hash"`
	ParentHash   string `json:"parent_hash"`
	ParentURL    string `json:"parent_url"`
	ParentAuthor struct {
		FID int32
	} `json:"parent_author"`
	Author    User      `json:"author"`
	Text      string    `json:"text"`
	Timestamp time.Time `json:"timestamp"`
	Embeds    []Embed   `json:"embeds"`
	Reactions Reactions `json:"reactions"`
	Replies   struct {
		Count int32 `json:"count"`
	}
	DirectReplies []*Cast `json:"direct_replies"`
	ViewerContext struct {
		Liked    bool `json:"liked"`
		Recasted bool `json:"recasted"`
	} `json:"viewer_context"`
}

func (Cast) HumanTime

func (c Cast) HumanTime() string

type CastClient

type CastClient struct {
	// contains filtered or unexported fields
}

type CastPayload

type CastPayload struct {
	SignerUUID      string  `json:"signer_uuid"`
	Text            string  `json:"text"`
	Parent          string  `json:"parent"`
	ChannelID       string  `json:"channel_id"`
	Idem            string  `json:"idem"`
	ParentAuthorFID uint64  `json:"parent_author_fid"`
	Embeds          []Embed `json:"embeds"`
}

type CastReactionObjType added in v0.1.4

type CastReactionObjType string

type Channel

type Channel struct {
	ID            string `json:"id"`
	URL           string `json:"url"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	FollowerCount int32  `json:"follower_count"`
	Object        string `json:"object"`
	ImageURL      string `json:"image_url"`
	CreatedAt     uint   `json:"created_at"`
	ParentURL     string `json:"parent_url"`
	Lead          User   `json:"lead"`
	Hosts         []User `json:"hosts"`
}

type ChannelResponse

type ChannelResponse struct {
	Channel       *Channel      `json:"channel"`
	ViewerContext ViewerContext `json:"viewer_context"`
}

type ChannelsResponse

type ChannelsResponse struct {
	Channels []*Channel
	Next     struct {
		Cursor *string `json:"cursor"`
	} `json:"next"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg *config.Config) *Client

func (*Client) FetchAllChannels

func (c *Client) FetchAllChannels() error

func (*Client) GetCachedChannelIds

func (c *Client) GetCachedChannelIds() ([]string, error)

func (*Client) GetCastWithReplies

func (c *Client) GetCastWithReplies(signer *Signer, hash string) (*Cast, error)

func (*Client) GetChannelById

func (c *Client) GetChannelById(q string) (*Channel, error)

func (*Client) GetChannelByParentUrl

func (c *Client) GetChannelByParentUrl(q string) (*Channel, error)

func (*Client) GetChannelUrlById

func (c *Client) GetChannelUrlById(id string) string

func (*Client) GetFeed

func (c *Client) GetFeed(r *FeedRequest) (*FeedResponse, error)

func (*Client) GetNotifications added in v0.1.4

func (c *Client) GetNotifications(fid uint64, opts ...RequestOption) (*NotificationsResponse, error)

func (*Client) GetUserByFID

func (c *Client) GetUserByFID(fid uint64, viewer uint64) (*User, error)

func (*Client) GetUserChannels

func (c *Client) GetUserChannels(fid uint64, active bool, opts ...RequestOption) ([]*Channel, error)

func (*Client) PostCast

func (c *Client) PostCast(signer *Signer, text, parent, channel string, parent_fid uint64) (*PostCastResponse, error)

func (*Client) React

func (c *Client) React(s *Signer, cast string, t ReactionType) error

func (*Client) SearchChannel

func (c *Client) SearchChannel(q string) ([]*Channel, error)

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(key string)

func (*Client) SetOptions

func (c *Client) SetOptions(opts ...RequestOption)

type Conversation

type Conversation struct {
	Cast
}

type ConversationResponse

type ConversationResponse struct {
	Conversation *struct {
		Cast Cast `json:"cast"`
	} `json:"conversation"`
}

type Embed

type Embed struct {
	URL    string `json:"url"`
	CastId struct {
		Hash string `json:"hash"`
		FID  int32  `json:"fid"`
	}
}

type FeedRequest

type FeedRequest struct {
	FeedType   string
	FID        uint64
	FilterType string
	ParentURL  string
	FIDs       []uint64
	Cursor     string
	Limit      uint64
	ViewerFID  uint64
}

type FeedResponse

type FeedResponse struct {
	Casts []*Cast
}

type FollowNotification added in v0.1.4

type FollowNotification struct {
	Object string `json:"object"`
	User   User   `json:"user"`
}

type NeynarError

type NeynarError struct {
	// contains filtered or unexported fields
}

func (NeynarError) Error

func (e NeynarError) Error() string

type Notification added in v0.1.4

type Notification struct {
	Object              string                 `json:"object"`
	MostRecentTimestamp time.Time              `json:"most_recent_timestamp"`
	Type                NotificationsType      `json:"type"`
	Cast                *Cast                  `json:"cast"`
	Follows             []FollowNotification   `json:"follows"`
	Reactions           []ReactionNotification `json:"reactions"`
}

type NotificationCast added in v0.1.4

type NotificationCast struct {
	Cast // may be cast_dehydrated which only has hash, specifically for reactions
}

type NotificationsResponse added in v0.1.4

type NotificationsResponse struct {
	Notifications []*Notification `json:"notifications"`
	Next          struct {
		Cursor *string `json:"cursor"`
	}
}

type NotificationsType added in v0.1.4

type NotificationsType string

type PostCastResponse

type PostCastResponse struct {
	Success bool
	Cast    Cast
}

type Profile

type Profile struct {
	Bio struct {
		Text string
	}
}

type Reaction

type Reaction struct {
	FID   int32  `json:"fid"`
	FName string `json:"fname"`
}

type ReactionNotification added in v0.1.4

type ReactionNotification struct {
	Object CastReactionObjType `json:"object"`
	Cast   NotificationCast    `json:"cast"`
	User   User                `json:"user"`
}

type ReactionRequest

type ReactionRequest struct {
	SignerUUID   string       `json:"signer_uuid"`
	ReactionType ReactionType `json:"reaction_type"`
	Target       string       `json:"target"`
}

type ReactionResponse

type ReactionResponse struct {
	Success bool
	Message string
}

type ReactionType

type ReactionType string
const (
	Like   ReactionType = "like"
	Recast ReactionType = "recast"
)

type Reactions

type Reactions struct {
	LikesCount   uint       `json:"likes_count"`
	RecastsCount uint       `json:"recasts_count"`
	Likes        []Reaction `json:"likes"`
	Recasts      []Reaction `json:"recasts"`
}

type RequestOption

type RequestOption func(*http.Request)

func WithFID

func WithFID(fid uint64) RequestOption

func WithLimit

func WithLimit(limit int) RequestOption

func WithQuery

func WithQuery(key, value string) RequestOption

type Signer

type Signer struct {
	FID         uint64
	UUID        string
	Username    string
	DisplayName string
	PublicKey   string
}

func GetSigner

func GetSigner(pk string) *Signer

type User

type User struct {
	FID               uint64            `json:"fid"`
	Username          string            `json:"username"`
	DisplayName       string            `json:"display_name"`
	PfpURL            string            `json:"pfp_url"`
	Profile           Profile           `json:"profile"`
	FollowerCount     int32             `json:"follower_count"`
	FollowingCount    int32             `json:"following_count"`
	Verifications     []string          `json:"verifications"`
	VerifiedAddresses VerifiedAddresses `json:"verified_addresses"`
	ActiveStatus      string            `json:"active_status"`
	PowerBadge        bool              `json:"power_badge"`
	ViewerContext     ViewerContext     `json:"viewer_context"`
}

type VerifiedAddresses

type VerifiedAddresses struct {
	EthAddresses []string `json:"eth_addresses"`
	SolAddresses []string `json:"sol_addresses"`
}

type ViewerContext

type ViewerContext struct {
	Following  bool `json:"following"`
	FollowedBy bool `json:"followed_by"`
}

Jump to

Keyboard shortcuts

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