sharedapi

package
v0.0.0-...-5e36e8a Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthCallbackAddr : コールバックを待つサーバーのアドレス
	AuthCallbackAddr = "localhost:3000"
	// AuthCallbackURL : コールバックURL
	AuthCallbackURL = "http://localhost:3000/callback"
)

Variables

This section is empty.

Functions

func ConvertHttpToWebsocket

func ConvertHttpToWebsocket(rawUrl string) (*url.URL, error)

ConvertHttpToWebsocket : スキーマをWSに変換

func PrintAuthenticateURL

func PrintAuthenticateURL(w io.Writer, u string)

PrintAuthenticateURL : 認証用URLを出力

func RecieveAuthenticateCode

func RecieveAuthenticateCode(queryName string, validator func(string) bool) (string, error)

RecieveAuthenticateCode : サーバーを建てて認証コードを受け取る

Types

type Account

type Account struct {
	// ID : ユーザーID
	ID string
	// Username : ユーザー名 + ドメイン名
	Username string
	// DisplayName : 表示名
	DisplayName string
	// Private : 非公開アカウントか
	Private bool
	// Bot : ボットアカウントか
	Bot bool
	// Verified : 認証アカウントか
	Verified bool
	// BIO : 自己紹介文
	BIO string
	// CreatedAt : アカウント作成日
	CreatedAt time.Time
	// FollowersCount : フォロワー数
	FollowersCount int
	// FollowingCount : フォロイー数
	FollowingCount int
	// PostsCount : 投稿数
	PostsCount int
	// Profiles : プロフィール一覧
	Profiles []Profile
}

Account : アカウント

type Announcement

type Announcement struct {
	ID          string
	PublishedAt time.Time
	UpdatedAt   *time.Time
	Title       string
	Text        string
}

Announcement : サービスからのお知らせ

type Client

type Client interface {
	// IsStreamingSupported : ストリーミングをサポートしているか
	IsStreamingSupported() bool
	// GetVisibilityList : 公開範囲の種類を取得
	GetVisibilityList() []string
	// CreatePostURL : 投稿のURLを作成
	CreatePostURL(post *Post) (string, error)

	// RegisterNewApplication : サーバーにアプリケーションを登録
	RegisterNewApplication() (string, string, error)
	// Authenticate : アプリケーション認証を行なってアクセストークンを取得
	Authenticate(w io.Writer) (string, error)

	// GetAnnouncements : サーバーからのお知らせを取得
	GetAnnouncements() ([]*Announcement, error)

	// CreatePost : 投稿を作成
	CreatePost(opts *CreatePostOpts) (*Post, error)
	// QuotePost : 投稿を引用
	QuotePost(id string, opts *CreatePostOpts) (*Post, error)
	// ReplyPost : 投稿に返信
	ReplyPost(id string, opts *CreatePostOpts) (*Post, error)
	// DeletePost : 投稿を削除
	DeletePost(id string) error

	// UploadMedia : メディアをアップロード (画像のみ対応)
	UploadMedia(filename string, src io.Reader) (string, error)

	// Reaction : 投稿にリアクション
	Reaction(id string, reactionName string) (*Post, error)
	// Unreaction : リアクションを削除
	Unreaction(id string) (*Post, error)
	// Repost : 投稿をリポスト
	Repost(id string) (*Post, error)
	// Unrepost : リポストを削除
	Unrepost(id string) (*Post, error)
	// Bookmark : 投稿をブックマーク
	Bookmark(id string) (*Post, error)
	// Unbookmark : ブックマークを解除
	Unbookmark(id string) (*Post, error)

	// SearchAccounts : アカウントを検索
	SearchAccounts(query string, limit int) ([]*Account, error)
	// GetAccount : アカウント情報を取得
	GetAccount(id string) (*Account, error)
	// GetLoginAccount : ログイン中のアカウント情報を取得
	GetLoginAccount() (*Account, error)
	// GetRelationships : ユーザーとの関係を取得
	GetRelationships(ids []string) ([]*Relationship, error)
	// GetPosts : アカウントの投稿を取得
	GetPosts(id string, limit int) ([]*Post, error)

	// Follow : ユーザーをフォロー
	Follow(id string) (*Relationship, error)
	// Unfollow : ユーザーのフォローを解除
	Unfollow(id string) (*Relationship, error)
	// Block : ユーザーをブロック
	Block(id string) (*Relationship, error)
	// Unblock : ユーザーのブロックを解除
	Unblock(id string) (*Relationship, error)
	// Mute : ユーザーをミュート
	Mute(id string) (*Relationship, error)
	// Unmute : ユーザーをミュート
	Unmute(id string) (*Relationship, error)

	// GetGlobalTimeline : グローバルタイムラインを取得
	GetGlobalTimeline(sinceID string, limit int) ([]*Post, error)
	// GetLocalTimeline : ローカルタイムラインを取得
	GetLocalTimeline(sinceID string, limit int) ([]*Post, error)
	// GetHomeTimeline : ホームタイムラインを取得
	GetHomeTimeline(sinceID string, limit int) ([]*Post, error)
	// GetListTimeline : リストタイムラインを取得
	GetListTimeline(listID, sinceID string, limit int) ([]*Post, error)

	// StreamingGlobalTimeline : グローバルタイムラインをストリーミング
	StreamingGlobalTimeline(opts *StreamingTimelineOpts) error
	// StreamingLocalTimeline : ローカルタイムラインをストリーミング
	StreamingLocalTimeline(opts *StreamingTimelineOpts) error
	// StreamingHomeTimeline : ホームタイムラインをストリーミング
	StreamingHomeTimeline(opts *StreamingTimelineOpts) error
	// StreamingListTimeline : リストタイムラインをストリーミング
	StreamingListTimeline(opts *StreamingListTimelineOpts) error
}

type ClientCredential

type ClientCredential struct {
	// Service : サービス種別
	Service string
	Name    string
	ID      string
	Secret  string
}

ClientCredential : クライアントの資格情報

func (*ClientCredential) IsUncertified

func (c *ClientCredential) IsUncertified() bool

IsUncertified : 資格情報が無いかどうか

type CreatePostOpts

type CreatePostOpts struct {
	// Text : 本文
	Text string
	// MediaIDs : 添付するメディアに対応するID
	MediaIDs []string
	// Visibility : 公開範囲
	Visibility string
	// Sensitive : センシティブな内容を含むか
	Sensitive bool
}

CreatePostOpts : 投稿の作成に関する設定

type DecodeError

type DecodeError struct {
	Response interface{}
	URL      string
	Err      error
}

func (*DecodeError) Error

func (d *DecodeError) Error() string

type Endpoint

type Endpoint string

func (Endpoint) URL

func (e Endpoint) URL(host string, pathParams url.Values) string

type HTTPError

type HTTPError struct {
	Status     string
	StatusCode int
	URL        string
}

func NewHTTPError

func NewHTTPError(res *http.Response) *HTTPError

func (*HTTPError) Error

func (h *HTTPError) Error() string

type Mention

type Mention struct {
	ID          string
	DisplayName string
	Username    string
}

Mention : メンション先

type Post

type Post struct {
	// ID : 投稿のID
	ID string
	// CreatedAt : 投稿日
	CreatedAt time.Time
	// Visibility : 公開範囲
	Visibility string
	// Sensitive : センシティブな内容を含むか
	Sensitive bool
	// RepostCount : リポスト数
	RepostCount int
	// Reactions : リアクション
	Reactions []Reaction
	// Reposted : リポスト済か
	Reposted bool
	// Bookmarked : ブックマーク済か
	Bookmarked bool
	// Text : 本文
	Text string
	// Mentions : メンション
	Mentions []Mention
	// Tags : ハッシュタグ
	Tags []Tag
	// Via : 投稿元
	Via string
	// Reference : 引用元
	Reference *Post
	// Author : 投稿者
	Author *Account
}

Post : 投稿

type Profile

type Profile struct {
	Label string
	Value string
}

Profile : プロフィール

type Reaction

type Reaction struct {
	Name    string
	Count   int
	Reacted bool
}

Reaction : リアクション詳細

type Relationship

type Relationship struct {
	// ID : ユーザーID
	ID string
	// Following : フォローしているか
	Following bool
	// FollowedBy : フォローされているか
	FollowedBy bool
	// Blocking : ブロックしているか
	Blocking bool
	// BlockedBy : ブロックされているか
	BlockedBy bool
	// Muting : ミュートしているか
	Muting bool
	// Requested : フォロー申請しているか
	Requested bool
}

Relationship : ユーザーとの関係

type RequestError

type RequestError struct {
	URL string
	Err error
}

func (RequestError) Error

func (r RequestError) Error() string

type StreamingListTimelineOpts

type StreamingListTimelineOpts struct {
	*StreamingTimelineOpts
	ListID string
}

StreamingListTimelineOpts : リストTLストリーミング関数のオプション

type StreamingTimelineOpts

type StreamingTimelineOpts struct {
	Context  context.Context
	OnUpdate func(post *Post)
	OnDelete func(id string)
	OnError  func(err error)
}

StreamingTimelineOpts : TLストリーミング関数の共通オプション

type Tag

type Tag struct {
	Name string
	URL  string
}

Tag : ハッシュタグ

type User

type User struct {
	UserID   string
	UserName string
	Token    string
}

User : ユーザー情報

type UserCredential

type UserCredential struct {
	// Server : 接続先サーバーのURL
	Server string
	// Token : トークン
	Token string
}

UserCredential : ユーザーの資格情報

Jump to

Keyboard shortcuts

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