Documentation ¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func Int(v int) *int
- func String(v string) *string
- func ValidateDate(date *string) error
- func WithEndpoint(endpoint string)
- type API
- type APIs
- type CallbackResponse
- type Category
- type CategoryResult
- type Channel
- type ChannelAddPending
- type ChannelAddSuccess
- type ChannelAvgReach
- type ChannelAvgReachResponse
- type ChannelErr
- type ChannelErrResponse
- type ChannelForwards
- type ChannelForwardsExtended
- type ChannelForwardsResponse
- type ChannelForwardsResponseExtended
- type ChannelMedia
- type ChannelMentionsExtended
- type ChannelMentionsResponse
- type ChannelMentionsResponseExtended
- type ChannelMentionsResult
- type ChannelPostsResponse
- type ChannelPostsResponseItem
- type ChannelPostsResult
- type ChannelPostsWithChannelResponse
- type ChannelPostsWithChannelResponseItem
- type ChannelPostsWithChannelResult
- type ChannelResponse
- type ChannelResponseResult
- type ChannelSearch
- type ChannelSearchItem
- type ChannelSearchResult
- type ChannelStatResponse
- type ChannelStatResult
- type ChannelSubscribers
- type ChannelSubscribersResponse
- type ChannelViews
- type ChannelViewsResponse
- type Client
- type ClientOption
- type Country
- type CountryResult
- type ErrorResult
- type Forward
- type ForwardItem
- type GetCallbackResponse
- type Keyword
- type Language
- type LanguageResult
- type Media
- type Mention
- type MentionItem
- type PostResponse
- type PostResult
- type PostSearchExtendedChannel
- type PostSearchExtendedResponse
- type PostSearchExtendedResponseItem
- type PostSearchExtendedResult
- type PostSearchResult
- type PostSearchResultItem
- type PostSearchResultResponse
- type PostStatResponse
- type PostStatResult
- type SetCallbackSuccessResult
- type SetCallbackVerificationResult
- type StatResponse
- type StatResult
- type Subscribe
- type SubscribeResponse
- type Subscription
- type SubscriptionList
- type SubscriptionListResponse
- type SuccessResult
- type TGStatRestrictions
- type View
- type ViewItem
- type WordsMentions
- type WordsMentionsByChannel
- type WordsMentionsByChannelChannel
- type WordsMentionsByChannelItem
- type WordsMentionsByChannelResponse
- type WordsMentionsResponse
- type WordsMentionsResponseItem
Constants ¶
View Source
const (
APIURL string = "https://api.tgstat.ru"
)
Variables ¶
View Source
var NewRestRequest = func(c *Client, ctx context.Context, token, method, urlPath string, data map[string]string) (*http.Request, error) { uri := APIURL + urlPath if c == nil { return nil, errors.New("client not configured") } if c.Url != "" { uri = c.Url + urlPath } if data == nil { return nil, errors.New("data is not initialised") } if token == "" { return nil, errors.New("token not found") } data["token"] = token reqBodyData, _ := json.Marshal(data) if method == http.MethodGet { body := url.Values{} for key, value := range data { body.Add(key, value) } body.Add("token", token) uri += "?" + body.Encode() reqBodyData = nil } req, err := http.NewRequest(method, uri, bytes.NewReader(reqBodyData)) if err != nil { return nil, err } req.Header.Set("Cache-Control", "no-cache") req.Header.Set("Content-Type", "application/json") req = req.WithContext(ctx) return req, nil }
View Source
var Token string
Functions ¶
func ValidateDate ¶
func WithEndpoint ¶
func WithEndpoint(endpoint string)
WithEndpoint configures a Client to use the specified API endpoint.
Types ¶
type API ¶
type API interface { NewRestRequest(ctx context.Context, token, method, urlPath string, data map[string]string) (*http.Request, error) Do(r *http.Request, v interface{}) (*http.Response, error) }
func GetAPI ¶
func GetAPI(options ...ClientOption) API
type APIs ¶
type APIs struct { Api API // contains filtered or unexported fields }
APIs are the currently supported endpoints.
type CallbackResponse ¶
type CategoryResult ¶
type ChannelAddPending ¶
type ChannelAddPending struct {
Status string `json:"status"`
}
type ChannelAddSuccess ¶
type ChannelAvgReach ¶
type ChannelAvgReach struct { Status string `json:"status"` Response []ChannelAvgReachResponse `json:"response"` }
type ChannelAvgReachResponse ¶
type ChannelErr ¶
type ChannelErr struct { Status string `json:"status"` Response []ChannelErrResponse `json:"response"` }
type ChannelErrResponse ¶
type ChannelForwards ¶
type ChannelForwards struct { Status string `json:"status"` Response ChannelForwardsResponse `json:"response"` }
type ChannelForwardsExtended ¶
type ChannelForwardsExtended struct { Status string `json:"status"` Response ChannelForwardsResponseExtended `json:"response"` }
type ChannelForwardsResponse ¶
type ChannelForwardsResponse struct {
Items []ForwardItem `json:"items"`
}
type ChannelForwardsResponseExtended ¶
type ChannelForwardsResponseExtended struct { Items []ForwardItem `json:"items"` Channels []Channel `json:"channels"` }
type ChannelMedia ¶
type ChannelMentionsExtended ¶
type ChannelMentionsExtended struct { Status string `json:"status"` Response ChannelMentionsResponseExtended `json:"response"` }
type ChannelMentionsResponse ¶
type ChannelMentionsResponse struct {
Items []MentionItem `json:"items"`
}
type ChannelMentionsResponseExtended ¶
type ChannelMentionsResponseExtended struct { Items []MentionItem `json:"items"` Channels []Channel `json:"channels"` }
type ChannelMentionsResult ¶
type ChannelMentionsResult struct { Status string `json:"status"` Response ChannelMentionsResponse `json:"response"` }
type ChannelPostsResponse ¶
type ChannelPostsResponse struct { Count int `json:"count"` TotalCount int `json:"total_count"` Channel Channel `json:"channel"` Items []ChannelPostsResponseItem `json:"items"` }
type ChannelPostsResponseItem ¶
type ChannelPostsResponseItem struct { ID int64 `json:"id"` Date int `json:"date"` Views int `json:"views"` Link string `json:"link"` ChannelID int `json:"channel_id"` ForwardedFrom string `json:"forwarded_from"` IsDeleted int `json:"is_deleted"` Text string `json:"text"` Media ChannelMedia `json:"media"` }
type ChannelPostsResult ¶
type ChannelPostsResult struct { Status string `json:"status"` Response ChannelPostsResponse `json:"response"` }
type ChannelPostsWithChannelResponse ¶
type ChannelPostsWithChannelResponse struct { Count int `json:"count"` TotalCount int `json:"total_count"` Channel Channel `json:"channel"` Items []ChannelPostsWithChannelResponseItem `json:"items"` }
type ChannelPostsWithChannelResponseItem ¶
type ChannelPostsWithChannelResponseItem struct { ID int64 `json:"id"` Date int `json:"date"` Views int `json:"views"` Link string `json:"link"` ChannelID int `json:"channel_id"` ForwardedFrom interface{} `json:"forwarded_from"` IsDeleted int `json:"is_deleted"` Text string `json:"text"` Media ChannelMedia `json:"media"` }
type ChannelPostsWithChannelResult ¶
type ChannelPostsWithChannelResult struct { Status string `json:"status"` Response ChannelPostsWithChannelResponse `json:"response"` }
type ChannelResponse ¶
type ChannelResponse struct { Id int `json:"id"` Link string `json:"link"` Username string `json:"username"` Title string `json:"title"` About string `json:"about"` Category string `json:"category"` Country string `json:"country"` Language string `json:"Language"` Image100 string `json:"image100"` Image640 string `json:"image640"` ParticipantsCount int `json:"participants_count"` TGStatRestriction interface{} `json:"tgstat_restrictions"` }
type ChannelResponseResult ¶
type ChannelResponseResult struct { Status string `json:"status"` Response ChannelResponse `json:"response"` }
type ChannelSearch ¶
type ChannelSearch struct { Count int `json:"count"` Items []ChannelSearchItem `json:"items"` }
type ChannelSearchItem ¶
type ChannelSearchResult ¶
type ChannelSearchResult struct { Status string `json:"status"` Response ChannelSearch `json:"response"` }
type ChannelStatResponse ¶
type ChannelStatResponse struct { Id int `json:"id"` Title string `json:"title"` Username string `json:"username"` ParticipantsCount int `json:"participants_count"` AvgPostReach int `json:"avg_post_reach"` ErrPercent float64 `json:"err_percent"` DailyReach int `json:"daily_reach"` CiIndex float64 `json:"ci_index"` }
type ChannelStatResult ¶
type ChannelStatResult struct { Status string `json:"status"` Response ChannelStatResponse `json:"response"` }
type ChannelSubscribers ¶
type ChannelSubscribers struct { Status string `json:"status"` Response []ChannelSubscribersResponse `json:"response"` }
type ChannelViews ¶
type ChannelViews struct { Status string `json:"status"` Response []ChannelViewsResponse `json:"response"` }
type ChannelViewsResponse ¶
type Client ¶
type Client struct { Url string // contains filtered or unexported fields }
Client is a client to TG Stat API
var TGStatClient Client
type CountryResult ¶
type ErrorResult ¶
type ForwardItem ¶
type GetCallbackResponse ¶
type GetCallbackResponse struct { Status string `json:"status"` Response CallbackResponse `json:"response"` }
type LanguageResult ¶
type MentionItem ¶
type PostResponse ¶
type PostResult ¶
type PostResult struct { Status string `json:"status"` Response PostResponse `json:"response"` }
type PostSearchExtendedResponse ¶
type PostSearchExtendedResponse struct { Count int `json:"count"` TotalCount int `json:"total_count"` Items []PostSearchExtendedResponseItem `json:"items"` Channels []PostSearchExtendedChannel `json:"channels"` }
type PostSearchExtendedResponseItem ¶
type PostSearchExtendedResponseItem struct { ID int64 `json:"id"` Date int `json:"date"` Views int `json:"views"` Link string `json:"link"` ChannelID int `json:"channel_id"` ForwardedFrom interface{} `json:"forwarded_from"` IsDeleted int `json:"is_deleted"` Text string `json:"text"` Snippet string `json:"snippet"` Media struct { MediaType string `json:"media_type"` MimeType string `json:"mime_type"` Size int `json:"size"` } `json:"media"` }
type PostSearchExtendedResult ¶
type PostSearchExtendedResult struct { Status string `json:"status"` Response PostSearchExtendedResponse `json:"response"` }
type PostSearchResult ¶
type PostSearchResult struct { Status string `json:"status"` Response PostSearchResultResponse `json:"response"` }
type PostSearchResultItem ¶
type PostSearchResultItem struct { ID int64 `json:"id"` Date int `json:"date"` Views int `json:"views"` Link string `json:"link"` ChannelID int `json:"channel_id"` ForwardedFrom interface{} `json:"forwarded_from"` IsDeleted int `json:"is_deleted"` Text string `json:"text"` Snippet string `json:"snippet"` Media struct { MediaType string `json:"media_type"` MimeType string `json:"mime_type"` Size int `json:"size"` } `json:"media"` }
type PostSearchResultResponse ¶
type PostSearchResultResponse struct { Count int `json:"count"` TotalCount int `json:"total_count"` Items []PostSearchResultItem `json:"items"` }
type PostStatResponse ¶
type PostStatResult ¶
type PostStatResult struct { Status string `json:"status"` Response PostStatResponse `json:"response"` }
type SetCallbackSuccessResult ¶
type SetCallbackSuccessResult struct {
Status string `json:"status"`
}
type StatResponse ¶
type StatResponse struct { ServiceKey string `json:"serviceKey"` Title string `json:"title"` SpentChannels string `json:"spentChannels,omitempty"` SpentRequests string `json:"spentRequests"` ExpiredAt int64 `json:"expiredAt"` SpentWords string `json:"spentWords,omitempty"` SpentObjects string `json:"spentObjects,omitempty"` }
type StatResult ¶
type StatResult struct { Status string `json:"status"` Response []StatResponse `json:"response"` }
type Subscribe ¶
type Subscribe struct { Status string `json:"status"` Response SubscribeResponse `json:"response"` }
type SubscribeResponse ¶
type SubscribeResponse struct {
SubscriptionId int `json:"subscription_id"`
}
type Subscription ¶
type SubscriptionList ¶
type SubscriptionList struct { Status string `json:"status"` Response SubscriptionListResponse `json:"response"` }
type SubscriptionListResponse ¶
type SubscriptionListResponse struct { TotalCount int `json:"total_count"` Subscriptions []Subscription `json:"subscriptions"` }
type SuccessResult ¶
type SuccessResult struct {
Status string `json:"status"`
}
type TGStatRestrictions ¶
type WordsMentions ¶
type WordsMentions struct { Status string `json:"status"` Response WordsMentionsResponse `json:"response"` }
type WordsMentionsByChannel ¶
type WordsMentionsByChannel struct { Status string `json:"status"` Response WordsMentionsByChannelResponse `json:"response"` }
type WordsMentionsByChannelResponse ¶
type WordsMentionsByChannelResponse struct { Items []WordsMentionsByChannelItem `json:"items"` Channels []WordsMentionsByChannelChannel `json:"channels"` }
type WordsMentionsResponse ¶
type WordsMentionsResponse struct {
Items []WordsMentionsResponseItem `json:"items"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.