github.com/twilio/twilio-go@v1.20.1/rest/bulkexports/v1/exports_configuration.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Bulkexports
     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  	"fmt"
    20  	"net/url"
    21  	"strings"
    22  )
    23  
    24  // Fetch a specific Export Configuration.
    25  func (c *ApiService) FetchExportConfiguration(ResourceType string) (*BulkexportsV1ExportConfiguration, error) {
    26  	path := "/v1/Exports/{ResourceType}/Configuration"
    27  	path = strings.Replace(path, "{"+"ResourceType"+"}", ResourceType, -1)
    28  
    29  	data := url.Values{}
    30  	headers := make(map[string]interface{})
    31  
    32  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  
    37  	defer resp.Body.Close()
    38  
    39  	ps := &BulkexportsV1ExportConfiguration{}
    40  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    41  		return nil, err
    42  	}
    43  
    44  	return ps, err
    45  }
    46  
    47  // Optional parameters for the method 'UpdateExportConfiguration'
    48  type UpdateExportConfigurationParams struct {
    49  	// If true, Twilio will automatically generate every day's file when the day is over.
    50  	Enabled *bool `json:"Enabled,omitempty"`
    51  	// Stores the URL destination for the method specified in webhook_method.
    52  	WebhookUrl *string `json:"WebhookUrl,omitempty"`
    53  	// Sets whether Twilio should call a webhook URL when the automatic generation is complete, using GET or POST. The actual destination is set in the webhook_url
    54  	WebhookMethod *string `json:"WebhookMethod,omitempty"`
    55  }
    56  
    57  func (params *UpdateExportConfigurationParams) SetEnabled(Enabled bool) *UpdateExportConfigurationParams {
    58  	params.Enabled = &Enabled
    59  	return params
    60  }
    61  func (params *UpdateExportConfigurationParams) SetWebhookUrl(WebhookUrl string) *UpdateExportConfigurationParams {
    62  	params.WebhookUrl = &WebhookUrl
    63  	return params
    64  }
    65  func (params *UpdateExportConfigurationParams) SetWebhookMethod(WebhookMethod string) *UpdateExportConfigurationParams {
    66  	params.WebhookMethod = &WebhookMethod
    67  	return params
    68  }
    69  
    70  // Update a specific Export Configuration.
    71  func (c *ApiService) UpdateExportConfiguration(ResourceType string, params *UpdateExportConfigurationParams) (*BulkexportsV1ExportConfiguration, error) {
    72  	path := "/v1/Exports/{ResourceType}/Configuration"
    73  	path = strings.Replace(path, "{"+"ResourceType"+"}", ResourceType, -1)
    74  
    75  	data := url.Values{}
    76  	headers := make(map[string]interface{})
    77  
    78  	if params != nil && params.Enabled != nil {
    79  		data.Set("Enabled", fmt.Sprint(*params.Enabled))
    80  	}
    81  	if params != nil && params.WebhookUrl != nil {
    82  		data.Set("WebhookUrl", *params.WebhookUrl)
    83  	}
    84  	if params != nil && params.WebhookMethod != nil {
    85  		data.Set("WebhookMethod", *params.WebhookMethod)
    86  	}
    87  
    88  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
    89  	if err != nil {
    90  		return nil, err
    91  	}
    92  
    93  	defer resp.Body.Close()
    94  
    95  	ps := &BulkexportsV1ExportConfiguration{}
    96  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    97  		return nil, err
    98  	}
    99  
   100  	return ps, err
   101  }