-
Notifications
You must be signed in to change notification settings - Fork 2
/
businesses.go
142 lines (119 loc) · 5.72 KB
/
businesses.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
// Code generated by the Paddle SDK Generator; DO NOT EDIT.
package paddle
import (
"context"
paddleerr "github.com/PaddleHQ/paddle-go-sdk/v3/pkg/paddleerr"
)
// ErrBusinessContactEmailDomainNotAllowed represents a `business_contact_email_domain_not_allowed` error.
// See https://developer.paddle.com/errors/businesses/business_contact_email_domain_not_allowed for more information.
var ErrBusinessContactEmailDomainNotAllowed = &paddleerr.Error{
Code: "business_contact_email_domain_not_allowed",
Type: paddleerr.ErrorTypeRequestError,
}
// BusinessContacts: List of contacts related to this business, typically used for sending invoices.
type BusinessContacts struct {
// Name: Full name of this contact.
Name string `json:"name,omitempty"`
// Email: Email address for this contact.
Email string `json:"email,omitempty"`
}
// BusinessesClient is a client for the Businesses resource.
type BusinessesClient struct {
doer Doer
}
// ListBusinessesRequest is given as an input to ListBusinesses.
type ListBusinessesRequest 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, including contacts, 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:"-"`
}
// ListBusinesses performs the GET operation on a Businesses resource.
func (c *BusinessesClient) ListBusinesses(ctx context.Context, req *ListBusinessesRequest) (res *Collection[*Business], err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/businesses", req, &res); err != nil {
return nil, err
}
return res, nil
}
// CreateBusinessRequest is given as an input to CreateBusiness.
type CreateBusinessRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
// Name: Name of this business.
Name string `json:"name,omitempty"`
// CompanyNumber: Company number for this business.
CompanyNumber *string `json:"company_number,omitempty"`
// TaxIdentifier: Tax or VAT Number for this business.
TaxIdentifier *string `json:"tax_identifier,omitempty"`
// Contacts: List of contacts related to this business, typically used for sending invoices.
Contacts []BusinessContacts `json:"contacts,omitempty"`
// CustomData: Your own structured key-value data.
CustomData CustomData `json:"custom_data,omitempty"`
}
// CreateBusiness performs the POST operation on a Businesses resource.
func (c *BusinessesClient) CreateBusiness(ctx context.Context, req *CreateBusinessRequest) (res *Business, err error) {
if err := c.doer.Do(ctx, "POST", "/customers/{customer_id}/businesses", req, &res); err != nil {
return nil, err
}
return res, nil
}
// GetBusinessRequest is given as an input to GetBusiness.
type GetBusinessRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
BusinessID string `in:"path=business_id" json:"-"`
}
// GetBusiness performs the GET operation on a Businesses resource.
func (c *BusinessesClient) GetBusiness(ctx context.Context, req *GetBusinessRequest) (res *Business, err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/businesses/{business_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}
// UpdateBusinessRequest is given as an input to UpdateBusiness.
type UpdateBusinessRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
BusinessID string `in:"path=business_id" json:"-"`
// Name: Name of this business.
Name *PatchField[string] `json:"name,omitempty"`
// CompanyNumber: Company number for this business.
CompanyNumber *PatchField[*string] `json:"company_number,omitempty"`
// TaxIdentifier: Tax or VAT Number for this business.
TaxIdentifier *PatchField[*string] `json:"tax_identifier,omitempty"`
// Status: Whether this entity can be used in Paddle.
Status *PatchField[Status] `json:"status,omitempty"`
// Contacts: List of contacts related to this business, typically used for sending invoices.
Contacts *PatchField[[]BusinessContacts] `json:"contacts,omitempty"`
// CustomData: Your own structured key-value data.
CustomData *PatchField[CustomData] `json:"custom_data,omitempty"`
}
// UpdateBusiness performs the PATCH operation on a Businesses resource.
func (c *BusinessesClient) UpdateBusiness(ctx context.Context, req *UpdateBusinessRequest) (res *Business, err error) {
if err := c.doer.Do(ctx, "PATCH", "/customers/{customer_id}/businesses/{business_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}