github.com/twilio/twilio-go@v1.20.1/rest/accounts/v1/auth_tokens_secondary.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Accounts
     8   * This is the public Twilio REST API.
     9   *
    10   * NOTE: This class is auto generated by OpenAPI Generator.
    11   * https://openapi-generator.tech
    12   * Do not edit the class manually.
    13   */
    14  
    15  package openapi
    16  
    17  import (
    18  	"encoding/json"
    19  	"net/url"
    20  )
    21  
    22  // Create a new secondary Auth Token
    23  func (c *ApiService) CreateSecondaryAuthToken() (*AccountsV1SecondaryAuthToken, error) {
    24  	path := "/v1/AuthTokens/Secondary"
    25  
    26  	data := url.Values{}
    27  	headers := make(map[string]interface{})
    28  
    29  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    30  	if err != nil {
    31  		return nil, err
    32  	}
    33  
    34  	defer resp.Body.Close()
    35  
    36  	ps := &AccountsV1SecondaryAuthToken{}
    37  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    38  		return nil, err
    39  	}
    40  
    41  	return ps, err
    42  }
    43  
    44  // Delete the secondary Auth Token from your account
    45  func (c *ApiService) DeleteSecondaryAuthToken() error {
    46  	path := "/v1/AuthTokens/Secondary"
    47  
    48  	data := url.Values{}
    49  	headers := make(map[string]interface{})
    50  
    51  	resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers)
    52  	if err != nil {
    53  		return err
    54  	}
    55  
    56  	defer resp.Body.Close()
    57  
    58  	return nil
    59  }