github.com/twilio/twilio-go@v1.20.1/rest/lookups/v2/phone_numbers.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Lookups
     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 'FetchPhoneNumber'
    24  type FetchPhoneNumberParams struct {
    25  	// A comma-separated list of fields to return. Possible values are validation, caller_name, sim_swap, call_forwarding, line_status, line_type_intelligence, identity_match, reassigned_number, sms_pumping_risk, phone_number_quality_score, pre_fill.
    26  	Fields *string `json:"Fields,omitempty"`
    27  	// The [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) used if the phone number provided is in national format.
    28  	CountryCode *string `json:"CountryCode,omitempty"`
    29  	// User’s first name. This query parameter is only used (optionally) for identity_match package requests.
    30  	FirstName *string `json:"FirstName,omitempty"`
    31  	// User’s last name. This query parameter is only used (optionally) for identity_match package requests.
    32  	LastName *string `json:"LastName,omitempty"`
    33  	// User’s first address line. This query parameter is only used (optionally) for identity_match package requests.
    34  	AddressLine1 *string `json:"AddressLine1,omitempty"`
    35  	// User’s second address line. This query parameter is only used (optionally) for identity_match package requests.
    36  	AddressLine2 *string `json:"AddressLine2,omitempty"`
    37  	// User’s city. This query parameter is only used (optionally) for identity_match package requests.
    38  	City *string `json:"City,omitempty"`
    39  	// User’s country subdivision, such as state, province, or locality. This query parameter is only used (optionally) for identity_match package requests.
    40  	State *string `json:"State,omitempty"`
    41  	// User’s postal zip code. This query parameter is only used (optionally) for identity_match package requests.
    42  	PostalCode *string `json:"PostalCode,omitempty"`
    43  	// User’s country, up to two characters. This query parameter is only used (optionally) for identity_match package requests.
    44  	AddressCountryCode *string `json:"AddressCountryCode,omitempty"`
    45  	// User’s national ID, such as SSN or Passport ID. This query parameter is only used (optionally) for identity_match package requests.
    46  	NationalId *string `json:"NationalId,omitempty"`
    47  	// User’s date of birth, in YYYYMMDD format. This query parameter is only used (optionally) for identity_match package requests.
    48  	DateOfBirth *string `json:"DateOfBirth,omitempty"`
    49  	// The date you obtained consent to call or text the end-user of the phone number or a date on which you are reasonably certain that the end-user could still be reached at that number. This query parameter is only used (optionally) for reassigned_number package requests.
    50  	LastVerifiedDate *string `json:"LastVerifiedDate,omitempty"`
    51  	// The unique identifier associated with a verification process through verify API. This query parameter is only used (optionally) for pre_fill package requests.
    52  	VerificationSid *string `json:"VerificationSid,omitempty"`
    53  }
    54  
    55  func (params *FetchPhoneNumberParams) SetFields(Fields string) *FetchPhoneNumberParams {
    56  	params.Fields = &Fields
    57  	return params
    58  }
    59  func (params *FetchPhoneNumberParams) SetCountryCode(CountryCode string) *FetchPhoneNumberParams {
    60  	params.CountryCode = &CountryCode
    61  	return params
    62  }
    63  func (params *FetchPhoneNumberParams) SetFirstName(FirstName string) *FetchPhoneNumberParams {
    64  	params.FirstName = &FirstName
    65  	return params
    66  }
    67  func (params *FetchPhoneNumberParams) SetLastName(LastName string) *FetchPhoneNumberParams {
    68  	params.LastName = &LastName
    69  	return params
    70  }
    71  func (params *FetchPhoneNumberParams) SetAddressLine1(AddressLine1 string) *FetchPhoneNumberParams {
    72  	params.AddressLine1 = &AddressLine1
    73  	return params
    74  }
    75  func (params *FetchPhoneNumberParams) SetAddressLine2(AddressLine2 string) *FetchPhoneNumberParams {
    76  	params.AddressLine2 = &AddressLine2
    77  	return params
    78  }
    79  func (params *FetchPhoneNumberParams) SetCity(City string) *FetchPhoneNumberParams {
    80  	params.City = &City
    81  	return params
    82  }
    83  func (params *FetchPhoneNumberParams) SetState(State string) *FetchPhoneNumberParams {
    84  	params.State = &State
    85  	return params
    86  }
    87  func (params *FetchPhoneNumberParams) SetPostalCode(PostalCode string) *FetchPhoneNumberParams {
    88  	params.PostalCode = &PostalCode
    89  	return params
    90  }
    91  func (params *FetchPhoneNumberParams) SetAddressCountryCode(AddressCountryCode string) *FetchPhoneNumberParams {
    92  	params.AddressCountryCode = &AddressCountryCode
    93  	return params
    94  }
    95  func (params *FetchPhoneNumberParams) SetNationalId(NationalId string) *FetchPhoneNumberParams {
    96  	params.NationalId = &NationalId
    97  	return params
    98  }
    99  func (params *FetchPhoneNumberParams) SetDateOfBirth(DateOfBirth string) *FetchPhoneNumberParams {
   100  	params.DateOfBirth = &DateOfBirth
   101  	return params
   102  }
   103  func (params *FetchPhoneNumberParams) SetLastVerifiedDate(LastVerifiedDate string) *FetchPhoneNumberParams {
   104  	params.LastVerifiedDate = &LastVerifiedDate
   105  	return params
   106  }
   107  func (params *FetchPhoneNumberParams) SetVerificationSid(VerificationSid string) *FetchPhoneNumberParams {
   108  	params.VerificationSid = &VerificationSid
   109  	return params
   110  }
   111  
   112  //
   113  func (c *ApiService) FetchPhoneNumber(PhoneNumber string, params *FetchPhoneNumberParams) (*LookupsV2PhoneNumber, error) {
   114  	path := "/v2/PhoneNumbers/{PhoneNumber}"
   115  	path = strings.Replace(path, "{"+"PhoneNumber"+"}", PhoneNumber, -1)
   116  
   117  	data := url.Values{}
   118  	headers := make(map[string]interface{})
   119  
   120  	if params != nil && params.Fields != nil {
   121  		data.Set("Fields", *params.Fields)
   122  	}
   123  	if params != nil && params.CountryCode != nil {
   124  		data.Set("CountryCode", *params.CountryCode)
   125  	}
   126  	if params != nil && params.FirstName != nil {
   127  		data.Set("FirstName", *params.FirstName)
   128  	}
   129  	if params != nil && params.LastName != nil {
   130  		data.Set("LastName", *params.LastName)
   131  	}
   132  	if params != nil && params.AddressLine1 != nil {
   133  		data.Set("AddressLine1", *params.AddressLine1)
   134  	}
   135  	if params != nil && params.AddressLine2 != nil {
   136  		data.Set("AddressLine2", *params.AddressLine2)
   137  	}
   138  	if params != nil && params.City != nil {
   139  		data.Set("City", *params.City)
   140  	}
   141  	if params != nil && params.State != nil {
   142  		data.Set("State", *params.State)
   143  	}
   144  	if params != nil && params.PostalCode != nil {
   145  		data.Set("PostalCode", *params.PostalCode)
   146  	}
   147  	if params != nil && params.AddressCountryCode != nil {
   148  		data.Set("AddressCountryCode", *params.AddressCountryCode)
   149  	}
   150  	if params != nil && params.NationalId != nil {
   151  		data.Set("NationalId", *params.NationalId)
   152  	}
   153  	if params != nil && params.DateOfBirth != nil {
   154  		data.Set("DateOfBirth", *params.DateOfBirth)
   155  	}
   156  	if params != nil && params.LastVerifiedDate != nil {
   157  		data.Set("LastVerifiedDate", *params.LastVerifiedDate)
   158  	}
   159  	if params != nil && params.VerificationSid != nil {
   160  		data.Set("VerificationSid", *params.VerificationSid)
   161  	}
   162  
   163  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
   164  	if err != nil {
   165  		return nil, err
   166  	}
   167  
   168  	defer resp.Body.Close()
   169  
   170  	ps := &LookupsV2PhoneNumber{}
   171  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   172  		return nil, err
   173  	}
   174  
   175  	return ps, err
   176  }