github.com/twilio/twilio-go@v1.20.1/rest/api/v2010/model_api_v2010_usage_record.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Api
     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  // ApiV2010UsageRecord struct for ApiV2010UsageRecord
    24  type ApiV2010UsageRecord struct {
    25  	// The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that accrued the usage.
    26  	AccountSid *string `json:"account_sid,omitempty"`
    27  	// The API version used to create the resource.
    28  	ApiVersion *string `json:"api_version,omitempty"`
    29  	// Usage records up to date as of this timestamp, formatted as YYYY-MM-DDTHH:MM:SS+00:00. All timestamps are in GMT
    30  	AsOf     *string `json:"as_of,omitempty"`
    31  	Category *string `json:"category,omitempty"`
    32  	// The number of usage events, such as the number of calls.
    33  	Count *string `json:"count,omitempty"`
    34  	// The units in which `count` is measured, such as `calls` for calls or `messages` for SMS.
    35  	CountUnit *string `json:"count_unit,omitempty"`
    36  	// A plain-language description of the usage category.
    37  	Description *string `json:"description,omitempty"`
    38  	// The last date for which usage is included in the UsageRecord. The date is specified in GMT and formatted as `YYYY-MM-DD`.
    39  	EndDate *string `json:"end_date,omitempty"`
    40  	// The total price of the usage in the currency specified in `price_unit` and associated with the account.
    41  	Price *float32 `json:"price,omitempty"`
    42  	// The currency in which `price` is measured, in [ISO 4127](https://www.iso.org/iso/home/standards/currency_codes.htm) format, such as `usd`, `eur`, and `jpy`.
    43  	PriceUnit *string `json:"price_unit,omitempty"`
    44  	// The first date for which usage is included in this UsageRecord. The date is specified in GMT and formatted as `YYYY-MM-DD`.
    45  	StartDate *string `json:"start_date,omitempty"`
    46  	// A list of related resources identified by their URIs. For more information, see [List Subresources](https://www.twilio.com/docs/usage/api/usage-record#list-subresources).
    47  	SubresourceUris *map[string]interface{} `json:"subresource_uris,omitempty"`
    48  	// The URI of the resource, relative to `https://api.twilio.com`.
    49  	Uri *string `json:"uri,omitempty"`
    50  	// The amount used to bill usage and measured in units described in `usage_unit`.
    51  	Usage *string `json:"usage,omitempty"`
    52  	// The units in which `usage` is measured, such as `minutes` for calls or `messages` for SMS.
    53  	UsageUnit *string `json:"usage_unit,omitempty"`
    54  }
    55  
    56  func (response *ApiV2010UsageRecord) UnmarshalJSON(bytes []byte) (err error) {
    57  	raw := struct {
    58  		AccountSid      *string                 `json:"account_sid"`
    59  		ApiVersion      *string                 `json:"api_version"`
    60  		AsOf            *string                 `json:"as_of"`
    61  		Category        *string                 `json:"category"`
    62  		Count           *string                 `json:"count"`
    63  		CountUnit       *string                 `json:"count_unit"`
    64  		Description     *string                 `json:"description"`
    65  		EndDate         *string                 `json:"end_date"`
    66  		Price           *interface{}            `json:"price"`
    67  		PriceUnit       *string                 `json:"price_unit"`
    68  		StartDate       *string                 `json:"start_date"`
    69  		SubresourceUris *map[string]interface{} `json:"subresource_uris"`
    70  		Uri             *string                 `json:"uri"`
    71  		Usage           *string                 `json:"usage"`
    72  		UsageUnit       *string                 `json:"usage_unit"`
    73  	}{}
    74  
    75  	if err = json.Unmarshal(bytes, &raw); err != nil {
    76  		return err
    77  	}
    78  
    79  	*response = ApiV2010UsageRecord{
    80  		AccountSid:      raw.AccountSid,
    81  		ApiVersion:      raw.ApiVersion,
    82  		AsOf:            raw.AsOf,
    83  		Category:        raw.Category,
    84  		Count:           raw.Count,
    85  		CountUnit:       raw.CountUnit,
    86  		Description:     raw.Description,
    87  		EndDate:         raw.EndDate,
    88  		PriceUnit:       raw.PriceUnit,
    89  		StartDate:       raw.StartDate,
    90  		SubresourceUris: raw.SubresourceUris,
    91  		Uri:             raw.Uri,
    92  		Usage:           raw.Usage,
    93  		UsageUnit:       raw.UsageUnit,
    94  	}
    95  
    96  	responsePrice, err := client.UnmarshalFloat32(raw.Price)
    97  	if err != nil {
    98  		return err
    99  	}
   100  	response.Price = responsePrice
   101  
   102  	return
   103  }