-
Notifications
You must be signed in to change notification settings - Fork 2
/
payment.go
70 lines (57 loc) · 2.65 KB
/
payment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package files_sdk
import (
"encoding/json"
"time"
lib "github.com/Files-com/files-sdk-go/v2/lib"
)
type Payment struct {
Id int64 `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
Amount string `json:"amount,omitempty" path:"amount,omitempty" url:"amount,omitempty"`
Balance string `json:"balance,omitempty" path:"balance,omitempty" url:"balance,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty" path:"created_at,omitempty" url:"created_at,omitempty"`
Currency string `json:"currency,omitempty" path:"currency,omitempty" url:"currency,omitempty"`
DownloadUri string `json:"download_uri,omitempty" path:"download_uri,omitempty" url:"download_uri,omitempty"`
InvoiceLineItems []string `json:"invoice_line_items,omitempty" path:"invoice_line_items,omitempty" url:"invoice_line_items,omitempty"`
Method string `json:"method,omitempty" path:"method,omitempty" url:"method,omitempty"`
PaymentLineItems []string `json:"payment_line_items,omitempty" path:"payment_line_items,omitempty" url:"payment_line_items,omitempty"`
PaymentReversedAt *time.Time `json:"payment_reversed_at,omitempty" path:"payment_reversed_at,omitempty" url:"payment_reversed_at,omitempty"`
PaymentType string `json:"payment_type,omitempty" path:"payment_type,omitempty" url:"payment_type,omitempty"`
SiteName string `json:"site_name,omitempty" path:"site_name,omitempty" url:"site_name,omitempty"`
Type string `json:"type,omitempty" path:"type,omitempty" url:"type,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty" path:"updated_at,omitempty" url:"updated_at,omitempty"`
}
func (p Payment) Identifier() interface{} {
return p.Id
}
type PaymentCollection []Payment
type PaymentListParams struct {
ListParams
}
type PaymentFindParams struct {
Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"`
}
func (p *Payment) UnmarshalJSON(data []byte) error {
type payment Payment
var v payment
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
}
*p = Payment(v)
return nil
}
func (p *PaymentCollection) UnmarshalJSON(data []byte) error {
type payments PaymentCollection
var v payments
if err := json.Unmarshal(data, &v); err != nil {
return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
}
*p = PaymentCollection(v)
return nil
}
func (p *PaymentCollection) ToSlice() *[]interface{} {
ret := make([]interface{}, len(*p))
for i, v := range *p {
ret[i] = v
}
return &ret
}