github.com/line/line-bot-sdk-go/v7@v7.21.0/linebot/get_quota.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  	"context"
    19  )
    20  
    21  // GetMessageQuota method
    22  func (client *Client) GetMessageQuota() *GetMessageQuotaCall {
    23  	return &GetMessageQuotaCall{
    24  		c:        client,
    25  		endpoint: APIEndpointGetMessageQuota,
    26  	}
    27  }
    28  
    29  // GetMessageQuotaConsumption method
    30  func (client *Client) GetMessageQuotaConsumption() *GetMessageQuotaCall {
    31  	return &GetMessageQuotaCall{
    32  		c:        client,
    33  		endpoint: APIEndpointGetMessageQuotaConsumption,
    34  	}
    35  }
    36  
    37  // GetMessageQuotaCall type
    38  type GetMessageQuotaCall struct {
    39  	c        *Client
    40  	ctx      context.Context
    41  	endpoint string
    42  }
    43  
    44  // WithContext method
    45  func (call *GetMessageQuotaCall) WithContext(ctx context.Context) *GetMessageQuotaCall {
    46  	call.ctx = ctx
    47  	return call
    48  }
    49  
    50  // Do method
    51  func (call *GetMessageQuotaCall) Do() (*MessageQuotaResponse, error) {
    52  	res, err := call.c.get(call.ctx, call.c.endpointBase, call.endpoint, nil)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  	defer closeResponse(res)
    57  	return decodeToMessageQuotaResponse(res)
    58  }
    59  
    60  // GetMessageConsumption method
    61  func (client *Client) GetMessageConsumption() *GetMessageConsumptionCall {
    62  	return &GetMessageConsumptionCall{
    63  		c: client,
    64  	}
    65  }
    66  
    67  // GetMessageConsumptionCall type
    68  type GetMessageConsumptionCall struct {
    69  	c   *Client
    70  	ctx context.Context
    71  }
    72  
    73  // WithContext method
    74  func (call *GetMessageConsumptionCall) WithContext(ctx context.Context) *GetMessageConsumptionCall {
    75  	call.ctx = ctx
    76  	return call
    77  }
    78  
    79  // Do method
    80  func (call *GetMessageConsumptionCall) Do() (*MessageConsumptionResponse, error) {
    81  	res, err := call.c.get(call.ctx, call.c.endpointBase, APIEndpointGetMessageConsumption, nil)
    82  	if err != nil {
    83  		return nil, err
    84  	}
    85  	defer closeResponse(res)
    86  	return decodeToMessageConsumptionResponse(res)
    87  }