-
Notifications
You must be signed in to change notification settings - Fork 2
/
addresses.go
146 lines (124 loc) · 5.93 KB
/
addresses.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Code generated by the Paddle SDK Generator; DO NOT EDIT.
package paddle
import (
"context"
paddleerr "github.com/PaddleHQ/paddle-go-sdk/v3/pkg/paddleerr"
)
// ErrAddressLocationNotAllowed represents a `address_location_not_allowed` error.
// See https://developer.paddle.com/errors/addresses/address_location_not_allowed for more information.
var ErrAddressLocationNotAllowed = &paddleerr.Error{
Code: "address_location_not_allowed",
Type: paddleerr.ErrorTypeRequestError,
}
// AddressesClient is a client for the Addresses resource.
type AddressesClient struct {
doer Doer
}
// ListAddressesRequest is given as an input to ListAddresses.
type ListAddressesRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
// After is a query parameter.
// Return entities after the specified Paddle ID when working with paginated endpoints. Used in the `meta.pagination.next` URL in responses for list operations.
After *string `in:"query=after;omitempty" json:"-"`
// ID is a query parameter.
// Return only the IDs specified. Use a comma-separated list to get multiple entities.
ID []string `in:"query=id;omitempty" json:"-"`
// OrderBy is a query parameter.
/*
Order returned entities by the specified field and direction (`[ASC]` or `[DESC]`). For example, `?order_by=id[ASC]`.
Valid fields for ordering: `id`.
*/
OrderBy *string `in:"query=order_by;omitempty" json:"-"`
// PerPage is a query parameter.
/*
Set how many entities are returned per page. Paddle returns the maximum number of results if a number greater than the maximum is requested. Check `meta.pagination.per_page` in the response to see how many were returned.
Default: `50`; Maximum: `200`.
*/
PerPage *int `in:"query=per_page;omitempty" json:"-"`
// Search is a query parameter.
// Return entities that match a search query. Searches all fields except `status`, `created_at`, and `updated_at`.
Search *string `in:"query=search;omitempty" json:"-"`
// Status is a query parameter.
// Return entities that match the specified status. Use a comma-separated list to specify multiple status values.
Status []string `in:"query=status;omitempty" json:"-"`
}
// ListAddresses performs the GET operation on a Addresses resource.
func (c *AddressesClient) ListAddresses(ctx context.Context, req *ListAddressesRequest) (res *Collection[*Address], err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/addresses", req, &res); err != nil {
return nil, err
}
return res, nil
}
// CreateAddressRequest is given as an input to CreateAddress.
type CreateAddressRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
// CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code for this address.
CountryCode CountryCode `json:"country_code,omitempty"`
// Description: Memorable description for this address.
Description *string `json:"description,omitempty"`
// FirstLine: First line of this address.
FirstLine *string `json:"first_line,omitempty"`
// SecondLine: Second line of this address.
SecondLine *string `json:"second_line,omitempty"`
// City: City of this address.
City *string `json:"city,omitempty"`
// PostalCode: ZIP or postal code of this address. Required for some countries.
PostalCode *string `json:"postal_code,omitempty"`
// Region: State, county, or region of this address.
Region *string `json:"region,omitempty"`
// CustomData: Your own structured key-value data.
CustomData CustomData `json:"custom_data,omitempty"`
}
// CreateAddress performs the POST operation on a Addresses resource.
func (c *AddressesClient) CreateAddress(ctx context.Context, req *CreateAddressRequest) (res *Address, err error) {
if err := c.doer.Do(ctx, "POST", "/customers/{customer_id}/addresses", req, &res); err != nil {
return nil, err
}
return res, nil
}
// GetAddressRequest is given as an input to GetAddress.
type GetAddressRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
AddressID string `in:"path=address_id" json:"-"`
}
// GetAddress performs the GET operation on a Addresses resource.
func (c *AddressesClient) GetAddress(ctx context.Context, req *GetAddressRequest) (res *Address, err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/addresses/{address_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}
// UpdateAddressRequest is given as an input to UpdateAddress.
type UpdateAddressRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
AddressID string `in:"path=address_id" json:"-"`
// Description: Memorable description for this address.
Description *PatchField[*string] `json:"description,omitempty"`
// FirstLine: First line of this address.
FirstLine *PatchField[*string] `json:"first_line,omitempty"`
// SecondLine: Second line of this address.
SecondLine *PatchField[*string] `json:"second_line,omitempty"`
// City: City of this address.
City *PatchField[*string] `json:"city,omitempty"`
// PostalCode: ZIP or postal code of this address. Required for some countries.
PostalCode *PatchField[*string] `json:"postal_code,omitempty"`
// Region: State, county, or region of this address.
Region *PatchField[*string] `json:"region,omitempty"`
// CountryCode: Supported two-letter ISO 3166-1 alpha-2 country code for this address.
CountryCode *PatchField[CountryCode] `json:"country_code,omitempty"`
// CustomData: Your own structured key-value data.
CustomData *PatchField[CustomData] `json:"custom_data,omitempty"`
// Status: Whether this entity can be used in Paddle.
Status *PatchField[Status] `json:"status,omitempty"`
}
// UpdateAddress performs the PATCH operation on a Addresses resource.
func (c *AddressesClient) UpdateAddress(ctx context.Context, req *UpdateAddressRequest) (res *Address, err error) {
if err := c.doer.Do(ctx, "PATCH", "/customers/{customer_id}/addresses/{address_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}