github.com/twilio/twilio-go@v1.20.1/rest/oauth/v1/authorize.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Oauth
     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  // Optional parameters for the method 'FetchAuthorize'
    23  type FetchAuthorizeParams struct {
    24  	// Response Type
    25  	ResponseType *string `json:"ResponseType,omitempty"`
    26  	// The Client Identifier
    27  	ClientId *string `json:"ClientId,omitempty"`
    28  	// The url to which response will be redirected to
    29  	RedirectUri *string `json:"RedirectUri,omitempty"`
    30  	// The scope of the access request
    31  	Scope *string `json:"Scope,omitempty"`
    32  	// An opaque value which can be used to maintain state between the request and callback
    33  	State *string `json:"State,omitempty"`
    34  }
    35  
    36  func (params *FetchAuthorizeParams) SetResponseType(ResponseType string) *FetchAuthorizeParams {
    37  	params.ResponseType = &ResponseType
    38  	return params
    39  }
    40  func (params *FetchAuthorizeParams) SetClientId(ClientId string) *FetchAuthorizeParams {
    41  	params.ClientId = &ClientId
    42  	return params
    43  }
    44  func (params *FetchAuthorizeParams) SetRedirectUri(RedirectUri string) *FetchAuthorizeParams {
    45  	params.RedirectUri = &RedirectUri
    46  	return params
    47  }
    48  func (params *FetchAuthorizeParams) SetScope(Scope string) *FetchAuthorizeParams {
    49  	params.Scope = &Scope
    50  	return params
    51  }
    52  func (params *FetchAuthorizeParams) SetState(State string) *FetchAuthorizeParams {
    53  	params.State = &State
    54  	return params
    55  }
    56  
    57  // Retrieves authorize uri
    58  func (c *ApiService) FetchAuthorize(params *FetchAuthorizeParams) (*OauthV1Authorize, error) {
    59  	path := "/v1/authorize"
    60  
    61  	data := url.Values{}
    62  	headers := make(map[string]interface{})
    63  
    64  	if params != nil && params.ResponseType != nil {
    65  		data.Set("ResponseType", *params.ResponseType)
    66  	}
    67  	if params != nil && params.ClientId != nil {
    68  		data.Set("ClientId", *params.ClientId)
    69  	}
    70  	if params != nil && params.RedirectUri != nil {
    71  		data.Set("RedirectUri", *params.RedirectUri)
    72  	}
    73  	if params != nil && params.Scope != nil {
    74  		data.Set("Scope", *params.Scope)
    75  	}
    76  	if params != nil && params.State != nil {
    77  		data.Set("State", *params.State)
    78  	}
    79  
    80  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    81  	if err != nil {
    82  		return nil, err
    83  	}
    84  
    85  	defer resp.Body.Close()
    86  
    87  	ps := &OauthV1Authorize{}
    88  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    89  		return nil, err
    90  	}
    91  
    92  	return ps, err
    93  }