github.com/twilio/twilio-go@v1.20.1/rest/content/v1/model_twilio_location.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Content
     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  
    20  	"github.com/twilio/twilio-go/client"
    21  )
    22  
    23  // TwilioLocation twilio/location type contains a location pin and an optional label, which can be used to enhance delivery notifications or connect recipients to physical experiences you offer.
    24  type TwilioLocation struct {
    25  	Latitude  float32 `json:"latitude"`
    26  	Longitude float32 `json:"longitude"`
    27  	Label     string  `json:"label,omitempty"`
    28  }
    29  
    30  func (response *TwilioLocation) UnmarshalJSON(bytes []byte) (err error) {
    31  	raw := struct {
    32  		Latitude  interface{} `json:"latitude"`
    33  		Longitude interface{} `json:"longitude"`
    34  		Label     string      `json:"label"`
    35  	}{}
    36  
    37  	if err = json.Unmarshal(bytes, &raw); err != nil {
    38  		return err
    39  	}
    40  
    41  	*response = TwilioLocation{
    42  		Label: raw.Label,
    43  	}
    44  
    45  	responseLatitude, err := client.UnmarshalFloat32(&raw.Latitude)
    46  	if err != nil {
    47  		return err
    48  	}
    49  	response.Latitude = *responseLatitude
    50  
    51  	responseLongitude, err := client.UnmarshalFloat32(&raw.Longitude)
    52  	if err != nil {
    53  		return err
    54  	}
    55  	response.Longitude = *responseLongitude
    56  
    57  	return
    58  }