-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcustomercustomerportal.go
More file actions
64 lines (56 loc) · 2.41 KB
/
customercustomerportal.go
File metadata and controls
64 lines (56 loc) · 2.41 KB
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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package dodopayments
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/dodopayments/dodopayments-go/internal/apiquery"
"github.com/dodopayments/dodopayments-go/internal/param"
"github.com/dodopayments/dodopayments-go/internal/requestconfig"
"github.com/dodopayments/dodopayments-go/option"
)
// CustomerCustomerPortalService contains methods and other services that help with
// interacting with the Dodo Payments API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewCustomerCustomerPortalService] method instead.
type CustomerCustomerPortalService struct {
Options []option.RequestOption
}
// NewCustomerCustomerPortalService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewCustomerCustomerPortalService(opts ...option.RequestOption) (r *CustomerCustomerPortalService) {
r = &CustomerCustomerPortalService{}
r.Options = opts
return
}
func (r *CustomerCustomerPortalService) New(ctx context.Context, customerID string, body CustomerCustomerPortalNewParams, opts ...option.RequestOption) (res *CustomerPortalSession, err error) {
opts = slices.Concat(r.Options, opts)
if customerID == "" {
err = errors.New("missing required customer_id parameter")
return nil, err
}
path := fmt.Sprintf("customers/%s/customer-portal/session", customerID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return res, err
}
type CustomerCustomerPortalNewParams struct {
// Optional return URL for this session. Overrides the business-level default. This
// URL will be shown as a "Return to {business}" back button in the portal.
ReturnURL param.Field[string] `query:"return_url"`
// If true, will send link to user.
SendEmail param.Field[bool] `query:"send_email"`
}
// URLQuery serializes [CustomerCustomerPortalNewParams]'s query parameters as
// `url.Values`.
func (r CustomerCustomerPortalNewParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}