github.com/twilio/twilio-go@v1.20.1/rest/numbers/v2/hosted_number_orders_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 'CreateBulkHostedNumberOrder'
    24  type CreateBulkHostedNumberOrderParams struct {
    25  	//
    26  	Body *map[string]interface{} `json:"body,omitempty"`
    27  }
    28  
    29  func (params *CreateBulkHostedNumberOrderParams) SetBody(Body map[string]interface{}) *CreateBulkHostedNumberOrderParams {
    30  	params.Body = &Body
    31  	return params
    32  }
    33  
    34  // Host multiple phone numbers on Twilio's platform.
    35  func (c *ApiService) CreateBulkHostedNumberOrder(params *CreateBulkHostedNumberOrderParams) (*NumbersV2BulkHostedNumberOrder, error) {
    36  	path := "/v2/HostedNumber/Orders/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 := &NumbersV2BulkHostedNumberOrder{}
    60  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    61  		return nil, err
    62  	}
    63  
    64  	return ps, err
    65  }
    66  
    67  // Optional parameters for the method 'FetchBulkHostedNumberOrder'
    68  type FetchBulkHostedNumberOrderParams struct {
    69  	// Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'.
    70  	OrderStatus *string `json:"OrderStatus,omitempty"`
    71  }
    72  
    73  func (params *FetchBulkHostedNumberOrderParams) SetOrderStatus(OrderStatus string) *FetchBulkHostedNumberOrderParams {
    74  	params.OrderStatus = &OrderStatus
    75  	return params
    76  }
    77  
    78  // Fetch a specific BulkHostedNumberOrder.
    79  func (c *ApiService) FetchBulkHostedNumberOrder(BulkHostingSid string, params *FetchBulkHostedNumberOrderParams) (*NumbersV2BulkHostedNumberOrder, error) {
    80  	path := "/v2/HostedNumber/Orders/Bulk/{BulkHostingSid}"
    81  	path = strings.Replace(path, "{"+"BulkHostingSid"+"}", BulkHostingSid, -1)
    82  
    83  	data := url.Values{}
    84  	headers := make(map[string]interface{})
    85  
    86  	if params != nil && params.OrderStatus != nil {
    87  		data.Set("OrderStatus", *params.OrderStatus)
    88  	}
    89  
    90  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    91  	if err != nil {
    92  		return nil, err
    93  	}
    94  
    95  	defer resp.Body.Close()
    96  
    97  	ps := &NumbersV2BulkHostedNumberOrder{}
    98  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    99  		return nil, err
   100  	}
   101  
   102  	return ps, err
   103  }