github.com/twilio/twilio-go@v1.20.1/rest/numbers/v2/regulatory_compliance_bundles_replace_items.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Numbers
     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 'CreateReplaceItems'
    24  type CreateReplaceItemsParams struct {
    25  	// The source bundle sid to copy the item assignments from.
    26  	FromBundleSid *string `json:"FromBundleSid,omitempty"`
    27  }
    28  
    29  func (params *CreateReplaceItemsParams) SetFromBundleSid(FromBundleSid string) *CreateReplaceItemsParams {
    30  	params.FromBundleSid = &FromBundleSid
    31  	return params
    32  }
    33  
    34  // Replaces all bundle items in the target bundle (specified in the path) with all the bundle items of the source bundle (specified by the from_bundle_sid body param)
    35  func (c *ApiService) CreateReplaceItems(BundleSid string, params *CreateReplaceItemsParams) (*NumbersV2ReplaceItems, error) {
    36  	path := "/v2/RegulatoryCompliance/Bundles/{BundleSid}/ReplaceItems"
    37  	path = strings.Replace(path, "{"+"BundleSid"+"}", BundleSid, -1)
    38  
    39  	data := url.Values{}
    40  	headers := make(map[string]interface{})
    41  
    42  	if params != nil && params.FromBundleSid != nil {
    43  		data.Set("FromBundleSid", *params.FromBundleSid)
    44  	}
    45  
    46  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    47  	if err != nil {
    48  		return nil, err
    49  	}
    50  
    51  	defer resp.Body.Close()
    52  
    53  	ps := &NumbersV2ReplaceItems{}
    54  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    55  		return nil, err
    56  	}
    57  
    58  	return ps, err
    59  }