mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
651 lines
23 KiB
Go
651 lines
23 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"
|
|
"strings"
|
|
)
|
|
|
|
// TaxonomyAPIService TaxonomyAPI service
|
|
type TaxonomyAPIService service
|
|
|
|
type TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest struct {
|
|
ctx context.Context
|
|
ApiService *TaxonomyAPIService
|
|
id string
|
|
}
|
|
|
|
func (r TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest) Execute() (*TaxonomyDeleted, *http.Response, error) {
|
|
return r.ApiService.DeleteTaxonomyCategoriesByIdExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteTaxonomyCategoriesById Removes one empty category.
|
|
|
|
Removes one empty category. A category that still has taxa
|
|
filed under it is refused with 409 and a count: deleting the label off a group
|
|
must never silently take the products wearing it, and the alternative — orphan
|
|
rows naming a category that no longer exists — is a catalogue that cannot be
|
|
rendered. Move or delete its taxa first. An id no category holds is a 404.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param id ID is the slug to act on, from the path.
|
|
@return TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest
|
|
*/
|
|
func (a *TaxonomyAPIService) DeleteTaxonomyCategoriesById(ctx context.Context, id string) TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest {
|
|
return TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return TaxonomyDeleted
|
|
func (a *TaxonomyAPIService) DeleteTaxonomyCategoriesByIdExecute(r TaxonomyAPIDeleteTaxonomyCategoriesByIdRequest) (*TaxonomyDeleted, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *TaxonomyDeleted
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaxonomyAPIService.DeleteTaxonomyCategoriesById")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/taxonomy/categories/{id}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
|
|
|
|
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 TaxonomyAPIDeleteTaxonomyTaxaByIdRequest struct {
|
|
ctx context.Context
|
|
ApiService *TaxonomyAPIService
|
|
id string
|
|
}
|
|
|
|
func (r TaxonomyAPIDeleteTaxonomyTaxaByIdRequest) Execute() (*TaxonomyDeleted, *http.Response, error) {
|
|
return r.ApiService.DeleteTaxonomyTaxaByIdExecute(r)
|
|
}
|
|
|
|
/*
|
|
DeleteTaxonomyTaxaById Removes one product from the catalogue.
|
|
|
|
Removes one product from the catalogue. An id no taxon holds is a
|
|
404. To take a product out of view without losing what was written about it, set
|
|
`published` to false instead.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param id ID is the slug to act on, from the path.
|
|
@return TaxonomyAPIDeleteTaxonomyTaxaByIdRequest
|
|
*/
|
|
func (a *TaxonomyAPIService) DeleteTaxonomyTaxaById(ctx context.Context, id string) TaxonomyAPIDeleteTaxonomyTaxaByIdRequest {
|
|
return TaxonomyAPIDeleteTaxonomyTaxaByIdRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return TaxonomyDeleted
|
|
func (a *TaxonomyAPIService) DeleteTaxonomyTaxaByIdExecute(r TaxonomyAPIDeleteTaxonomyTaxaByIdRequest) (*TaxonomyDeleted, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodDelete
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *TaxonomyDeleted
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaxonomyAPIService.DeleteTaxonomyTaxaById")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/taxonomy/taxa/{id}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
|
|
|
|
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 TaxonomyAPIGetTaxonomyRequest struct {
|
|
ctx context.Context
|
|
ApiService *TaxonomyAPIService
|
|
brand *string
|
|
}
|
|
|
|
// Brand returns only what that brand's console shows — the categories it admits, and within them the taxa scoped to it. Empty returns everything.
|
|
func (r TaxonomyAPIGetTaxonomyRequest) Brand(brand string) TaxonomyAPIGetTaxonomyRequest {
|
|
r.brand = &brand
|
|
return r
|
|
}
|
|
|
|
func (r TaxonomyAPIGetTaxonomyRequest) Execute() (*TaxonomyTaxonomy, *http.Response, error) {
|
|
return r.ApiService.GetTaxonomyExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetTaxonomy Returns the product catalogue as this caller sees it: the PLATFORM catalogue — Hanzo's own products, the part that is true for everyone — plus the caller's own org's rows, every category in display order and each carrying the products filed under it in theirs.
|
|
|
|
Returns the product catalogue as this caller sees it: the PLATFORM
|
|
catalogue — Hanzo's own products, the part that is true for everyone — plus the
|
|
caller's own org's rows, every category in display order and each carrying the
|
|
products filed under it in theirs. Another customer's rows are never in it. It
|
|
is readable signed out, and a signed-out visitor gets the platform catalogue
|
|
alone, which is what the marketing landing renders from.
|
|
|
|
Where the caller's org and the platform hold the same id, the caller's own row
|
|
is the one served. That rule exists because ids are unique per ORG and not
|
|
globally — two customers may each have a "crm", and refusing the second would
|
|
tell one of them the other exists — so a collision with the platform is possible
|
|
by construction and something has to win deterministically. Yours does: your own
|
|
catalogue is the one you edited.
|
|
|
|
`?brand=` narrows it the way a brand's own console does: only the categories
|
|
that brand admits, and within them only the taxa scoped to it. An unpublished
|
|
row is served only to whoever may edit it — a SuperAdmin for the platform's, an
|
|
org admin for their own — so a product can be staged before anyone sees it
|
|
without becoming invisible to the person staging it.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return TaxonomyAPIGetTaxonomyRequest
|
|
*/
|
|
func (a *TaxonomyAPIService) GetTaxonomy(ctx context.Context) TaxonomyAPIGetTaxonomyRequest {
|
|
return TaxonomyAPIGetTaxonomyRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return TaxonomyTaxonomy
|
|
func (a *TaxonomyAPIService) GetTaxonomyExecute(r TaxonomyAPIGetTaxonomyRequest) (*TaxonomyTaxonomy, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *TaxonomyTaxonomy
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaxonomyAPIService.GetTaxonomy")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/taxonomy"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.brand != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "brand", r.brand, "form", "")
|
|
}
|
|
// 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 TaxonomyAPIPutTaxonomyCategoriesByIdRequest struct {
|
|
ctx context.Context
|
|
ApiService *TaxonomyAPIService
|
|
id string
|
|
taxonomyCategoryIn *TaxonomyCategoryIn
|
|
}
|
|
|
|
func (r TaxonomyAPIPutTaxonomyCategoriesByIdRequest) TaxonomyCategoryIn(taxonomyCategoryIn TaxonomyCategoryIn) TaxonomyAPIPutTaxonomyCategoriesByIdRequest {
|
|
r.taxonomyCategoryIn = &taxonomyCategoryIn
|
|
return r
|
|
}
|
|
|
|
func (r TaxonomyAPIPutTaxonomyCategoriesByIdRequest) Execute() (*TaxonomyCategory, *http.Response, error) {
|
|
return r.ApiService.PutTaxonomyCategoriesByIdExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutTaxonomyCategoriesById Creates or replaces one category and returns it as stored.
|
|
|
|
Creates or replaces one category and returns it as stored. The id in
|
|
the URL is the one it is filed under whatever the body says, so a category can
|
|
never be written under a name it was not addressed by — which also makes create
|
|
and replace the same act, and is why there is no POST beside this.
|
|
|
|
Platform SuperAdmin only: one catalogue serves every tenant, so an org admin who
|
|
could rename a category would rename it for all of them.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param id ID is the category slug to write, from the path.
|
|
@return TaxonomyAPIPutTaxonomyCategoriesByIdRequest
|
|
*/
|
|
func (a *TaxonomyAPIService) PutTaxonomyCategoriesById(ctx context.Context, id string) TaxonomyAPIPutTaxonomyCategoriesByIdRequest {
|
|
return TaxonomyAPIPutTaxonomyCategoriesByIdRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return TaxonomyCategory
|
|
func (a *TaxonomyAPIService) PutTaxonomyCategoriesByIdExecute(r TaxonomyAPIPutTaxonomyCategoriesByIdRequest) (*TaxonomyCategory, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *TaxonomyCategory
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaxonomyAPIService.PutTaxonomyCategoriesById")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/taxonomy/categories/{id}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.taxonomyCategoryIn == nil {
|
|
return localVarReturnValue, nil, reportError("taxonomyCategoryIn 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.taxonomyCategoryIn
|
|
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 TaxonomyAPIPutTaxonomyTaxaByIdRequest struct {
|
|
ctx context.Context
|
|
ApiService *TaxonomyAPIService
|
|
id string
|
|
taxonomyTaxonIn *TaxonomyTaxonIn
|
|
}
|
|
|
|
func (r TaxonomyAPIPutTaxonomyTaxaByIdRequest) TaxonomyTaxonIn(taxonomyTaxonIn TaxonomyTaxonIn) TaxonomyAPIPutTaxonomyTaxaByIdRequest {
|
|
r.taxonomyTaxonIn = &taxonomyTaxonIn
|
|
return r
|
|
}
|
|
|
|
func (r TaxonomyAPIPutTaxonomyTaxaByIdRequest) Execute() (*TaxonomyTaxon, *http.Response, error) {
|
|
return r.ApiService.PutTaxonomyTaxaByIdExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutTaxonomyTaxaById Creates or replaces one product and returns it as stored.
|
|
|
|
Creates or replaces one product and returns it as stored. The id in the
|
|
URL is the one it is filed under whatever the body says. The category must
|
|
already exist — a taxon naming a category that does not is refused with 400
|
|
rather than stored where nothing can render it.
|
|
|
|
A taxon opens exactly one way: `route` for a product the console renders
|
|
itself, or `href` for one that genuinely lives at its own domain. Giving both,
|
|
or neither, is refused.
|
|
|
|
Platform SuperAdmin only.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param id ID is the taxon slug to write, from the path.
|
|
@return TaxonomyAPIPutTaxonomyTaxaByIdRequest
|
|
*/
|
|
func (a *TaxonomyAPIService) PutTaxonomyTaxaById(ctx context.Context, id string) TaxonomyAPIPutTaxonomyTaxaByIdRequest {
|
|
return TaxonomyAPIPutTaxonomyTaxaByIdRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return TaxonomyTaxon
|
|
func (a *TaxonomyAPIService) PutTaxonomyTaxaByIdExecute(r TaxonomyAPIPutTaxonomyTaxaByIdRequest) (*TaxonomyTaxon, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *TaxonomyTaxon
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TaxonomyAPIService.PutTaxonomyTaxaById")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/taxonomy/taxa/{id}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.taxonomyTaxonIn == nil {
|
|
return localVarReturnValue, nil, reportError("taxonomyTaxonIn 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.taxonomyTaxonIn
|
|
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
|
|
}
|