github.com/twilio/twilio-go@v1.20.1/rest/content/v1/model_catalog_item.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 // CatalogItem struct for CatalogItem 24 type CatalogItem struct { 25 Id string `json:"id,omitempty"` 26 SectionTitle string `json:"section_title,omitempty"` 27 Name string `json:"name,omitempty"` 28 MediaUrl string `json:"media_url,omitempty"` 29 Price float32 `json:"price,omitempty"` 30 Description string `json:"description,omitempty"` 31 } 32 33 func (response *CatalogItem) UnmarshalJSON(bytes []byte) (err error) { 34 raw := struct { 35 Id string `json:"id"` 36 SectionTitle string `json:"section_title"` 37 Name string `json:"name"` 38 MediaUrl string `json:"media_url"` 39 Price interface{} `json:"price"` 40 Description string `json:"description"` 41 }{} 42 43 if err = json.Unmarshal(bytes, &raw); err != nil { 44 return err 45 } 46 47 *response = CatalogItem{ 48 Id: raw.Id, 49 SectionTitle: raw.SectionTitle, 50 Name: raw.Name, 51 MediaUrl: raw.MediaUrl, 52 Description: raw.Description, 53 } 54 55 responsePrice, err := client.UnmarshalFloat32(&raw.Price) 56 if err != nil { 57 return err 58 } 59 response.Price = *responsePrice 60 61 return 62 }