github.com/twilio/twilio-go@v1.20.1/rest/content/v1/content_approval_requests_whatsapp.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Content
     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  	"strings"
    21  )
    22  
    23  // Optional parameters for the method 'CreateContentApprovalRequest'
    24  type CreateContentApprovalRequestParams struct {
    25  	//
    26  	ContentApprovalRequest *ContentApprovalRequest `json:"ContentApprovalRequest,omitempty"`
    27  }
    28  
    29  func (params *CreateContentApprovalRequestParams) SetContentApprovalRequest(ContentApprovalRequest ContentApprovalRequest) *CreateContentApprovalRequestParams {
    30  	params.ContentApprovalRequest = &ContentApprovalRequest
    31  	return params
    32  }
    33  
    34  //
    35  func (c *ApiService) CreateContentApprovalRequest(ContentSid string, params *CreateContentApprovalRequestParams) (*ContentV1ApprovalCreate, error) {
    36  	path := "/v1/Content/{ContentSid}/ApprovalRequests/whatsapp"
    37  	path = strings.Replace(path, "{"+"ContentSid"+"}", ContentSid, -1)
    38  
    39  	data := url.Values{}
    40  	headers := map[string]interface{}{
    41  		"Content-Type": "application/json",
    42  	}
    43  
    44  	body := []byte{}
    45  	if params != nil && params.ContentApprovalRequest != nil {
    46  		b, err := json.Marshal(*params.ContentApprovalRequest)
    47  		if err != nil {
    48  			return nil, err
    49  		}
    50  		body = b
    51  	}
    52  
    53  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers, body...)
    54  	if err != nil {
    55  		return nil, err
    56  	}
    57  
    58  	defer resp.Body.Close()
    59  
    60  	ps := &ContentV1ApprovalCreate{}
    61  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    62  		return nil, err
    63  	}
    64  
    65  	return ps, err
    66  }