mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
1275 lines
46 KiB
Go
1275 lines
46 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
// AffiliateAPIService AffiliateAPI service
|
|
type AffiliateAPIService service
|
|
|
|
type AffiliateAPIGetAffiliateRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
}
|
|
|
|
func (r AffiliateAPIGetAffiliateRequest) Execute() (*AffiliateAffiliateStanding, *http.Response, error) {
|
|
return r.ApiService.GetAffiliateExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAffiliate Answers the caller org's OWN affiliate standing: status, referral code and share link, commission rate, how many orgs it has referred, and its lifetime accrued, still-pending and already-paid commission in integer cents, with its payout history.
|
|
|
|
Answers the caller org's OWN affiliate standing: status, referral
|
|
code and share link, commission rate, how many orgs it has referred, and its
|
|
lifetime accrued, still-pending and already-paid commission in integer cents,
|
|
with its payout history.
|
|
|
|
An org that never applied gets an honest `isAffiliate:false` and the default
|
|
rate rather than a 404 — the console renders the apply form off that answer.
|
|
|
|
The affiliate is resolved from the VALIDATED org, never from a field, so this
|
|
can only ever read the caller's own row; without a principal it is refused. It
|
|
is a PURE READ: nothing accrues until the sweep runs. Commission is earned on
|
|
Hanzo's MARGIN, never on the referred customer's bill, so nothing here changes
|
|
what that customer pays.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIGetAffiliateRequest
|
|
*/
|
|
func (a *AffiliateAPIService) GetAffiliate(ctx context.Context) AffiliateAPIGetAffiliateRequest {
|
|
return AffiliateAPIGetAffiliateRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAffiliateStanding
|
|
func (a *AffiliateAPIService) GetAffiliateExecute(r AffiliateAPIGetAffiliateRequest) (*AffiliateAffiliateStanding, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAffiliateStanding
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.GetAffiliate")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIGetAffiliateLeaderboardRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
}
|
|
|
|
func (r AffiliateAPIGetAffiliateLeaderboardRequest) Execute() (*AffiliateAffiliateBoard, *http.Response, error) {
|
|
return r.ApiService.GetAffiliateLeaderboardExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAffiliateLeaderboard Answers the top affiliates by lifetime accrued commission, shown by OPT-IN HANDLE with aggregate figures only, plus the caller's own exact rank.
|
|
|
|
Answers the top affiliates by lifetime accrued commission, shown by
|
|
OPT-IN HANDLE with aggregate figures only, plus the caller's own exact rank.
|
|
|
|
It never discloses an org identity and never a referred org's usage. An
|
|
affiliate that has set no handle still OCCUPIES its rank but is not listed —
|
|
so opting out hides the name, not the position, and the visible board must not
|
|
be read as a complete roster.
|
|
|
|
The caller's own row carries its exact GLOBAL rank, computed over the whole
|
|
approved set rather than over the page, so it is right well outside the top of
|
|
the board. Only an approved affiliate has a rank. Requires a validated
|
|
principal; a signed-in non-affiliate may read the board but gets no personal
|
|
row.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIGetAffiliateLeaderboardRequest
|
|
*/
|
|
func (a *AffiliateAPIService) GetAffiliateLeaderboard(ctx context.Context) AffiliateAPIGetAffiliateLeaderboardRequest {
|
|
return AffiliateAPIGetAffiliateLeaderboardRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAffiliateBoard
|
|
func (a *AffiliateAPIService) GetAffiliateLeaderboardExecute(r AffiliateAPIGetAffiliateLeaderboardRequest) (*AffiliateAffiliateBoard, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAffiliateBoard
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.GetAffiliateLeaderboard")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/leaderboard"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIGetAffiliateMeRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
}
|
|
|
|
func (r AffiliateAPIGetAffiliateMeRequest) Execute() (*AffiliateAffiliateSelf, *http.Response, error) {
|
|
return r.ApiService.GetAffiliateMeExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAffiliateMe Answers the richer self-view: the same lifetime accrued, pending and paid commission and payout history, plus the caller's downline broken out by upline LEVEL — direct, second, third — each with the rate paid at that level and how many orgs sit there.
|
|
|
|
Answers the richer self-view: the same lifetime accrued, pending and paid
|
|
commission and payout history, plus the caller's downline broken out by upline
|
|
LEVEL — direct, second, third — each with the rate paid at that level and how
|
|
many orgs sit there.
|
|
|
|
Commission is MULTI-LEVEL: a referred org's spend pays up its referral chain,
|
|
three levels deep and no further. The direct level is the affiliate's own
|
|
negotiated rate; the second and third are platform-wide switches, read live,
|
|
so the schedule shown is the one actually in force rather than one compiled
|
|
in. A caller that has not applied still gets that schedule alongside
|
|
`isAffiliate:false`, so the console can show what it would earn.
|
|
|
|
Scoped to the validated org and nothing else, and refused without a
|
|
principal. A PURE READ — it reports the downline but accrues nothing.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIGetAffiliateMeRequest
|
|
*/
|
|
func (a *AffiliateAPIService) GetAffiliateMe(ctx context.Context) AffiliateAPIGetAffiliateMeRequest {
|
|
return AffiliateAPIGetAffiliateMeRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAffiliateSelf
|
|
func (a *AffiliateAPIService) GetAffiliateMeExecute(r AffiliateAPIGetAffiliateMeRequest) (*AffiliateAffiliateSelf, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAffiliateSelf
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.GetAffiliateMe")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/me"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIGetAffiliateMeEarningsRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
}
|
|
|
|
func (r AffiliateAPIGetAffiliateMeEarningsRequest) Execute() (*AffiliateAffiliateEarnings, *http.Response, error) {
|
|
return r.ApiService.GetAffiliateMeEarningsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAffiliateMeEarnings Answers the caller's own commission ledger: per period, the margin it earned against and the commission taken from that margin; and per referred org, that referral's aggregate contribution.
|
|
|
|
Answers the caller's own commission ledger: per period, the margin it
|
|
earned against and the commission taken from that margin; and per referred
|
|
org, that referral's aggregate contribution. Integer cents throughout.
|
|
|
|
The per-org view deliberately carries the affiliate's OWN earned share and NOT
|
|
the referred org's spend or margin. An affiliate is entitled to what it
|
|
earned, not to a restatement of its customer's usage — the period view is
|
|
where the margin base appears, aggregated across every referral.
|
|
|
|
Scoped server-side to the validated caller's affiliate; a caller that is not
|
|
one gets `isAffiliate:false`.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIGetAffiliateMeEarningsRequest
|
|
*/
|
|
func (a *AffiliateAPIService) GetAffiliateMeEarnings(ctx context.Context) AffiliateAPIGetAffiliateMeEarningsRequest {
|
|
return AffiliateAPIGetAffiliateMeEarningsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAffiliateEarnings
|
|
func (a *AffiliateAPIService) GetAffiliateMeEarningsExecute(r AffiliateAPIGetAffiliateMeEarningsRequest) (*AffiliateAffiliateEarnings, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAffiliateEarnings
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.GetAffiliateMeEarnings")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/me/earnings"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIGetAffiliateMeLinksRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
}
|
|
|
|
func (r AffiliateAPIGetAffiliateMeLinksRequest) Execute() (*AffiliateAffiliateLinks, *http.Response, error) {
|
|
return r.ApiService.GetAffiliateMeLinksExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAffiliateMeLinks Answers the caller's share links, each with its URL and its funnel: clicks tracked, signups — orgs attributed with that code — and conversions, meaning how many of those signups have actually produced commission.
|
|
|
|
Answers the caller's share links, each with its URL and its funnel:
|
|
clicks tracked, signups — orgs attributed with that code — and conversions,
|
|
meaning how many of those signups have actually produced commission.
|
|
|
|
Signups and conversions are DERIVED from the commission ledger and never
|
|
stored, so they cannot drift from the money. Clicks are the one stored counter
|
|
and the one that is pure vanity.
|
|
|
|
Any pending public click pings are folded into the store before the read, in
|
|
one batch — which is how the counters stay current without a database write
|
|
per click. Scoped to the validated caller's own affiliate; a non-affiliate
|
|
gets `isAffiliate:false` and the link cap.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIGetAffiliateMeLinksRequest
|
|
*/
|
|
func (a *AffiliateAPIService) GetAffiliateMeLinks(ctx context.Context) AffiliateAPIGetAffiliateMeLinksRequest {
|
|
return AffiliateAPIGetAffiliateMeLinksRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAffiliateLinks
|
|
func (a *AffiliateAPIService) GetAffiliateMeLinksExecute(r AffiliateAPIGetAffiliateMeLinksRequest) (*AffiliateAffiliateLinks, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAffiliateLinks
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.GetAffiliateMeLinks")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/me/links"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIPostAffiliateApplyRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
affiliateApplyRequest *AffiliateApplyRequest
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateApplyRequest) AffiliateApplyRequest(affiliateApplyRequest AffiliateApplyRequest) AffiliateAPIPostAffiliateApplyRequest {
|
|
r.affiliateApplyRequest = &affiliateApplyRequest
|
|
return r
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateApplyRequest) Execute() (*AffiliateApplication, *http.Response, error) {
|
|
return r.ApiService.PostAffiliateApplyExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostAffiliateApply Enrolls the caller's OWN org as an affiliate at status `applied`, optionally requesting a vanity code, and answers the record — 201 on the first apply, 200 with `created:false` afterwards.
|
|
|
|
Enrolls the caller's OWN org as an affiliate at status `applied`,
|
|
optionally requesting a vanity code, and answers the record — 201 on the first
|
|
apply, 200 with `created:false` afterwards.
|
|
|
|
IDEMPOTENT, first apply wins: one affiliate per org, so re-applying never
|
|
creates a second row and never resets an existing approval. Applying is not
|
|
joining — no code is minted and nothing accrues until staff approve, which is
|
|
where both the code and the commission rate come from.
|
|
|
|
The org is the validated caller's, never a field. A malformed vanity code is
|
|
refused up front; the code is only REQUESTED here, and approval may mint a
|
|
different one if the requested code is taken.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIPostAffiliateApplyRequest
|
|
*/
|
|
func (a *AffiliateAPIService) PostAffiliateApply(ctx context.Context) AffiliateAPIPostAffiliateApplyRequest {
|
|
return AffiliateAPIPostAffiliateApplyRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateApplication
|
|
func (a *AffiliateAPIService) PostAffiliateApplyExecute(r AffiliateAPIPostAffiliateApplyRequest) (*AffiliateApplication, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateApplication
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.PostAffiliateApply")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/apply"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.affiliateApplyRequest == nil {
|
|
return localVarReturnValue, nil, reportError("affiliateApplyRequest is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.affiliateApplyRequest
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIPostAffiliateAttributeRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
affiliateAttributeRequest *AffiliateAttributeRequest
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateAttributeRequest) AffiliateAttributeRequest(affiliateAttributeRequest AffiliateAttributeRequest) AffiliateAPIPostAffiliateAttributeRequest {
|
|
r.affiliateAttributeRequest = &affiliateAttributeRequest
|
|
return r
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateAttributeRequest) Execute() (*AffiliateAttribution, *http.Response, error) {
|
|
return r.ApiService.PostAffiliateAttributeExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostAffiliateAttribute Records the first-touch edge every later commission is computed from: the caller's org was referred by the affiliate that owns this code.
|
|
|
|
Records the first-touch edge every later commission is computed
|
|
from: the caller's org was referred by the affiliate that owns this code.
|
|
|
|
The REFERRED org is the validated caller, never a field. A caller that could
|
|
name the referred org could attach itself to somebody else's revenue. The
|
|
affiliate is resolved from the code, and only an APPROVED affiliate's code
|
|
resolves.
|
|
|
|
FIRST TOUCH WINS, set once: one affiliate per referred org, so a re-post
|
|
answers the existing edge with `created:false` rather than moving the
|
|
attribution. Self-attribution is refused, and so is a code that would make a
|
|
cycle in the upline chain. An unknown code is a 404, deliberately: an
|
|
affiliate code IS a public shareable link, so whether one is real is public by
|
|
design, and the caller legitimately needs to know its link resolved.
|
|
|
|
A user-level mirror of the edge is written best-effort; a conflict there never
|
|
fails the org attribution, which is the money-bearing one.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIPostAffiliateAttributeRequest
|
|
*/
|
|
func (a *AffiliateAPIService) PostAffiliateAttribute(ctx context.Context) AffiliateAPIPostAffiliateAttributeRequest {
|
|
return AffiliateAPIPostAffiliateAttributeRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateAttribution
|
|
func (a *AffiliateAPIService) PostAffiliateAttributeExecute(r AffiliateAPIPostAffiliateAttributeRequest) (*AffiliateAttribution, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateAttribution
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.PostAffiliateAttribute")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/attribute"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.affiliateAttributeRequest == nil {
|
|
return localVarReturnValue, nil, reportError("affiliateAttributeRequest is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.affiliateAttributeRequest
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIPostAffiliateClickRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
affiliateClickRequest *AffiliateClickRequest
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateClickRequest) AffiliateClickRequest(affiliateClickRequest AffiliateClickRequest) AffiliateAPIPostAffiliateClickRequest {
|
|
r.affiliateClickRequest = &affiliateClickRequest
|
|
return r
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateClickRequest) Execute() (*AffiliateClickCount, *http.Response, error) {
|
|
return r.ApiService.PostAffiliateClickExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostAffiliateClick Counts a click on a share link.
|
|
|
|
Counts a click on a share link. PUBLIC — it takes no principal, because
|
|
a visitor clicking a shareable link has no session yet.
|
|
|
|
The ping folds into an in-memory buffer and NEVER writes the money database
|
|
synchronously, so a click flood cannot contend with the accrual and payout
|
|
write path; tallies are flushed in one batch on the next authenticated links
|
|
read and at shutdown. Clicks are a vanity metric: no accrual and no payout
|
|
ever reads them — those key on real metered spend — so click inflation cannot
|
|
move money.
|
|
|
|
Any well-formed code is accepted WITHOUT checking that it exists,
|
|
deliberately: this is not a code-existence oracle. `counted` reports that the
|
|
buffer took the ping, not that the code is real; an unknown code simply no-ops
|
|
at flush time.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIPostAffiliateClickRequest
|
|
*/
|
|
func (a *AffiliateAPIService) PostAffiliateClick(ctx context.Context) AffiliateAPIPostAffiliateClickRequest {
|
|
return AffiliateAPIPostAffiliateClickRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateClickCount
|
|
func (a *AffiliateAPIService) PostAffiliateClickExecute(r AffiliateAPIPostAffiliateClickRequest) (*AffiliateClickCount, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateClickCount
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.PostAffiliateClick")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/click"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.affiliateClickRequest == nil {
|
|
return localVarReturnValue, nil, reportError("affiliateClickRequest is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.affiliateClickRequest
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIPostAffiliateMeHandleRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
affiliateHandleRequest *AffiliateHandleRequest
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateMeHandleRequest) AffiliateHandleRequest(affiliateHandleRequest AffiliateHandleRequest) AffiliateAPIPostAffiliateMeHandleRequest {
|
|
r.affiliateHandleRequest = &affiliateHandleRequest
|
|
return r
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateMeHandleRequest) Execute() (*AffiliateHandleSet, *http.Response, error) {
|
|
return r.ApiService.PostAffiliateMeHandleExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostAffiliateMeHandle Sets the caller's public leaderboard display name, or clears it.
|
|
|
|
Sets the caller's public leaderboard display name, or clears it.
|
|
|
|
The handle IS the opt-in. An empty handle opts out: the affiliate keeps its
|
|
rank and can still see its own row, it simply stops being listed to anyone
|
|
else. That is the whole privacy control — there is no separate visibility
|
|
flag, and no way to be listed without choosing a name.
|
|
|
|
Requires a validated principal and an existing affiliate record; apply first.
|
|
The handle is bounded and restricted to letters, digits, space, hyphen,
|
|
underscore and dot.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIPostAffiliateMeHandleRequest
|
|
*/
|
|
func (a *AffiliateAPIService) PostAffiliateMeHandle(ctx context.Context) AffiliateAPIPostAffiliateMeHandleRequest {
|
|
return AffiliateAPIPostAffiliateMeHandleRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateHandleSet
|
|
func (a *AffiliateAPIService) PostAffiliateMeHandleExecute(r AffiliateAPIPostAffiliateMeHandleRequest) (*AffiliateHandleSet, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateHandleSet
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.PostAffiliateMeHandle")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/me/handle"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.affiliateHandleRequest == nil {
|
|
return localVarReturnValue, nil, reportError("affiliateHandleRequest is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.affiliateHandleRequest
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type AffiliateAPIPostAffiliateMeLinksRequest struct {
|
|
ctx context.Context
|
|
ApiService *AffiliateAPIService
|
|
affiliateCreateLinkRequest *AffiliateCreateLinkRequest
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateMeLinksRequest) AffiliateCreateLinkRequest(affiliateCreateLinkRequest AffiliateCreateLinkRequest) AffiliateAPIPostAffiliateMeLinksRequest {
|
|
r.affiliateCreateLinkRequest = &affiliateCreateLinkRequest
|
|
return r
|
|
}
|
|
|
|
func (r AffiliateAPIPostAffiliateMeLinksRequest) Execute() (*AffiliateLinkMint, *http.Response, error) {
|
|
return r.ApiService.PostAffiliateMeLinksExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostAffiliateMeLinks Mints a new share link for the caller's own affiliate and answers it with its full URL, 201.
|
|
|
|
Mints a new share link for the caller's own affiliate and answers it
|
|
with its full URL, 201.
|
|
|
|
APPROVAL IS REQUIRED: an org that has applied but is not approved is refused,
|
|
because a link that cannot accrue is a link that quietly loses the referral. A
|
|
requested vanity code must be valid and free across the WHOLE directory —
|
|
codes are one global namespace, so a taken code is a 409 rather than a silent
|
|
alias. Omit the code and a random one is minted.
|
|
|
|
Bounded per affiliate. The label is cosmetic: it is trimmed, stripped of
|
|
control characters and capped, and it is never part of a code.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AffiliateAPIPostAffiliateMeLinksRequest
|
|
*/
|
|
func (a *AffiliateAPIService) PostAffiliateMeLinks(ctx context.Context) AffiliateAPIPostAffiliateMeLinksRequest {
|
|
return AffiliateAPIPostAffiliateMeLinksRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AffiliateLinkMint
|
|
func (a *AffiliateAPIService) PostAffiliateMeLinksExecute(r AffiliateAPIPostAffiliateMeLinksRequest) (*AffiliateLinkMint, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AffiliateLinkMint
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AffiliateAPIService.PostAffiliateMeLinks")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/affiliate/me/links"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.affiliateCreateLinkRequest == nil {
|
|
return localVarReturnValue, nil, reportError("affiliateCreateLinkRequest is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.affiliateCreateLinkRequest
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|