-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.456.1
1 parent
a64a7e9
commit 1a08e54
Showing
328 changed files
with
5,062 additions
and
885 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,251 @@ | ||
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. | ||
|
||
package polargo | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"github.com/polarsource/polar-go/internal/hooks" | ||
"github.com/polarsource/polar-go/internal/utils" | ||
"github.com/polarsource/polar-go/models/apierrors" | ||
"github.com/polarsource/polar-go/models/components" | ||
"github.com/polarsource/polar-go/models/operations" | ||
"github.com/polarsource/polar-go/retry" | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
type CustomerSessions struct { | ||
sdkConfiguration sdkConfiguration | ||
} | ||
|
||
func newCustomerSessions(sdkConfig sdkConfiguration) *CustomerSessions { | ||
return &CustomerSessions{ | ||
sdkConfiguration: sdkConfig, | ||
} | ||
} | ||
|
||
// Create Customer Session | ||
// Create a customer session. | ||
func (s *CustomerSessions) Create(ctx context.Context, request components.CustomerSessionCreate, opts ...operations.Option) (*operations.CustomerSessionsCreateResponse, error) { | ||
hookCtx := hooks.HookContext{ | ||
Context: ctx, | ||
OperationID: "customer-sessions:create", | ||
OAuth2Scopes: []string{}, | ||
SecuritySource: s.sdkConfiguration.Security, | ||
} | ||
|
||
o := operations.Options{} | ||
supportedOptions := []string{ | ||
operations.SupportedOptionRetries, | ||
operations.SupportedOptionTimeout, | ||
} | ||
|
||
for _, opt := range opts { | ||
if err := opt(&o, supportedOptions...); err != nil { | ||
return nil, fmt.Errorf("error applying option: %w", err) | ||
} | ||
} | ||
|
||
var baseURL string | ||
if o.ServerURL == nil { | ||
baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) | ||
} else { | ||
baseURL = *o.ServerURL | ||
} | ||
opURL, err := url.JoinPath(baseURL, "/v1/customer-sessions/") | ||
if err != nil { | ||
return nil, fmt.Errorf("error generating URL: %w", err) | ||
} | ||
|
||
bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
timeout := o.Timeout | ||
if timeout == nil { | ||
timeout = s.sdkConfiguration.Timeout | ||
} | ||
|
||
if timeout != nil { | ||
var cancel context.CancelFunc | ||
ctx, cancel = context.WithTimeout(ctx, *timeout) | ||
defer cancel() | ||
} | ||
|
||
req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) | ||
if err != nil { | ||
return nil, fmt.Errorf("error creating request: %w", err) | ||
} | ||
req.Header.Set("Accept", "application/json") | ||
req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) | ||
req.Header.Set("Content-Type", reqContentType) | ||
|
||
if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { | ||
return nil, err | ||
} | ||
|
||
for k, v := range o.SetHeaders { | ||
req.Header.Set(k, v) | ||
} | ||
|
||
globalRetryConfig := s.sdkConfiguration.RetryConfig | ||
retryConfig := o.Retries | ||
if retryConfig == nil { | ||
if globalRetryConfig != nil { | ||
retryConfig = globalRetryConfig | ||
} | ||
} | ||
|
||
var httpRes *http.Response | ||
if retryConfig != nil { | ||
httpRes, err = utils.Retry(ctx, utils.Retries{ | ||
Config: retryConfig, | ||
StatusCodes: []string{ | ||
"429", | ||
"500", | ||
"502", | ||
"503", | ||
"504", | ||
}, | ||
}, func() (*http.Response, error) { | ||
if req.Body != nil { | ||
copyBody, err := req.GetBody() | ||
if err != nil { | ||
return nil, err | ||
} | ||
req.Body = copyBody | ||
} | ||
|
||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) | ||
if err != nil { | ||
if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { | ||
return nil, err | ||
} | ||
|
||
return nil, retry.Permanent(err) | ||
} | ||
|
||
httpRes, err := s.sdkConfiguration.Client.Do(req) | ||
if err != nil || httpRes == nil { | ||
if err != nil { | ||
err = fmt.Errorf("error sending request: %w", err) | ||
} else { | ||
err = fmt.Errorf("error sending request: no response") | ||
} | ||
|
||
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) | ||
} | ||
return httpRes, err | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} else { | ||
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
} else { | ||
req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
httpRes, err = s.sdkConfiguration.Client.Do(req) | ||
if err != nil || httpRes == nil { | ||
if err != nil { | ||
err = fmt.Errorf("error sending request: %w", err) | ||
} else { | ||
err = fmt.Errorf("error sending request: no response") | ||
} | ||
|
||
_, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) | ||
return nil, err | ||
} else if utils.MatchStatusCodes([]string{"422", "4XX", "5XX"}, httpRes.StatusCode) { | ||
_httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) | ||
if err != nil { | ||
return nil, err | ||
} else if _httpRes != nil { | ||
httpRes = _httpRes | ||
} | ||
} else { | ||
httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
} | ||
|
||
res := &operations.CustomerSessionsCreateResponse{ | ||
HTTPMeta: components.HTTPMetadata{ | ||
Request: req, | ||
Response: httpRes, | ||
}, | ||
} | ||
|
||
switch { | ||
case httpRes.StatusCode == 201: | ||
switch { | ||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var out components.CustomerSession | ||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { | ||
return nil, err | ||
} | ||
|
||
res.CustomerSession = &out | ||
default: | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) | ||
} | ||
case httpRes.StatusCode == 422: | ||
switch { | ||
case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var out apierrors.HTTPValidationError | ||
if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { | ||
return nil, err | ||
} | ||
|
||
return nil, &out | ||
default: | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) | ||
} | ||
case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: | ||
fallthrough | ||
case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) | ||
default: | ||
rawBody, err := utils.ConsumeRawBody(httpRes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) | ||
} | ||
|
||
return res, nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# AlreadyCanceledSubscriptionError | ||
|
||
|
||
## Values | ||
|
||
| Name | Value | | ||
| ------------------------------------------------------------- | ------------------------------------------------------------- | | ||
| `AlreadyCanceledSubscriptionErrorAlreadyCanceledSubscription` | AlreadyCanceledSubscription | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Error | ||
|
||
|
||
## Values | ||
|
||
| Name | Value | | ||
| ----------------------- | ----------------------- | | ||
| `ErrorResourceNotFound` | ResourceNotFound | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# NotPermittedError | ||
|
||
|
||
## Values | ||
|
||
| Name | Value | | ||
| ------------------------------- | ------------------------------- | | ||
| `NotPermittedErrorNotPermitted` | NotPermitted | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.