File: payment_methods.go

package info (click to toggle)
golang-github-packethost-packngo 0.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 440 kB
  • sloc: makefile: 2
file content (72 lines) | stat: -rw-r--r-- 2,814 bytes parent folder | download | duplicates (2)
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
71
72
package packngo

// API documentation https://www.packet.net/developers/api/paymentmethods/
const paymentMethodBasePath = "/payment-methods"

// ProjectService interface defines available project methods
type PaymentMethodService interface {
	List() ([]PaymentMethod, *Response, error)
	Get(string) (*PaymentMethod, *Response, error)
	Create(*PaymentMethodCreateRequest) (*PaymentMethod, *Response, error)
	Update(string, *PaymentMethodUpdateRequest) (*PaymentMethod, *Response, error)
	Delete(string) (*Response, error)
}

type paymentMethodsRoot struct {
	PaymentMethods []PaymentMethod `json:"payment_methods"`
}

// PaymentMethod represents a Packet payment method of an organization
type PaymentMethod struct {
	ID             string         `json:"id"`
	Name           string         `json:"name,omitempty"`
	Created        string         `json:"created_at,omitempty"`
	Updated        string         `json:"updated_at,omitempty"`
	Nonce          string         `json:"nonce,omitempty"`
	Default        bool           `json:"default,omitempty"`
	Organization   Organization   `json:"organization,omitempty"`
	Projects       []Project      `json:"projects,omitempty"`
	Type           string         `json:"type,omitempty"`
	CardholderName string         `json:"cardholder_name,omitempty"`
	ExpMonth       string         `json:"expiration_month,omitempty"`
	ExpYear        string         `json:"expiration_year,omitempty"`
	Last4          string         `json:"last_4,omitempty"`
	BillingAddress BillingAddress `json:"billing_address,omitempty"`
	URL            string         `json:"href,omitempty"`
}

func (pm PaymentMethod) String() string {
	return Stringify(pm)
}

// PaymentMethodCreateRequest type used to create a Packet payment method of an organization
type PaymentMethodCreateRequest struct {
	Name           string `json:"name"`
	Nonce          string `json:"nonce"`
	CardholderName string `json:"cardholder_name,omitempty"`
	ExpMonth       string `json:"expiration_month,omitempty"`
	ExpYear        string `json:"expiration_year,omitempty"`
	BillingAddress string `json:"billing_address,omitempty"`
}

func (pm PaymentMethodCreateRequest) String() string {
	return Stringify(pm)
}

// PaymentMethodUpdateRequest type used to update a Packet payment method of an organization
type PaymentMethodUpdateRequest struct {
	Name           *string `json:"name,omitempty"`
	CardholderName *string `json:"cardholder_name,omitempty"`
	ExpMonth       *string `json:"expiration_month,omitempty"`
	ExpYear        *string `json:"expiration_year,omitempty"`
	BillingAddress *string `json:"billing_address,omitempty"`
}

func (pm PaymentMethodUpdateRequest) String() string {
	return Stringify(pm)
}

// PaymentMethodServiceOp implements PaymentMethodService
type PaymentMethodServiceOp struct {
	client *Client
}