github.com/line/line-bot-sdk-go/v7@v7.21.0/linebot/response.go (about)

     1  // Copyright 2016 LINE Corporation
     2  //
     3  // LINE Corporation licenses this file to you under the Apache License,
     4  // version 2.0 (the "License"); you may not use this file except in compliance
     5  // with the License. You may obtain a copy of the License at:
     6  //
     7  //   http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    11  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    12  // License for the specific language governing permissions and limitations
    13  // under the License.
    14  
    15  package linebot
    16  
    17  import (
    18  	"bytes"
    19  	"encoding/json"
    20  	"io"
    21  	"net/http"
    22  	"time"
    23  )
    24  
    25  // BasicResponse type
    26  type BasicResponse struct {
    27  	RequestID string
    28  }
    29  
    30  type errorResponseDetail struct {
    31  	Message  string `json:"message"`
    32  	Property string `json:"property"`
    33  }
    34  
    35  // ErrorResponse type
    36  type ErrorResponse struct {
    37  	Message string                `json:"message"`
    38  	Details []errorResponseDetail `json:"details"`
    39  	// OAuth Errors
    40  	Error            string `json:"error"`
    41  	ErrorDescription string `json:"error_description"`
    42  }
    43  
    44  // UserProfileResponse type
    45  type UserProfileResponse struct {
    46  	UserID        string `json:"userId"`
    47  	DisplayName   string `json:"displayName"`
    48  	PictureURL    string `json:"pictureUrl"`
    49  	StatusMessage string `json:"statusMessage"`
    50  	Language      string `json:"language"`
    51  }
    52  
    53  // UserIDsResponse type
    54  type UserIDsResponse struct {
    55  	UserIDs []string `json:"userIds"`
    56  	Next    string   `json:"next"`
    57  }
    58  
    59  // GroupSummaryResponse type
    60  type GroupSummaryResponse struct {
    61  	GroupID    string `json:"groupId"`
    62  	GroupName  string `json:"groupName"`
    63  	PictureURL string `json:"pictureUrl"`
    64  }
    65  
    66  // MemberIDsResponse type
    67  type MemberIDsResponse struct {
    68  	MemberIDs []string `json:"memberIds"`
    69  	Next      string   `json:"next"`
    70  }
    71  
    72  // MemberCountResponse type
    73  type MemberCountResponse struct {
    74  	Count int `json:"count"`
    75  }
    76  
    77  // MessageContentResponse type
    78  type MessageContentResponse struct {
    79  	Content       io.ReadCloser
    80  	ContentLength int64
    81  	ContentType   string
    82  }
    83  
    84  // MessagesNumberResponse type
    85  type MessagesNumberResponse struct {
    86  	Status  string
    87  	Success int64
    88  }
    89  
    90  // MessageQuotaResponse type
    91  type MessageQuotaResponse struct {
    92  	Type       string
    93  	Value      int64
    94  	TotalUsage int64 `json:"totalUsage"`
    95  }
    96  
    97  // MessageConsumptionResponse type
    98  type MessageConsumptionResponse struct {
    99  	TotalUsage int64
   100  }
   101  
   102  // BotInfoResponse type
   103  type BotInfoResponse struct {
   104  	UserID         string         `json:"userId"`
   105  	BasicID        string         `json:"basicId"`
   106  	PremiumID      string         `json:"premiumId"`
   107  	DisplayName    string         `json:"displayName"`
   108  	PictureURL     string         `json:"pictureUrl"`
   109  	ChatMode       ChatMode       `json:"chatMode"`
   110  	MarkAsReadMode MarkAsReadMode `json:"markAsReadMode"`
   111  }
   112  
   113  // MessagesNumberDeliveryResponse type
   114  type MessagesNumberDeliveryResponse struct {
   115  	Status          string `json:"status"`
   116  	Broadcast       int64  `json:"broadcast"`
   117  	Targeting       int64  `json:"targeting"`
   118  	AutoResponse    int64  `json:"autoResponse"`
   119  	WelcomeResponse int64  `json:"welcomeResponse"`
   120  	Chat            int64  `json:"chat"`
   121  	APIBroadcast    int64  `json:"apiBroadcast"`
   122  	APIPush         int64  `json:"apiPush"`
   123  	APIMulticast    int64  `json:"apiMulticast"`
   124  	APINarrowcast   int64  `json:"apiNarrowcast"`
   125  	APIReply        int64  `json:"apiReply"`
   126  }
   127  
   128  // MessagesNumberFollowersResponse type
   129  type MessagesNumberFollowersResponse struct {
   130  	Status          string `json:"status"`
   131  	Followers       int64  `json:"followers"`
   132  	TargetedReaches int64  `json:"targetedReaches"`
   133  	Blocks          int64  `json:"blocks"`
   134  }
   135  
   136  // MessagesProgressResponse type
   137  type MessagesProgressResponse struct {
   138  	Phase             string `json:"phase"`
   139  	SuccessCount      int64  `json:"successCount"`
   140  	FailureCount      int64  `json:"failureCount"`
   141  	TargetCount       int64  `json:"targetCount"`
   142  	FailedDescription string `json:"failedDescription"`
   143  	ErrorCode         int    `json:"errorCode"`
   144  	AcceptedTime      string `json:"acceptedTime"`
   145  	CompletedTime     string `json:"completedTime,omitempty"`
   146  }
   147  
   148  // MessagesFriendDemographicsResponse type
   149  type MessagesFriendDemographicsResponse struct {
   150  	Available           bool                       `json:"available"`
   151  	Genders             []GenderDetail             `json:"genders"`
   152  	Ages                []AgeDetail                `json:"ages"`
   153  	Areas               []AreasDetail              `json:"areas"`
   154  	AppTypes            []AppTypeDetail            `json:"appTypes"`
   155  	SubscriptionPeriods []SubscriptionPeriodDetail `json:"subscriptionPeriods"`
   156  }
   157  
   158  // GenderDetail type
   159  type GenderDetail struct {
   160  	Gender     string  `json:"gender"`
   161  	Percentage float64 `json:"percentage"`
   162  }
   163  
   164  // AgeDetail type
   165  type AgeDetail struct {
   166  	Age        string  `json:"age"`
   167  	Percentage float64 `json:"percentage"`
   168  }
   169  
   170  // AreasDetail type
   171  type AreasDetail struct {
   172  	Area       string  `json:"area"`
   173  	Percentage float64 `json:"percentage"`
   174  }
   175  
   176  // AppTypeDetail type
   177  type AppTypeDetail struct {
   178  	AppType    string  `json:"appType"`
   179  	Percentage float64 `json:"percentage"`
   180  }
   181  
   182  // SubscriptionPeriodDetail type
   183  type SubscriptionPeriodDetail struct {
   184  	SubscriptionPeriod string  `json:"subscriptionPeriod"`
   185  	Percentage         float64 `json:"percentage"`
   186  }
   187  
   188  // MessagesUserInteractionStatsResponse type
   189  type MessagesUserInteractionStatsResponse struct {
   190  	Overview OverviewDetail  `json:"overview"`
   191  	Messages []MessageDetail `json:"messages"`
   192  	Clicks   []ClickDetail   `json:"clicks"`
   193  }
   194  
   195  // OverviewDetail type
   196  type OverviewDetail struct {
   197  	RequestID                   string `json:"requestId"`
   198  	Timestamp                   int64  `json:"timestamp"`
   199  	Delivered                   int64  `json:"delivered"`
   200  	UniqueImpression            int64  `json:"uniqueImpression"`
   201  	UniqueClick                 int64  `json:"uniqueClick"`
   202  	UniqueMediaPlayed           int64  `json:"uniqueMediaPlayed"`
   203  	UniqueMediaPlayed100Percent int64  `json:"uniqueMediaPlayed100Percent"`
   204  }
   205  
   206  // MessageDetail type
   207  type MessageDetail struct {
   208  	Seq                         int64 `json:"seq"`
   209  	Impression                  int64 `json:"impression"`
   210  	MediaPlayed                 int64 `json:"mediaPlayed"`
   211  	MediaPlayed25Percent        int64 `json:"mediaPlayed25Percent"`
   212  	MediaPlayed50Percent        int64 `json:"mediaPlayed50Percent"`
   213  	MediaPlayed75Percent        int64 `json:"mediaPlayed75Percent"`
   214  	MediaPlayed100Percent       int64 `json:"mediaPlayed100Percent"`
   215  	UniqueMediaPlayed           int64 `json:"uniqueMediaPlayed"`
   216  	UniqueMediaPlayed25Percent  int64 `json:"uniqueMediaPlayed25Percent"`
   217  	UniqueMediaPlayed50Percent  int64 `json:"uniqueMediaPlayed50Percent"`
   218  	UniqueMediaPlayed75Percent  int64 `json:"uniqueMediaPlayed75Percent"`
   219  	UniqueMediaPlayed100Percent int64 `json:"uniqueMediaPlayed100Percent"`
   220  }
   221  
   222  // ClickDetail type
   223  type ClickDetail struct {
   224  	Seq                  int64  `json:"seq"`
   225  	URL                  string `json:"url"`
   226  	Click                int64  `json:"click"`
   227  	UniqueClick          int64  `json:"uniqueClick"`
   228  	UniqueClickOfRequest int64  `json:"uniqueClickOfRequest"`
   229  }
   230  
   231  // RichMenuIDResponse type
   232  type RichMenuIDResponse struct {
   233  	RichMenuID string `json:"richMenuId"`
   234  }
   235  
   236  // RichMenuResponse type
   237  type RichMenuResponse struct {
   238  	RichMenuID  string       `json:"richMenuId"`
   239  	Size        RichMenuSize `json:"size"`
   240  	Selected    bool         `json:"selected"`
   241  	Name        string       `json:"name"`
   242  	ChatBarText string       `json:"chatBarText"`
   243  	Areas       []AreaDetail `json:"areas"`
   244  }
   245  
   246  // RichMenuAliasResponse type
   247  type RichMenuAliasResponse struct {
   248  	RichMenuAliasID string `json:"richMenuAliasId"`
   249  	RichMenuID      string `json:"richMenuId"`
   250  }
   251  
   252  // LIFFAppsResponse type
   253  type LIFFAppsResponse struct {
   254  	Apps []LIFFApp `json:"apps"`
   255  }
   256  
   257  // LIFFIDResponse type
   258  type LIFFIDResponse struct {
   259  	LIFFID string `json:"liffId"`
   260  }
   261  
   262  // LinkTokenResponse type
   263  type LinkTokenResponse struct {
   264  	LinkToken string `json:"linkToken"`
   265  }
   266  
   267  // WebhookInfoResponse type
   268  type WebhookInfoResponse struct {
   269  	Endpoint string `json:"endpoint"`
   270  	Active   bool   `json:"active"`
   271  }
   272  
   273  // UploadAudienceGroupResponse type
   274  type UploadAudienceGroupResponse struct {
   275  	RequestID         string `json:"-"`
   276  	AcceptedRequestID string `json:"-"`
   277  	AudienceGroupID   int    `json:"audienceGroupId,omitempty"`
   278  	CreateRoute       string `json:"createRoute,omitempty"`
   279  	Type              string `json:"type,omitempty"`
   280  	Description       string `json:"description,omitempty"`
   281  	Created           int64  `json:"created,omitempty"`
   282  	Permission        string `json:"permission,omitempty"`
   283  	ExpireTimestamp   int64  `json:"expireTimestamp,omitempty"`
   284  	IsIfaAudience     bool   `json:"isIfaAudience,omitempty"`
   285  }
   286  
   287  // ClickAudienceGroupResponse type
   288  type ClickAudienceGroupResponse struct {
   289  	XRequestID        string `json:"-"` // from header X-Line-Request-Id
   290  	AcceptedRequestID string `json:"-"`
   291  	AudienceGroupID   int    `json:"audienceGroupId,omitempty"`
   292  	CreateRoute       string `json:"createRoute,omitempty"`
   293  	Type              string `json:"type,omitempty"`
   294  	Description       string `json:"description,omitempty"`
   295  	Created           int64  `json:"created,omitempty"`
   296  	Permission        string `json:"permission,omitempty"`
   297  	ExpireTimestamp   int64  `json:"expireTimestamp,omitempty"`
   298  	IsIfaAudience     bool   `json:"isIfaAudience,omitempty"`
   299  	RequestID         string `json:"requestId,omitempty"`
   300  	ClickURL          string `json:"clickUrl,omitempty"`
   301  }
   302  
   303  // IMPAudienceGroupResponse type
   304  type IMPAudienceGroupResponse struct {
   305  	XRequestID        string `json:"-"`
   306  	AcceptedRequestID string `json:"-"`
   307  	AudienceGroupID   int    `json:"audienceGroupId,omitempty"`
   308  	CreateRoute       string `json:"createRoute,omitempty"`
   309  	Type              string `json:"type,omitempty"`
   310  	Description       string `json:"description,omitempty"`
   311  	Created           int64  `json:"created,omitempty"`
   312  	Permission        string `json:"permission,omitempty"`
   313  	ExpireTimestamp   int64  `json:"expireTimestamp,omitempty"`
   314  	IsIfaAudience     bool   `json:"isIfaAudience,omitempty"`
   315  	RequestID         string `json:"requestId,omitempty"`
   316  }
   317  
   318  // AudienceGroup type
   319  type AudienceGroup struct {
   320  	AudienceGroupID      int    `json:"audienceGroupId,omitempty"`
   321  	CreateRoute          string `json:"createRoute,omitempty"`
   322  	Type                 string `json:"type,omitempty"`
   323  	Description          string `json:"description,omitempty"`
   324  	Status               string `json:"status,omitempty"`
   325  	AudienceCount        int    `json:"audienceCount,omitempty"`
   326  	Created              int64  `json:"created,omitempty"`
   327  	Permission           string `json:"permission,omitempty"`
   328  	IsIfaAudience        bool   `json:"isIfaAudience,omitempty"`
   329  	RequestID            string `json:"requestId,omitempty"`
   330  	ClickURL             string `json:"clickUrl,omitempty"`
   331  	FailedType           string `json:"failedType,omitempty"`
   332  	Activated            int64  `json:"activated,omitempty"`
   333  	InactivatedTimestamp int64  `json:"inactivatedTimestamp,omitempty"`
   334  	ExpireTimestamp      int64  `json:"expireTimestamp,omitempty"`
   335  }
   336  
   337  // Job type
   338  type Job struct {
   339  	AudienceGroupJobID int    `json:"audienceGroupJobId,omitempty"`
   340  	AudienceGroupID    int    `json:"audienceGroupId,omitempty"`
   341  	Description        string `json:"description,omitempty"`
   342  	Type               string `json:"type,omitempty"`
   343  	Status             string `json:"status,omitempty"`
   344  	FailedType         string `json:"failedType,omitempty"`
   345  	AudienceCount      int64  `json:"audienceCount,omitempty"`
   346  	Created            int64  `json:"created,omitempty"`
   347  	JobStatus          string `json:"jobStatus,omitempty"`
   348  }
   349  
   350  // AdAccount type
   351  type AdAccount struct {
   352  	Name string `json:"name,omitempty"`
   353  }
   354  
   355  // GetAudienceGroupResponse type
   356  type GetAudienceGroupResponse struct {
   357  	RequestID         string        `json:"-"`
   358  	AcceptedRequestID string        `json:"-"`
   359  	AudienceGroup     AudienceGroup `json:"audienceGroup,omitempty"`
   360  	Jobs              []Job         `json:"jobs,omitempty"`
   361  	AdAccount         *AdAccount    `json:"adaccount,omitempty"`
   362  }
   363  
   364  // ListAudienceGroupResponse type
   365  type ListAudienceGroupResponse struct {
   366  	RequestID                        string          `json:"-"`
   367  	AcceptedRequestID                string          `json:"-"`
   368  	AudienceGroups                   []AudienceGroup `json:"audienceGroups,omitempty"`
   369  	HasNextPage                      bool            `json:"hasNextPage,omitempty"`
   370  	TotalCount                       int             `json:"totalCount,omitempty"`
   371  	ReadWriteAudienceGroupTotalCount int             `json:"readWriteAudienceGroupTotalCount,omitempty"`
   372  	Page                             int             `json:"page,omitempty"`
   373  	Size                             int             `json:"size,omitempty"`
   374  }
   375  
   376  // GetAudienceGroupAuthorityLevelResponse type
   377  type GetAudienceGroupAuthorityLevelResponse struct {
   378  	RequestID         string                     `json:"-"`
   379  	AcceptedRequestID string                     `json:"-"`
   380  	AuthorityLevel    AudienceAuthorityLevelType `json:"authorityLevel,omitempty"`
   381  }
   382  
   383  // isSuccess checks if status code is 2xx: The action was successfully received,
   384  // understood, and accepted.
   385  func isSuccess(code int) bool {
   386  	return code/100 == 2
   387  }
   388  
   389  // AccessTokenResponse type
   390  type AccessTokenResponse struct {
   391  	AccessToken string `json:"access_token"`
   392  	ExpiresIn   int64  `json:"expires_in"`
   393  	TokenType   string `json:"token_type"`
   394  	KeyID       string `json:"key_id"`
   395  }
   396  
   397  // AccessTokensResponse type
   398  type AccessTokensResponse struct {
   399  	KeyIDs []string `json:"kids"`
   400  }
   401  
   402  // VerifiedAccessTokenResponse type
   403  type VerifiedAccessTokenResponse struct {
   404  	ClientID  string `json:"client_id"`
   405  	ExpiresIn int64  `json:"expires_in"`
   406  	Scope     string `json:"scope"`
   407  }
   408  
   409  // TestWebhookResponse type
   410  type TestWebhookResponse struct {
   411  	Success    bool      `json:"success"`
   412  	Timestamp  time.Time `json:"timestamp"`
   413  	StatusCode int       `json:"statusCode"`
   414  	Reason     string    `json:"reason"`
   415  	Detail     string    `json:"detail"`
   416  }
   417  
   418  func checkResponse(res *http.Response) error {
   419  	if isSuccess(res.StatusCode) {
   420  		return nil
   421  	}
   422  	decoder := json.NewDecoder(res.Body)
   423  	result := ErrorResponse{}
   424  	if err := decoder.Decode(&result); err != nil {
   425  		return &APIError{
   426  			Code: res.StatusCode,
   427  		}
   428  	}
   429  	return &APIError{
   430  		Code:     res.StatusCode,
   431  		Response: &result,
   432  	}
   433  }
   434  
   435  func decodeToBasicResponse(res *http.Response) (*BasicResponse, error) {
   436  	if err := checkResponse(res); err != nil {
   437  		return nil, err
   438  	}
   439  	decoder := json.NewDecoder(res.Body)
   440  	result := BasicResponse{
   441  		RequestID: res.Header.Get("X-Line-Request-Id"),
   442  	}
   443  	if err := decoder.Decode(&result); err != nil {
   444  		if err == io.EOF {
   445  			return &result, nil
   446  		}
   447  		return nil, err
   448  	}
   449  	return &result, nil
   450  }
   451  
   452  func decodeToUserProfileResponse(res *http.Response) (*UserProfileResponse, error) {
   453  	if err := checkResponse(res); err != nil {
   454  		return nil, err
   455  	}
   456  	decoder := json.NewDecoder(res.Body)
   457  	result := UserProfileResponse{}
   458  	if err := decoder.Decode(&result); err != nil {
   459  		return nil, err
   460  	}
   461  	return &result, nil
   462  }
   463  
   464  func decodeToUserIDsResponse(res *http.Response) (*UserIDsResponse, error) {
   465  	if err := checkResponse(res); err != nil {
   466  		return nil, err
   467  	}
   468  	decoder := json.NewDecoder(res.Body)
   469  	result := &UserIDsResponse{}
   470  	if err := decoder.Decode(result); err != nil {
   471  		return nil, err
   472  	}
   473  	return result, nil
   474  }
   475  
   476  func decodeToGroupSummaryResponse(res *http.Response) (*GroupSummaryResponse, error) {
   477  	if err := checkResponse(res); err != nil {
   478  		return nil, err
   479  	}
   480  	decoder := json.NewDecoder(res.Body)
   481  	result := &GroupSummaryResponse{}
   482  	if err := decoder.Decode(result); err != nil {
   483  		return nil, err
   484  	}
   485  	return result, nil
   486  }
   487  
   488  func decodeToMemberIDsResponse(res *http.Response) (*MemberIDsResponse, error) {
   489  	if err := checkResponse(res); err != nil {
   490  		return nil, err
   491  	}
   492  	decoder := json.NewDecoder(res.Body)
   493  	result := &MemberIDsResponse{}
   494  	if err := decoder.Decode(result); err != nil {
   495  		return nil, err
   496  	}
   497  	return result, nil
   498  }
   499  
   500  func decodeToMemberCountResponse(res *http.Response) (*MemberCountResponse, error) {
   501  	if err := checkResponse(res); err != nil {
   502  		return nil, err
   503  	}
   504  	decoder := json.NewDecoder(res.Body)
   505  	result := &MemberCountResponse{}
   506  	if err := decoder.Decode(result); err != nil {
   507  		return nil, err
   508  	}
   509  	return result, nil
   510  }
   511  
   512  func decodeToMessageContentResponse(res *http.Response) (*MessageContentResponse, error) {
   513  	if err := checkResponse(res); err != nil {
   514  		return nil, err
   515  	}
   516  	var buf bytes.Buffer
   517  	if _, err := io.Copy(&buf, res.Body); err != nil {
   518  		return nil, err
   519  	}
   520  	result := MessageContentResponse{
   521  		Content:       io.NopCloser(&buf),
   522  		ContentType:   res.Header.Get("Content-Type"),
   523  		ContentLength: res.ContentLength,
   524  	}
   525  	return &result, nil
   526  }
   527  
   528  func decodeToMessageQuotaResponse(res *http.Response) (*MessageQuotaResponse, error) {
   529  	if err := checkResponse(res); err != nil {
   530  		return nil, err
   531  	}
   532  	decoder := json.NewDecoder(res.Body)
   533  	result := &MessageQuotaResponse{}
   534  	if err := decoder.Decode(result); err != nil {
   535  		return nil, err
   536  	}
   537  	return result, nil
   538  }
   539  
   540  func decodeToMessageConsumptionResponse(res *http.Response) (*MessageConsumptionResponse, error) {
   541  	if err := checkResponse(res); err != nil {
   542  		return nil, err
   543  	}
   544  	decoder := json.NewDecoder(res.Body)
   545  	result := &MessageConsumptionResponse{}
   546  	if err := decoder.Decode(result); err != nil {
   547  		return nil, err
   548  	}
   549  	return result, nil
   550  }
   551  
   552  func decodeToBotInfoResponse(res *http.Response) (*BotInfoResponse, error) {
   553  	if err := checkResponse(res); err != nil {
   554  		return nil, err
   555  	}
   556  	decoder := json.NewDecoder(res.Body)
   557  	result := &BotInfoResponse{}
   558  	if err := decoder.Decode(result); err != nil {
   559  		return nil, err
   560  	}
   561  	return result, nil
   562  }
   563  
   564  func decodeToRichMenuResponse(res *http.Response) (*RichMenuResponse, error) {
   565  	if err := checkResponse(res); err != nil {
   566  		return nil, err
   567  	}
   568  	decoder := json.NewDecoder(res.Body)
   569  	result := RichMenuResponse{}
   570  	if err := decoder.Decode(&result); err != nil {
   571  		return nil, err
   572  	}
   573  	return &result, nil
   574  }
   575  
   576  func decodeToRichMenuListResponse(res *http.Response) ([]*RichMenuResponse, error) {
   577  	if err := checkResponse(res); err != nil {
   578  		return nil, err
   579  	}
   580  	decoder := json.NewDecoder(res.Body)
   581  	result := struct {
   582  		RichMenus []*RichMenuResponse `json:"richmenus"`
   583  	}{}
   584  	if err := decoder.Decode(&result); err != nil {
   585  		return nil, err
   586  	}
   587  	return result.RichMenus, nil
   588  }
   589  
   590  func decodeToRichMenuIDResponse(res *http.Response) (*RichMenuIDResponse, error) {
   591  	if err := checkResponse(res); err != nil {
   592  		return nil, err
   593  	}
   594  	decoder := json.NewDecoder(res.Body)
   595  	result := RichMenuIDResponse{}
   596  	if err := decoder.Decode(&result); err != nil {
   597  		return nil, err
   598  	}
   599  	return &result, nil
   600  }
   601  
   602  func decodeToRichMenuAliasResponse(res *http.Response) (*RichMenuAliasResponse, error) {
   603  	if err := checkResponse(res); err != nil {
   604  		return nil, err
   605  	}
   606  	decoder := json.NewDecoder(res.Body)
   607  	result := RichMenuAliasResponse{}
   608  	if err := decoder.Decode(&result); err != nil {
   609  		return nil, err
   610  	}
   611  	return &result, nil
   612  }
   613  
   614  func decodeToRichMenuAliasListResponse(res *http.Response) ([]*RichMenuAliasResponse, error) {
   615  	if err := checkResponse(res); err != nil {
   616  		return nil, err
   617  	}
   618  	decoder := json.NewDecoder(res.Body)
   619  	result := struct {
   620  		Aliases []*RichMenuAliasResponse `json:"aliases"`
   621  	}{}
   622  	if err := decoder.Decode(&result); err != nil {
   623  		return nil, err
   624  	}
   625  	return result.Aliases, nil
   626  }
   627  
   628  func decodeToLIFFResponse(res *http.Response) (*LIFFAppsResponse, error) {
   629  	if err := checkResponse(res); err != nil {
   630  		return nil, err
   631  	}
   632  	decoder := json.NewDecoder(res.Body)
   633  	result := &LIFFAppsResponse{}
   634  	if err := decoder.Decode(result); err != nil {
   635  		return nil, err
   636  	}
   637  	return result, nil
   638  }
   639  
   640  func decodeToLIFFIDResponse(res *http.Response) (*LIFFIDResponse, error) {
   641  	if err := checkResponse(res); err != nil {
   642  		return nil, err
   643  	}
   644  	decoder := json.NewDecoder(res.Body)
   645  	result := LIFFIDResponse{}
   646  	if err := decoder.Decode(&result); err != nil {
   647  		return nil, err
   648  	}
   649  	return &result, nil
   650  }
   651  
   652  func decodeToLinkTokenResponse(res *http.Response) (*LinkTokenResponse, error) {
   653  	if err := checkResponse(res); err != nil {
   654  		return nil, err
   655  	}
   656  	decoder := json.NewDecoder(res.Body)
   657  	result := LinkTokenResponse{}
   658  	if err := decoder.Decode(&result); err != nil {
   659  		return nil, err
   660  	}
   661  	return &result, nil
   662  }
   663  
   664  func decodeToWebhookInfoResponse(res *http.Response) (*WebhookInfoResponse, error) {
   665  	if err := checkResponse(res); err != nil {
   666  		return nil, err
   667  	}
   668  	decoder := json.NewDecoder(res.Body)
   669  	result := WebhookInfoResponse{}
   670  	if err := decoder.Decode(&result); err != nil {
   671  		return nil, err
   672  	}
   673  	return &result, nil
   674  }
   675  
   676  func decodeToMessagesNumberResponse(res *http.Response) (*MessagesNumberResponse, error) {
   677  	if err := checkResponse(res); err != nil {
   678  		return nil, err
   679  	}
   680  	decoder := json.NewDecoder(res.Body)
   681  	result := MessagesNumberResponse{}
   682  	if err := decoder.Decode(&result); err != nil {
   683  		return nil, err
   684  	}
   685  	return &result, nil
   686  }
   687  
   688  func decodeToMessagesNumberDeliveryResponse(res *http.Response) (*MessagesNumberDeliveryResponse, error) {
   689  	if err := checkResponse(res); err != nil {
   690  		return nil, err
   691  	}
   692  	decoder := json.NewDecoder(res.Body)
   693  	result := MessagesNumberDeliveryResponse{}
   694  	if err := decoder.Decode(&result); err != nil {
   695  		return nil, err
   696  	}
   697  	return &result, nil
   698  }
   699  
   700  func decodeToMessagesNumberFollowersResponse(res *http.Response) (*MessagesNumberFollowersResponse, error) {
   701  	if err := checkResponse(res); err != nil {
   702  		return nil, err
   703  	}
   704  	decoder := json.NewDecoder(res.Body)
   705  	result := MessagesNumberFollowersResponse{}
   706  	if err := decoder.Decode(&result); err != nil {
   707  		return nil, err
   708  	}
   709  	return &result, nil
   710  }
   711  
   712  func decodeToMessagesFriendDemographicsResponse(res *http.Response) (*MessagesFriendDemographicsResponse, error) {
   713  	if err := checkResponse(res); err != nil {
   714  		return nil, err
   715  	}
   716  	decoder := json.NewDecoder(res.Body)
   717  	result := MessagesFriendDemographicsResponse{}
   718  	if err := decoder.Decode(&result); err != nil {
   719  		return nil, err
   720  	}
   721  	return &result, nil
   722  }
   723  
   724  func decodeToMessagesUserInteractionStatsResponse(res *http.Response) (*MessagesUserInteractionStatsResponse, error) {
   725  	if err := checkResponse(res); err != nil {
   726  		return nil, err
   727  	}
   728  	decoder := json.NewDecoder(res.Body)
   729  	result := MessagesUserInteractionStatsResponse{}
   730  	if err := decoder.Decode(&result); err != nil {
   731  		return nil, err
   732  	}
   733  	return &result, nil
   734  }
   735  
   736  func decodeToMessagesProgressResponse(res *http.Response) (*MessagesProgressResponse, error) {
   737  	if err := checkResponse(res); err != nil {
   738  		return nil, err
   739  	}
   740  	decoder := json.NewDecoder(res.Body)
   741  	result := MessagesProgressResponse{}
   742  	if err := decoder.Decode(&result); err != nil {
   743  		return nil, err
   744  	}
   745  	return &result, nil
   746  }
   747  
   748  func decodeToAccessTokenResponse(res *http.Response) (*AccessTokenResponse, error) {
   749  	if err := checkResponse(res); err != nil {
   750  		return nil, err
   751  	}
   752  	decoder := json.NewDecoder(res.Body)
   753  	result := AccessTokenResponse{}
   754  	if err := decoder.Decode(&result); err != nil {
   755  		return nil, err
   756  	}
   757  	return &result, nil
   758  }
   759  
   760  func decodeToAccessTokensResponse(res *http.Response) (*AccessTokensResponse, error) {
   761  	if err := checkResponse(res); err != nil {
   762  		return nil, err
   763  	}
   764  	decoder := json.NewDecoder(res.Body)
   765  	result := AccessTokensResponse{}
   766  	if err := decoder.Decode(&result); err != nil {
   767  		return nil, err
   768  	}
   769  	return &result, nil
   770  }
   771  
   772  func decodeToVerifiedAccessTokenResponse(res *http.Response) (*VerifiedAccessTokenResponse, error) {
   773  	if err := checkResponse(res); err != nil {
   774  		return nil, err
   775  	}
   776  	decoder := json.NewDecoder(res.Body)
   777  	result := VerifiedAccessTokenResponse{}
   778  	if err := decoder.Decode(&result); err != nil {
   779  		return nil, err
   780  	}
   781  	return &result, nil
   782  }
   783  
   784  func decodeToTestWebhookResponse(res *http.Response) (*TestWebhookResponse, error) {
   785  	if err := checkResponse(res); err != nil {
   786  		return nil, err
   787  	}
   788  	decoder := json.NewDecoder(res.Body)
   789  	result := TestWebhookResponse{}
   790  	if err := decoder.Decode(&result); err != nil {
   791  		return nil, err
   792  	}
   793  	return &result, nil
   794  }
   795  
   796  func decodeToAudienceGroupResponse(res *http.Response) (*UploadAudienceGroupResponse, error) {
   797  	if err := checkResponse(res); err != nil {
   798  		return nil, err
   799  	}
   800  	decoder := json.NewDecoder(res.Body)
   801  	result := UploadAudienceGroupResponse{
   802  		RequestID:         res.Header.Get("X-Line-Request-Id"),
   803  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   804  	}
   805  	if err := decoder.Decode(&result); err != nil {
   806  		if err == io.EOF {
   807  			return &result, nil
   808  		}
   809  		return nil, err
   810  	}
   811  	return &result, nil
   812  }
   813  
   814  func decodeToClickAudienceGroupResponse(res *http.Response) (*ClickAudienceGroupResponse, error) {
   815  	if err := checkResponse(res); err != nil {
   816  		return nil, err
   817  	}
   818  	decoder := json.NewDecoder(res.Body)
   819  	result := ClickAudienceGroupResponse{
   820  		XRequestID:        res.Header.Get("X-Line-Request-Id"),
   821  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   822  	}
   823  	if err := decoder.Decode(&result); err != nil {
   824  		if err == io.EOF {
   825  			return &result, nil
   826  		}
   827  		return nil, err
   828  	}
   829  	return &result, nil
   830  }
   831  
   832  func decodeToIMPAudienceGroupResponse(res *http.Response) (*IMPAudienceGroupResponse, error) {
   833  	if err := checkResponse(res); err != nil {
   834  		return nil, err
   835  	}
   836  	decoder := json.NewDecoder(res.Body)
   837  	result := IMPAudienceGroupResponse{
   838  		XRequestID:        res.Header.Get("X-Line-Request-Id"),
   839  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   840  	}
   841  	if err := decoder.Decode(&result); err != nil {
   842  		if err == io.EOF {
   843  			return &result, nil
   844  		}
   845  		return nil, err
   846  	}
   847  	return &result, nil
   848  }
   849  
   850  func decodeToGetAudienceGroupResponse(res *http.Response) (*GetAudienceGroupResponse, error) {
   851  	if err := checkResponse(res); err != nil {
   852  		return nil, err
   853  	}
   854  	decoder := json.NewDecoder(res.Body)
   855  	result := GetAudienceGroupResponse{
   856  		RequestID:         res.Header.Get("X-Line-Request-Id"),
   857  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   858  	}
   859  	if err := decoder.Decode(&result); err != nil {
   860  		if err == io.EOF {
   861  			return &result, nil
   862  		}
   863  		return nil, err
   864  	}
   865  	return &result, nil
   866  }
   867  
   868  func decodeToListAudienceGroupResponse(res *http.Response) (*ListAudienceGroupResponse, error) {
   869  	if err := checkResponse(res); err != nil {
   870  		return nil, err
   871  	}
   872  	decoder := json.NewDecoder(res.Body)
   873  	result := ListAudienceGroupResponse{
   874  		RequestID:         res.Header.Get("X-Line-Request-Id"),
   875  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   876  	}
   877  	if err := decoder.Decode(&result); err != nil {
   878  		if err == io.EOF {
   879  			return &result, nil
   880  		}
   881  		return nil, err
   882  	}
   883  	return &result, nil
   884  }
   885  
   886  func decodeToGetAudienceGroupAuthorityLevelResponse(res *http.Response) (*GetAudienceGroupAuthorityLevelResponse, error) {
   887  	if err := checkResponse(res); err != nil {
   888  		return nil, err
   889  	}
   890  	decoder := json.NewDecoder(res.Body)
   891  	result := GetAudienceGroupAuthorityLevelResponse{
   892  		RequestID:         res.Header.Get("X-Line-Request-Id"),
   893  		AcceptedRequestID: res.Header.Get("X-Line-Accepted-Request-Id"),
   894  	}
   895  	if err := decoder.Decode(&result); err != nil {
   896  		if err == io.EOF {
   897  			return &result, nil
   898  		}
   899  		return nil, err
   900  	}
   901  	return &result, nil
   902  }