github.com/twilio/twilio-go@v1.20.1/rest/numbers/v1/hosted_number_eligibility_bulk.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 'CreateBulkEligibility'
    24  type CreateBulkEligibilityParams struct {
    25  	//
    26  	Body *map[string]interface{} `json:"body,omitempty"`
    27  }
    28  
    29  func (params *CreateBulkEligibilityParams) SetBody(Body map[string]interface{}) *CreateBulkEligibilityParams {
    30  	params.Body = &Body
    31  	return params
    32  }
    33  
    34  // Create a bulk eligibility check for a set of numbers that you want to host in Twilio.
    35  func (c *ApiService) CreateBulkEligibility(params *CreateBulkEligibilityParams) (*NumbersV1BulkEligibility, error) {
    36  	path := "/v1/HostedNumber/Eligibility/Bulk"
    37  
    38  	data := url.Values{}
    39  	headers := map[string]interface{}{
    40  		"Content-Type": "application/json",
    41  	}
    42  
    43  	body := []byte{}
    44  	if params != nil && params.Body != nil {
    45  		b, err := json.Marshal(*params.Body)
    46  		if err != nil {
    47  			return nil, err
    48  		}
    49  		body = b
    50  	}
    51  
    52  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers, body...)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  
    57  	defer resp.Body.Close()
    58  
    59  	ps := &NumbersV1BulkEligibility{}
    60  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    61  		return nil, err
    62  	}
    63  
    64  	return ps, err
    65  }
    66  
    67  // Fetch an eligibility bulk check that you requested to host in Twilio.
    68  func (c *ApiService) FetchBulkEligibility(RequestId string) (*NumbersV1BulkEligibility, error) {
    69  	path := "/v1/HostedNumber/Eligibility/Bulk/{RequestId}"
    70  	path = strings.Replace(path, "{"+"RequestId"+"}", RequestId, -1)
    71  
    72  	data := url.Values{}
    73  	headers := make(map[string]interface{})
    74  
    75  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    76  	if err != nil {
    77  		return nil, err
    78  	}
    79  
    80  	defer resp.Body.Close()
    81  
    82  	ps := &NumbersV1BulkEligibility{}
    83  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    84  		return nil, err
    85  	}
    86  
    87  	return ps, err
    88  }