github.com/Files-com/files-sdk-go/v3@v3.1.81/accountlineitem.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	lib "github.com/Files-com/files-sdk-go/v3/lib"
     8  )
     9  
    10  type AccountLineItem struct {
    11  	Id                int64      `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
    12  	Amount            string     `json:"amount,omitempty" path:"amount,omitempty" url:"amount,omitempty"`
    13  	Balance           string     `json:"balance,omitempty" path:"balance,omitempty" url:"balance,omitempty"`
    14  	CreatedAt         *time.Time `json:"created_at,omitempty" path:"created_at,omitempty" url:"created_at,omitempty"`
    15  	Currency          string     `json:"currency,omitempty" path:"currency,omitempty" url:"currency,omitempty"`
    16  	DownloadUri       string     `json:"download_uri,omitempty" path:"download_uri,omitempty" url:"download_uri,omitempty"`
    17  	InvoiceLineItems  []string   `json:"invoice_line_items,omitempty" path:"invoice_line_items,omitempty" url:"invoice_line_items,omitempty"`
    18  	Method            string     `json:"method,omitempty" path:"method,omitempty" url:"method,omitempty"`
    19  	PaymentLineItems  []string   `json:"payment_line_items,omitempty" path:"payment_line_items,omitempty" url:"payment_line_items,omitempty"`
    20  	PaymentReversedAt *time.Time `json:"payment_reversed_at,omitempty" path:"payment_reversed_at,omitempty" url:"payment_reversed_at,omitempty"`
    21  	PaymentType       string     `json:"payment_type,omitempty" path:"payment_type,omitempty" url:"payment_type,omitempty"`
    22  	SiteName          string     `json:"site_name,omitempty" path:"site_name,omitempty" url:"site_name,omitempty"`
    23  	Type              string     `json:"type,omitempty" path:"type,omitempty" url:"type,omitempty"`
    24  }
    25  
    26  func (a AccountLineItem) Identifier() interface{} {
    27  	return a.Id
    28  }
    29  
    30  type AccountLineItemCollection []AccountLineItem
    31  
    32  func (a *AccountLineItem) UnmarshalJSON(data []byte) error {
    33  	type accountLineItem AccountLineItem
    34  	var v accountLineItem
    35  	if err := json.Unmarshal(data, &v); err != nil {
    36  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    37  	}
    38  
    39  	*a = AccountLineItem(v)
    40  	return nil
    41  }
    42  
    43  func (a *AccountLineItemCollection) UnmarshalJSON(data []byte) error {
    44  	type accountLineItems AccountLineItemCollection
    45  	var v accountLineItems
    46  	if err := json.Unmarshal(data, &v); err != nil {
    47  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    48  	}
    49  
    50  	*a = AccountLineItemCollection(v)
    51  	return nil
    52  }
    53  
    54  func (a *AccountLineItemCollection) ToSlice() *[]interface{} {
    55  	ret := make([]interface{}, len(*a))
    56  	for i, v := range *a {
    57  		ret[i] = v
    58  	}
    59  
    60  	return &ret
    61  }