types.go
changeset 70 fbc089e7249d
parent 66 965586c1e3ed
child 74 ba06092b91a6
equal deleted inserted replaced
69:3474d0f36259 70:fbc089e7249d
     3 import (
     3 import (
     4 	"time"
     4 	"time"
     5 )
     5 )
     6 
     6 
     7 type Gondole struct {
     7 type Gondole struct {
     8 	Name   string
     8 	Name    string
     9 	ID     string
     9 	ID      string
    10 	Secret string
    10 	Secret  string
       
    11 	APIBase string
    11 }
    12 }
    12 
    13 
    13 type Client struct {
    14 type Client struct {
    14 	BaseURL     string
    15 	BaseURL     string
    15 	BearerToken string
    16 	BearerToken string
    16 }
    17 }
    17 
    18 
    18 /*
    19 /*
    19 
       
    20 Entities:
    20 Entities:
    21 
    21 
    22 Everything manipulated/returned by the API
    22 Everything manipulated/returned by the API
    23 */
    23 */
    24 
    24 
       
    25 // Account represents a Mastodon account entity
    25 type Account struct {
    26 type Account struct {
    26 	ID          string
    27 	ID             int    `json:"id"`
    27 	Username    string
    28 	Username       string `json:"username"`
    28 	Acct        string
    29 	Acct           string `json:"acct"`
    29 	DisplayName string
    30 	DisplayName    string `json:"display_name"`
    30 	Note        string
    31 	Note           string `json:"note"`
    31 	URL         string
    32 	URL            string `json:"url"`
    32 	Avatar      string
    33 	Avatar         string `json:"avatar"`
    33 	Header      string
    34 	Header         string `json:"header"`
    34 	Locked      bool
    35 	Locked         bool   `json:"locked"`
    35 	Followers   int
    36 	CreatedAt      string `json:"created_at"`
    36 	Followings  int
    37 	FollowersCount int    `json:"followers_count"`
    37 	Statuses    int
    38 	FollowingCount int    `json:"following_count"`
       
    39 	StatusesCount  int    `json:"statuses_count"`
    38 }
    40 }
    39 
    41 
       
    42 // Application represents a Mastodon application entity
    40 type Application struct {
    43 type Application struct {
    41 	Name    string
    44 	Name    string `json:"name"`
    42 	Website string
    45 	Website string `json:"website"`
    43 }
    46 }
    44 
    47 
    45 type Attachement struct {
    48 // Attachment represents a Mastodon attachement entity
    46 	ID         string
    49 type Attachment struct {
    47 	Type       string
    50 	ID         int    `json:"iD"`
    48 	URL        string
    51 	Type       string `json:"type"`
    49 	RemoteURL  string
    52 	URL        string `json:"url"`
    50 	PreviewURL string
    53 	RemoteURL  string `json:"remote_url"`
    51 	TextURL    string
    54 	PreviewURL string `json:"preview_url"`
       
    55 	TextURL    string `json:"text_url"`
    52 }
    56 }
    53 
    57 
       
    58 /*
       
    59 // Card represents a Mastodon card entity
    54 type Card struct {
    60 type Card struct {
    55 	URL         string
    61 	URL         string       `json:"url"`
    56 	Title       string
    62 	Title       string       `json:"title"`
    57 	Description string
    63 	Description string       `json:"description"`
    58 	Image       string
    64 	Image       *interface{} `json:"image"`
       
    65 }
       
    66 */
       
    67 
       
    68 // Context represents a Mastodon context entity
       
    69 type Context struct {
       
    70 	Ancestors   []Status `json:"ancestors"`
       
    71 	Descendents []Status `json:"descendents"`
    59 }
    72 }
    60 
    73 
    61 type Context struct {
    74 // Error represents a Mastodon error entity
    62 	Ancestors   []Status
    75 type Error struct {
    63 	Descendents []Status
    76 	Text string `json:"error"`
    64 }
    77 }
    65 
    78 
    66 type Error struct {
    79 // Instance represents a Mastodon instance entity
    67 	Text string
    80 type Instance struct {
       
    81 	URI         string `json:"uri"`
       
    82 	Title       string `json:"title"`
       
    83 	Description string `json:"description"`
       
    84 	Email       string `json:"email"`
    68 }
    85 }
    69 
    86 
    70 type Instance struct {
    87 // Mention represents a Mastodon mention entity
    71 	URI         string
    88 type Mention struct {
    72 	Title       string
    89 	ID       int    `json:"id"`
    73 	Description string
    90 	URL      string `json:"url"`
    74 	Email       string
    91 	Username string `json:"username"`
       
    92 	Acct     string `json:"acct"`
    75 }
    93 }
    76 
    94 
    77 type Mention struct {
    95 // Notification represents a Mastodon notification entity
    78 	ID       string
    96 type Notification struct {
    79 	URL      string
    97 	ID        int      `json:"id"`
    80 	Username string
    98 	Type      string   `json:"type"`
    81 	Acct     string
    99 	CreatedAt string   `json:"created_at"`
       
   100 	Account   *Account `json:"account"`
       
   101 	Status    *Status  `json:"status"`
    82 }
   102 }
    83 
   103 
    84 type Notification struct {
   104 // Relationship represents a Mastodon relationship entity
    85 	ID        string
   105 type Relationship struct {
    86 	Type      string
   106 	Following  bool `json:"following"`
    87 	CreatedAt time.Time
   107 	FollowedBy bool `json:"followed_by"`
    88 	Account   *Account
   108 	Blocking   bool `json:"blocking"`
    89 	Status    *Status
   109 	Muting     bool `json:"muting"`
       
   110 	Requested  bool `json:"requested"`
    90 }
   111 }
    91 
   112 
    92 type Relationship struct {
   113 // Report represents a Mastodon report entity
    93 	Following  bool
       
    94 	FollowedBy bool
       
    95 	Blocking   bool
       
    96 	Muting     bool
       
    97 	Requested  bool
       
    98 }
       
    99 type Report struct {
   114 type Report struct {
   100 	ID          int64
   115 	ID          int    `json:"iD"`
   101 	ActionTaken string
   116 	ActionTaken string `json:"action_taken"`
   102 }
   117 }
   103 
   118 
   104 type Result struct {
   119 // Results represents a Mastodon results entity
   105 	Accounts []Account
   120 type Results struct {
   106 	Statutes []Status
   121 	Accounts []Account `json:"accounts"`
   107 	Hashtags []Tag
   122 	Statuses []Status  `json:"statuses"`
       
   123 	Hashtags []string  `json:"hashtags"`
   108 }
   124 }
   109 
   125 
       
   126 // Status represents a Mastodon status entity
   110 type Status struct {
   127 type Status struct {
   111 	ID                 string
   128 	ID                 int          `json:"id"`
   112 	URI                string
   129 	URI                string       `json:"uri"`
   113 	URL                string
   130 	URL                string       `json:"url"`
   114 	Account            *Account
   131 	Account            *Account     `json:"account"`
   115 	InReplyToId        string
   132 	InReplyToID        int          `json:"in_reply_to_id"`
   116 	InReplyToAccountID string
   133 	InReplyToAccountID int          `json:"in_reply_to_account_id"`
   117 	Reblog             *Status
   134 	Reblog             *Status      `json:"reblog"`
   118 	Content            string
   135 	Content            string       `json:"content"`
   119 	CreatedAT          time.Time
   136 	CreatedAt          time.Time    `json:"created_at"`
   120 	Reblogs            int
   137 	ReblogsCount       int          `json:"reblogs_count"`
   121 	Favourites         int
   138 	FavouritesCount    int          `json:"favourites_count"`
   122 	Reblogged          bool
   139 	Reblogged          bool         `json:"reblogged"`
   123 	Favourited         bool
   140 	Favourited         bool         `json:"favourited"`
   124 	Sensitive          bool
   141 	Sensitive          bool         `json:"sensitive"`
   125 	SpoilerText        string
   142 	SpoilerText        string       `json:"spoiler_text"`
   126 	Visibility         string
   143 	Visibility         string       `json:"visibility"`
   127 	MediaAttachments   []Attachement
   144 	MediaAttachments   []Attachment `json:"media_attachments"`
   128 	Mentions           []Mention
   145 	Mentions           []Mention    `json:"mentions"`
   129 	Tags               []Tag
   146 	Tags               []Tag        `json:"tags"`
   130 	App                Application
   147 	Application        Application  `json:"application"`
   131 }
   148 }
   132 
   149 
       
   150 // Tag represents a Mastodon tag entity
   133 type Tag struct {
   151 type Tag struct {
   134 	Name string
   152 	Name string `json:"name"`
   135 	URL  string
   153 	URL  string `json:"url"`
   136 }
   154 }