diff --git a/api/oas_client_gen.go b/api/oas_client_gen.go index 4211a03..0d31939 100644 --- a/api/oas_client_gen.go +++ b/api/oas_client_gen.go @@ -59,6 +59,10 @@ type Invoker interface { // // GET /payments PaymentsGet(ctx context.Context, params PaymentsGetParams) (PaymentsGetRes, error) + // PaymentsIDCancelPut invokes PUT /payments/{id}/cancel operation. + // + // PUT /payments/{id}/cancel + PaymentsIDCancelPut(ctx context.Context, request PaymentsIDCancelPutReq, params PaymentsIDCancelPutParams) (PaymentsIDCancelPutRes, error) // PaymentsIDGet invokes GET /payments/{id} operation. // // GET /payments/{id} @@ -1557,6 +1561,130 @@ func (c *Client) sendPaymentsGet(ctx context.Context, params PaymentsGetParams) return result, nil } +// PaymentsIDCancelPut invokes PUT /payments/{id}/cancel operation. +// +// PUT /payments/{id}/cancel +func (c *Client) PaymentsIDCancelPut(ctx context.Context, request PaymentsIDCancelPutReq, params PaymentsIDCancelPutParams) (PaymentsIDCancelPutRes, error) { + res, err := c.sendPaymentsIDCancelPut(ctx, request, params) + return res, err +} + +func (c *Client) sendPaymentsIDCancelPut(ctx context.Context, request PaymentsIDCancelPutReq, params PaymentsIDCancelPutParams) (res PaymentsIDCancelPutRes, err error) { + otelAttrs := []attribute.KeyValue{ + semconv.HTTPMethodKey.String("PUT"), + semconv.HTTPRouteKey.String("/payments/{id}/cancel"), + } + + // Run stopwatch. + startTime := time.Now() + defer func() { + // Use floating point division here for higher precision (instead of Millisecond method). + elapsedDuration := time.Since(startTime) + c.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), metric.WithAttributes(otelAttrs...)) + }() + + // Increment request counter. + c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) + + // Start a span for this request. + ctx, span := c.cfg.Tracer.Start(ctx, "PaymentsIDCancelPut", + trace.WithAttributes(otelAttrs...), + clientSpanKind, + ) + // Track stage for error reporting. + var stage string + defer func() { + if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) + } + span.End() + }() + + stage = "BuildURL" + u := uri.Clone(c.requestURL(ctx)) + var pathParts [3]string + pathParts[0] = "/payments/" + { + // Encode "id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.ID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[1] = encoded + } + pathParts[2] = "/cancel" + uri.AddPathParts(u, pathParts[:]...) + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "PUT", u) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodePaymentsIDCancelPutRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") + } + + { + type bitset = [1]uint8 + var satisfied bitset + { + stage = "Security:BearerAuth" + switch err := c.securityBearerAuth(ctx, "PaymentsIDCancelPut", r); { + case err == nil: // if NO error + satisfied[0] |= 1 << 0 + case errors.Is(err, ogenerrors.ErrSkipClientSecurity): + // Skip this security. + default: + return res, errors.Wrap(err, "security \"BearerAuth\"") + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied + } + } + + stage = "SendRequest" + resp, err := c.cfg.Client.Do(r) + if err != nil { + return res, errors.Wrap(err, "do request") + } + defer resp.Body.Close() + + stage = "DecodeResponse" + result, err := decodePaymentsIDCancelPutResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + // PaymentsIDGet invokes GET /payments/{id} operation. // // GET /payments/{id} diff --git a/api/oas_handlers_gen.go b/api/oas_handlers_gen.go index 6c0cbda..d0ebf6f 100644 --- a/api/oas_handlers_gen.go +++ b/api/oas_handlers_gen.go @@ -1495,6 +1495,174 @@ func (s *Server) handlePaymentsGetRequest(args [0]string, argsEscaped bool, w ht } } +// handlePaymentsIDCancelPutRequest handles PUT /payments/{id}/cancel operation. +// +// PUT /payments/{id}/cancel +func (s *Server) handlePaymentsIDCancelPutRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + semconv.HTTPMethodKey.String("PUT"), + semconv.HTTPRouteKey.String("/payments/{id}/cancel"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "PaymentsIDCancelPut", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "PaymentsIDCancelPut", + ID: "", + } + ) + { + type bitset = [1]uint8 + var satisfied bitset + { + sctx, ok, err := s.securityBearerAuth(ctx, "PaymentsIDCancelPut", r) + if err != nil { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Security: "BearerAuth", + Err: err, + } + defer recordError("Security:BearerAuth", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + if ok { + satisfied[0] |= 1 << 0 + ctx = sctx + } + } + + if ok := func() bool { + nextRequirement: + for _, requirement := range []bitset{ + {0b00000001}, + } { + for i, mask := range requirement { + if satisfied[i]&mask != mask { + continue nextRequirement + } + } + return true + } + return false + }(); !ok { + err = &ogenerrors.SecurityError{ + OperationContext: opErrContext, + Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, + } + defer recordError("Security", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + } + params, err := decodePaymentsIDCancelPutParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + request, close, err := s.decodePaymentsIDCancelPutRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response PaymentsIDCancelPutRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "PaymentsIDCancelPut", + OperationSummary: "", + OperationID: "", + Body: request, + Params: middleware.Parameters{ + { + Name: "id", + In: "path", + }: params.ID, + }, + Raw: r, + } + + type ( + Request = PaymentsIDCancelPutReq + Params = PaymentsIDCancelPutParams + Response = PaymentsIDCancelPutRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackPaymentsIDCancelPutParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.PaymentsIDCancelPut(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.PaymentsIDCancelPut(ctx, request, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodePaymentsIDCancelPutResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handlePaymentsIDGetRequest handles GET /payments/{id} operation. // // GET /payments/{id} diff --git a/api/oas_interfaces_gen.go b/api/oas_interfaces_gen.go index 1e83851..93bdc19 100644 --- a/api/oas_interfaces_gen.go +++ b/api/oas_interfaces_gen.go @@ -37,6 +37,10 @@ type PaymentsGetRes interface { paymentsGetRes() } +type PaymentsIDCancelPutRes interface { + paymentsIDCancelPutRes() +} + type PaymentsIDGetRes interface { paymentsIDGetRes() } diff --git a/api/oas_json_gen.go b/api/oas_json_gen.go index b253448..de8b1bd 100644 --- a/api/oas_json_gen.go +++ b/api/oas_json_gen.go @@ -2356,6 +2356,202 @@ func (s *OptInt) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes PaymentCancelCardResponseMethod as json. +func (o OptNilPaymentCancelCardResponseMethod) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseMethod from json. +func (o *OptNilPaymentCancelCardResponseMethod) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilPaymentCancelCardResponseMethod to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v PaymentCancelCardResponseMethod + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilPaymentCancelCardResponseMethod) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilPaymentCancelCardResponseMethod) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardResponseTds2Status as json. +func (o OptNilPaymentCancelCardResponseTds2Status) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseTds2Status from json. +func (o *OptNilPaymentCancelCardResponseTds2Status) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilPaymentCancelCardResponseTds2Status to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v PaymentCancelCardResponseTds2Status + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilPaymentCancelCardResponseTds2Status) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilPaymentCancelCardResponseTds2Status) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardResponseTds2Type as json. +func (o OptNilPaymentCancelCardResponseTds2Type) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseTds2Type from json. +func (o *OptNilPaymentCancelCardResponseTds2Type) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilPaymentCancelCardResponseTds2Type to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v PaymentCancelCardResponseTds2Type + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilPaymentCancelCardResponseTds2Type) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilPaymentCancelCardResponseTds2Type) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardResponseTdsType as json. +func (o OptNilPaymentCancelCardResponseTdsType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseTdsType from json. +func (o *OptNilPaymentCancelCardResponseTdsType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilPaymentCancelCardResponseTdsType to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v PaymentCancelCardResponseTdsType + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilPaymentCancelCardResponseTdsType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilPaymentCancelCardResponseTdsType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes PaymentCardResponseMethod as json. func (o OptNilPaymentCardResponseMethod) Encode(e *jx.Encoder) { if !o.Set { @@ -3926,6 +4122,105 @@ func (s *OptNilString) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes PaymentCancelCardResponseJobCode as json. +func (o OptPaymentCancelCardResponseJobCode) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseJobCode from json. +func (o *OptPaymentCancelCardResponseJobCode) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentCancelCardResponseJobCode to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentCancelCardResponseJobCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentCancelCardResponseJobCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardResponsePayType as json. +func (o OptPaymentCancelCardResponsePayType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponsePayType from json. +func (o *OptPaymentCancelCardResponsePayType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentCancelCardResponsePayType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentCancelCardResponsePayType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentCancelCardResponsePayType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardResponseStatus as json. +func (o OptPaymentCancelCardResponseStatus) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentCancelCardResponseStatus from json. +func (o *OptPaymentCancelCardResponseStatus) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentCancelCardResponseStatus to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentCancelCardResponseStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentCancelCardResponseStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes PaymentCardResponseJobCode as json. func (o OptPaymentCardResponseJobCode) Encode(e *jx.Encoder) { if !o.Set { @@ -4492,296 +4787,1450 @@ func (o OptPaymentMethodDirectDebitResponseDirectdebitAccountType) Encode(e *jx. if !o.Set { return } - e.Str(string(o.Value)) -} + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseDirectdebitAccountType from json. +func (o *OptPaymentMethodDirectDebitResponseDirectdebitAccountType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitAccountType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseDirectdebitAccountType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseDirectdebitAccountType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseDirectdebitApplicationType as json. +func (o OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseDirectdebitApplicationType from json. +func (o *OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitApplicationType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseDirectdebitBankType as json. +func (o OptPaymentMethodDirectDebitResponseDirectdebitBankType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseDirectdebitBankType from json. +func (o *OptPaymentMethodDirectDebitResponseDirectdebitBankType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitBankType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseDirectdebitBankType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseDirectdebitBankType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseDirectdebitLastResultCode as json. +func (o OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseDirectdebitLastResultCode from json. +func (o *OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseDirectdebitPaperApplication as json. +func (o OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes PaymentMethodDirectDebitResponseDirectdebitPaperApplication from json. +func (o *OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponsePayType as json. +func (o OptPaymentMethodDirectDebitResponsePayType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponsePayType from json. +func (o *OptPaymentMethodDirectDebitResponsePayType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponsePayType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponsePayType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponsePayType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseRedirectURLAccessedFlag as json. +func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseRedirectURLAccessedFlag from json. +func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentMethodDirectDebitResponseStatus as json. +func (o OptPaymentMethodDirectDebitResponseStatus) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes PaymentMethodDirectDebitResponseStatus from json. +func (o *OptPaymentMethodDirectDebitResponseStatus) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseStatus to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptPaymentMethodDirectDebitResponseStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptPaymentMethodDirectDebitResponseStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes string as json. +func (o OptString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptString to nil") + } + o.Set = true + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *PaymentCancelCard) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *PaymentCancelCard) encodeFields(e *jx.Encoder) { + { + e.FieldStart("pay_type") + s.PayType.Encode(e) + } + { + e.FieldStart("access_id") + e.Str(s.AccessID) + } +} + +var jsonFieldsNameOfPaymentCancelCard = [2]string{ + 0: "pay_type", + 1: "access_id", +} + +// Decode decodes PaymentCancelCard from json. +func (s *PaymentCancelCard) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCard to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "pay_type": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.PayType.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"pay_type\"") + } + case "access_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.AccessID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"access_id\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode PaymentCancelCard") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfPaymentCancelCard) { + name = jsonFieldsNameOfPaymentCancelCard[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *PaymentCancelCard) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PaymentCancelCard) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentCancelCardPayType as json. +func (s PaymentCancelCardPayType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes PaymentCancelCardPayType from json. +func (s *PaymentCancelCardPayType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardPayType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch PaymentCancelCardPayType(v) { + case PaymentCancelCardPayTypeCard: + *s = PaymentCancelCardPayTypeCard + default: + *s = PaymentCancelCardPayType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s PaymentCancelCardPayType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PaymentCancelCardPayType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *PaymentCancelCardResponse) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *PaymentCancelCardResponse) encodeFields(e *jx.Encoder) { + { + if s.ShopID.Set { + e.FieldStart("shop_id") + s.ShopID.Encode(e) + } + } + { + if s.ID.Set { + e.FieldStart("id") + s.ID.Encode(e) + } + } + { + if s.PayType.Set { + e.FieldStart("pay_type") + s.PayType.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.AccessID.Set { + e.FieldStart("access_id") + s.AccessID.Encode(e) + } + } + { + if s.ProcessDate.Set { + e.FieldStart("process_date") + s.ProcessDate.Encode(e) + } + } + { + if s.JobCode.Set { + e.FieldStart("job_code") + s.JobCode.Encode(e) + } + } + { + if s.ItemCode.Set { + e.FieldStart("item_code") + s.ItemCode.Encode(e) + } + } + { + if s.Amount.Set { + e.FieldStart("amount") + s.Amount.Encode(e) + } + } + { + if s.Tax.Set { + e.FieldStart("tax") + s.Tax.Encode(e) + } + } + { + if s.TotalAmount.Set { + e.FieldStart("total_amount") + s.TotalAmount.Encode(e) + } + } + { + if s.CustomerGroupID.Set { + e.FieldStart("customer_group_id") + s.CustomerGroupID.Encode(e) + } + } + { + if s.CustomerID.Set { + e.FieldStart("customer_id") + s.CustomerID.Encode(e) + } + } + { + if s.CardNo.Set { + e.FieldStart("card_no") + s.CardNo.Encode(e) + } + } + { + if s.CardID.Set { + e.FieldStart("card_id") + s.CardID.Encode(e) + } + } + { + if s.Expire.Set { + e.FieldStart("expire") + s.Expire.Encode(e) + } + } + { + if s.HolderName.Set { + e.FieldStart("holder_name") + s.HolderName.Encode(e) + } + } + { + if s.CardNoHash.Set { + e.FieldStart("card_no_hash") + s.CardNoHash.Encode(e) + } + } + { + if s.Method.Set { + e.FieldStart("method") + s.Method.Encode(e) + } + } + { + if s.PayTimes.Set { + e.FieldStart("pay_times") + s.PayTimes.Encode(e) + } + } + { + if s.Forward.Set { + e.FieldStart("forward") + s.Forward.Encode(e) + } + } + { + if s.Issuer.Set { + e.FieldStart("issuer") + s.Issuer.Encode(e) + } + } + { + if s.TransactionID.Set { + e.FieldStart("transaction_id") + s.TransactionID.Encode(e) + } + } + { + if s.Approve.Set { + e.FieldStart("approve") + s.Approve.Encode(e) + } + } + { + if s.AuthMaxDate.Set { + e.FieldStart("auth_max_date") + s.AuthMaxDate.Encode(e) + } + } + { + if s.ClientField1.Set { + e.FieldStart("client_field_1") + s.ClientField1.Encode(e) + } + } + { + if s.ClientField2.Set { + e.FieldStart("client_field_2") + s.ClientField2.Encode(e) + } + } + { + if s.ClientField3.Set { + e.FieldStart("client_field_3") + s.ClientField3.Encode(e) + } + } + { + if s.TdsType.Set { + e.FieldStart("tds_type") + s.TdsType.Encode(e) + } + } + { + if s.Tds2Type.Set { + e.FieldStart("tds2_type") + s.Tds2Type.Encode(e) + } + } + { + if s.Tds2RetURL.Set { + e.FieldStart("tds2_ret_url") + s.Tds2RetURL.Encode(e) + } + } + { + if s.Tds2Status.Set { + e.FieldStart("tds2_status") + s.Tds2Status.Encode(e) + } + } + { + if s.MerchantName.Set { + e.FieldStart("merchant_name") + s.MerchantName.Encode(e) + } + } + { + if s.SendURL.Set { + e.FieldStart("send_url") + s.SendURL.Encode(e) + } + } + { + if s.SubscriptionID.Set { + e.FieldStart("subscription_id") + s.SubscriptionID.Encode(e) + } + } + { + if s.Brand.Set { + e.FieldStart("brand") + s.Brand.Encode(e) + } + } + { + if s.ErrorCode.Set { + e.FieldStart("error_code") + s.ErrorCode.Encode(e) + } + } + { + if s.Created.Set { + e.FieldStart("created") + s.Created.Encode(e) + } + } + { + if s.Updated.Set { + e.FieldStart("updated") + s.Updated.Encode(e) + } + } +} + +var jsonFieldsNameOfPaymentCancelCardResponse = [39]string{ + 0: "shop_id", + 1: "id", + 2: "pay_type", + 3: "status", + 4: "access_id", + 5: "process_date", + 6: "job_code", + 7: "item_code", + 8: "amount", + 9: "tax", + 10: "total_amount", + 11: "customer_group_id", + 12: "customer_id", + 13: "card_no", + 14: "card_id", + 15: "expire", + 16: "holder_name", + 17: "card_no_hash", + 18: "method", + 19: "pay_times", + 20: "forward", + 21: "issuer", + 22: "transaction_id", + 23: "approve", + 24: "auth_max_date", + 25: "client_field_1", + 26: "client_field_2", + 27: "client_field_3", + 28: "tds_type", + 29: "tds2_type", + 30: "tds2_ret_url", + 31: "tds2_status", + 32: "merchant_name", + 33: "send_url", + 34: "subscription_id", + 35: "brand", + 36: "error_code", + 37: "created", + 38: "updated", +} + +// Decode decodes PaymentCancelCardResponse from json. +func (s *PaymentCancelCardResponse) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponse to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "shop_id": + if err := func() error { + s.ShopID.Reset() + if err := s.ShopID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"shop_id\"") + } + case "id": + if err := func() error { + s.ID.Reset() + if err := s.ID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "pay_type": + if err := func() error { + s.PayType.Reset() + if err := s.PayType.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"pay_type\"") + } + case "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "access_id": + if err := func() error { + s.AccessID.Reset() + if err := s.AccessID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"access_id\"") + } + case "process_date": + if err := func() error { + s.ProcessDate.Reset() + if err := s.ProcessDate.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"process_date\"") + } + case "job_code": + if err := func() error { + s.JobCode.Reset() + if err := s.JobCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"job_code\"") + } + case "item_code": + if err := func() error { + s.ItemCode.Reset() + if err := s.ItemCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"item_code\"") + } + case "amount": + if err := func() error { + s.Amount.Reset() + if err := s.Amount.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"amount\"") + } + case "tax": + if err := func() error { + s.Tax.Reset() + if err := s.Tax.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tax\"") + } + case "total_amount": + if err := func() error { + s.TotalAmount.Reset() + if err := s.TotalAmount.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"total_amount\"") + } + case "customer_group_id": + if err := func() error { + s.CustomerGroupID.Reset() + if err := s.CustomerGroupID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"customer_group_id\"") + } + case "customer_id": + if err := func() error { + s.CustomerID.Reset() + if err := s.CustomerID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"customer_id\"") + } + case "card_no": + if err := func() error { + s.CardNo.Reset() + if err := s.CardNo.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card_no\"") + } + case "card_id": + if err := func() error { + s.CardID.Reset() + if err := s.CardID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card_id\"") + } + case "expire": + if err := func() error { + s.Expire.Reset() + if err := s.Expire.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"expire\"") + } + case "holder_name": + if err := func() error { + s.HolderName.Reset() + if err := s.HolderName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"holder_name\"") + } + case "card_no_hash": + if err := func() error { + s.CardNoHash.Reset() + if err := s.CardNoHash.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"card_no_hash\"") + } + case "method": + if err := func() error { + s.Method.Reset() + if err := s.Method.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"method\"") + } + case "pay_times": + if err := func() error { + s.PayTimes.Reset() + if err := s.PayTimes.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"pay_times\"") + } + case "forward": + if err := func() error { + s.Forward.Reset() + if err := s.Forward.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"forward\"") + } + case "issuer": + if err := func() error { + s.Issuer.Reset() + if err := s.Issuer.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"issuer\"") + } + case "transaction_id": + if err := func() error { + s.TransactionID.Reset() + if err := s.TransactionID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"transaction_id\"") + } + case "approve": + if err := func() error { + s.Approve.Reset() + if err := s.Approve.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"approve\"") + } + case "auth_max_date": + if err := func() error { + s.AuthMaxDate.Reset() + if err := s.AuthMaxDate.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"auth_max_date\"") + } + case "client_field_1": + if err := func() error { + s.ClientField1.Reset() + if err := s.ClientField1.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"client_field_1\"") + } + case "client_field_2": + if err := func() error { + s.ClientField2.Reset() + if err := s.ClientField2.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"client_field_2\"") + } + case "client_field_3": + if err := func() error { + s.ClientField3.Reset() + if err := s.ClientField3.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"client_field_3\"") + } + case "tds_type": + if err := func() error { + s.TdsType.Reset() + if err := s.TdsType.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tds_type\"") + } + case "tds2_type": + if err := func() error { + s.Tds2Type.Reset() + if err := s.Tds2Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tds2_type\"") + } + case "tds2_ret_url": + if err := func() error { + s.Tds2RetURL.Reset() + if err := s.Tds2RetURL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tds2_ret_url\"") + } + case "tds2_status": + if err := func() error { + s.Tds2Status.Reset() + if err := s.Tds2Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tds2_status\"") + } + case "merchant_name": + if err := func() error { + s.MerchantName.Reset() + if err := s.MerchantName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"merchant_name\"") + } + case "send_url": + if err := func() error { + s.SendURL.Reset() + if err := s.SendURL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"send_url\"") + } + case "subscription_id": + if err := func() error { + s.SubscriptionID.Reset() + if err := s.SubscriptionID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"subscription_id\"") + } + case "brand": + if err := func() error { + s.Brand.Reset() + if err := s.Brand.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"brand\"") + } + case "error_code": + if err := func() error { + s.ErrorCode.Reset() + if err := s.ErrorCode.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error_code\"") + } + case "created": + if err := func() error { + s.Created.Reset() + if err := s.Created.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"created\"") + } + case "updated": + if err := func() error { + s.Updated.Reset() + if err := s.Updated.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"updated\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode PaymentCancelCardResponse") + } -// Decode decodes PaymentMethodDirectDebitResponseDirectdebitAccountType from json. -func (o *OptPaymentMethodDirectDebitResponseDirectdebitAccountType) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitAccountType to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseDirectdebitAccountType) MarshalJSON() ([]byte, error) { +func (s *PaymentCancelCardResponse) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseDirectdebitAccountType) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponse) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponseDirectdebitApplicationType as json. -func (o OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseJobCode as json. +func (s PaymentCancelCardResponseJobCode) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponseDirectdebitApplicationType from json. -func (o *OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitApplicationType to nil") +// Decode decodes PaymentCancelCardResponseJobCode from json. +func (s *PaymentCancelCardResponseJobCode) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseJobCode to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseDirectdebitApplicationType) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes PaymentMethodDirectDebitResponseDirectdebitBankType as json. -func (o OptPaymentMethodDirectDebitResponseDirectdebitBankType) Encode(e *jx.Encoder) { - if !o.Set { - return + // Try to use constant string. + switch PaymentCancelCardResponseJobCode(v) { + case PaymentCancelCardResponseJobCodeCHECK: + *s = PaymentCancelCardResponseJobCodeCHECK + case PaymentCancelCardResponseJobCodeAUTH: + *s = PaymentCancelCardResponseJobCodeAUTH + case PaymentCancelCardResponseJobCodeCAPTURE: + *s = PaymentCancelCardResponseJobCodeCAPTURE + case PaymentCancelCardResponseJobCodeSALES: + *s = PaymentCancelCardResponseJobCodeSALES + case PaymentCancelCardResponseJobCodeCANCEL: + *s = PaymentCancelCardResponseJobCodeCANCEL + default: + *s = PaymentCancelCardResponseJobCode(v) } - e.Str(string(o.Value)) -} -// Decode decodes PaymentMethodDirectDebitResponseDirectdebitBankType from json. -func (o *OptPaymentMethodDirectDebitResponseDirectdebitBankType) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitBankType to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseDirectdebitBankType) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseJobCode) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseDirectdebitBankType) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseJobCode) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponseDirectdebitLastResultCode as json. -func (o OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseMethod as json. +func (s PaymentCancelCardResponseMethod) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponseDirectdebitLastResultCode from json. -func (o *OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode to nil") +// Decode decodes PaymentCancelCardResponseMethod from json. +func (s *PaymentCancelCardResponseMethod) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseMethod to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } + // Try to use constant string. + switch PaymentCancelCardResponseMethod(v) { + case PaymentCancelCardResponseMethod1: + *s = PaymentCancelCardResponseMethod1 + case PaymentCancelCardResponseMethod2: + *s = PaymentCancelCardResponseMethod2 + case PaymentCancelCardResponseMethod5: + *s = PaymentCancelCardResponseMethod5 + default: + *s = PaymentCancelCardResponseMethod(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseMethod) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseDirectdebitLastResultCode) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseMethod) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponseDirectdebitPaperApplication as json. -func (o OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes PaymentCancelCardResponsePayType as json. +func (s PaymentCancelCardResponsePayType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponseDirectdebitPaperApplication from json. -func (o *OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication to nil") +// Decode decodes PaymentCancelCardResponsePayType from json. +func (s *PaymentCancelCardResponsePayType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponsePayType to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } + // Try to use constant string. + switch PaymentCancelCardResponsePayType(v) { + case PaymentCancelCardResponsePayTypeCard: + *s = PaymentCancelCardResponsePayTypeCard + default: + *s = PaymentCancelCardResponsePayType(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponsePayType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseDirectdebitPaperApplication) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponsePayType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponsePayType as json. -func (o OptPaymentMethodDirectDebitResponsePayType) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseStatus as json. +func (s PaymentCancelCardResponseStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponsePayType from json. -func (o *OptPaymentMethodDirectDebitResponsePayType) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponsePayType to nil") +// Decode decodes PaymentCancelCardResponseStatus from json. +func (s *PaymentCancelCardResponseStatus) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseStatus to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } + // Try to use constant string. + switch PaymentCancelCardResponseStatus(v) { + case PaymentCancelCardResponseStatusUNPROCESSED: + *s = PaymentCancelCardResponseStatusUNPROCESSED + case PaymentCancelCardResponseStatusCHECKED: + *s = PaymentCancelCardResponseStatusCHECKED + case PaymentCancelCardResponseStatusAUTHORIZED: + *s = PaymentCancelCardResponseStatusAUTHORIZED + case PaymentCancelCardResponseStatusCAPTURED: + *s = PaymentCancelCardResponseStatusCAPTURED + case PaymentCancelCardResponseStatusCANCELED: + *s = PaymentCancelCardResponseStatusCANCELED + case PaymentCancelCardResponseStatusAUTHENTICATED: + *s = PaymentCancelCardResponseStatusAUTHENTICATED + default: + *s = PaymentCancelCardResponseStatus(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponsePayType) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseStatus) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponsePayType) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseStatus) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponseRedirectURLAccessedFlag as json. -func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseTds2Status as json. +func (s PaymentCancelCardResponseTds2Status) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponseRedirectURLAccessedFlag from json. -func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag to nil") +// Decode decodes PaymentCancelCardResponseTds2Status from json. +func (s *PaymentCancelCardResponseTds2Status) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseTds2Status to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } + // Try to use constant string. + switch PaymentCancelCardResponseTds2Status(v) { + case PaymentCancelCardResponseTds2StatusAUTHENTICATING: + *s = PaymentCancelCardResponseTds2StatusAUTHENTICATING + case PaymentCancelCardResponseTds2StatusCHALLENGE: + *s = PaymentCancelCardResponseTds2StatusCHALLENGE + case PaymentCancelCardResponseTds2StatusAUTHENTICATED: + *s = PaymentCancelCardResponseTds2StatusAUTHENTICATED + default: + *s = PaymentCancelCardResponseTds2Status(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseTds2Status) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseTds2Status) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes PaymentMethodDirectDebitResponseStatus as json. -func (o OptPaymentMethodDirectDebitResponseStatus) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseTds2Type as json. +func (s PaymentCancelCardResponseTds2Type) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes PaymentMethodDirectDebitResponseStatus from json. -func (o *OptPaymentMethodDirectDebitResponseStatus) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptPaymentMethodDirectDebitResponseStatus to nil") +// Decode decodes PaymentCancelCardResponseTds2Type from json. +func (s *PaymentCancelCardResponseTds2Type) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseTds2Type to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { return err } + // Try to use constant string. + switch PaymentCancelCardResponseTds2Type(v) { + case PaymentCancelCardResponseTds2Type2: + *s = PaymentCancelCardResponseTds2Type2 + case PaymentCancelCardResponseTds2Type3: + *s = PaymentCancelCardResponseTds2Type3 + default: + *s = PaymentCancelCardResponseTds2Type(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptPaymentMethodDirectDebitResponseStatus) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseTds2Type) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptPaymentMethodDirectDebitResponseStatus) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseTds2Type) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes string as json. -func (o OptString) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes PaymentCancelCardResponseTdsType as json. +func (s PaymentCancelCardResponseTdsType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes string from json. -func (o *OptString) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptString to nil") +// Decode decodes PaymentCancelCardResponseTdsType from json. +func (s *PaymentCancelCardResponseTdsType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentCancelCardResponseTdsType to nil") } - o.Set = true - v, err := d.Str() + v, err := d.StrBytes() if err != nil { return err } - o.Value = string(v) + // Try to use constant string. + switch PaymentCancelCardResponseTdsType(v) { + case PaymentCancelCardResponseTdsType0: + *s = PaymentCancelCardResponseTdsType0 + case PaymentCancelCardResponseTdsType2: + *s = PaymentCancelCardResponseTdsType2 + default: + *s = PaymentCancelCardResponseTdsType(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptString) MarshalJSON() ([]byte, error) { +func (s PaymentCancelCardResponseTdsType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptString) UnmarshalJSON(data []byte) error { +func (s *PaymentCancelCardResponseTdsType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } @@ -6009,8 +7458,8 @@ func (s *PaymentCardResponseStatus) Decode(d *jx.Decoder) error { *s = PaymentCardResponseStatusAUTHORIZED case PaymentCardResponseStatusCAPTURED: *s = PaymentCardResponseStatusCAPTURED - case PaymentCardResponseStatusCANCELLED: - *s = PaymentCardResponseStatusCANCELLED + case PaymentCardResponseStatusCANCELED: + *s = PaymentCardResponseStatusCANCELED case PaymentCardResponseStatusAUTHENTICATED: *s = PaymentCardResponseStatusAUTHENTICATED default: @@ -7143,8 +8592,8 @@ func (s *PaymentDirectdebitResponseStatus) Decode(d *jx.Decoder) error { *s = PaymentDirectdebitResponseStatusAWAITINGPAYMENTAPPROVAL case PaymentDirectdebitResponseStatusCAPTURED: *s = PaymentDirectdebitResponseStatusCAPTURED - case PaymentDirectdebitResponseStatusCANCELLED: - *s = PaymentDirectdebitResponseStatusCANCELLED + case PaymentDirectdebitResponseStatusCANCELED: + *s = PaymentDirectdebitResponseStatusCANCELED case PaymentDirectdebitResponseStatusFAILED: *s = PaymentDirectdebitResponseStatusFAILED default: @@ -8060,8 +9509,8 @@ func (s *PaymentDoCardResponseStatus) Decode(d *jx.Decoder) error { *s = PaymentDoCardResponseStatusAUTHORIZED case PaymentDoCardResponseStatusCAPTURED: *s = PaymentDoCardResponseStatusCAPTURED - case PaymentDoCardResponseStatusCANCELLED: - *s = PaymentDoCardResponseStatusCANCELLED + case PaymentDoCardResponseStatusCANCELED: + *s = PaymentDoCardResponseStatusCANCELED case PaymentDoCardResponseStatusAUTHENTICATED: *s = PaymentDoCardResponseStatusAUTHENTICATED default: @@ -15355,6 +16804,84 @@ func (s *PaymentsGetOKListItem) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes PaymentsIDCancelPutOK as json. +func (s PaymentsIDCancelPutOK) Encode(e *jx.Encoder) { + switch s.Type { + case PaymentCancelCardResponsePaymentsIDCancelPutOK: + s.PaymentCancelCardResponse.Encode(e) + } +} + +// Decode decodes PaymentsIDCancelPutOK from json. +func (s *PaymentsIDCancelPutOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentsIDCancelPutOK to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Object: + if err := s.PaymentCancelCardResponse.Decode(d); err != nil { + return err + } + s.Type = PaymentCancelCardResponsePaymentsIDCancelPutOK + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s PaymentsIDCancelPutOK) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PaymentsIDCancelPutOK) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PaymentsIDCancelPutReq as json. +func (s PaymentsIDCancelPutReq) Encode(e *jx.Encoder) { + switch s.Type { + case PaymentCancelCardPaymentsIDCancelPutReq: + s.PaymentCancelCard.Encode(e) + } +} + +// Decode decodes PaymentsIDCancelPutReq from json. +func (s *PaymentsIDCancelPutReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PaymentsIDCancelPutReq to nil") + } + // Sum type type_discriminator. + switch t := d.Next(); t { + case jx.Object: + if err := s.PaymentCancelCard.Decode(d); err != nil { + return err + } + s.Type = PaymentCancelCardPaymentsIDCancelPutReq + default: + return errors.Errorf("unexpected json type %q", t) + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s PaymentsIDCancelPutReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PaymentsIDCancelPutReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes PaymentsIDGetOK as json. func (s PaymentsIDGetOK) Encode(e *jx.Encoder) { switch s.Type { diff --git a/api/oas_parameters_gen.go b/api/oas_parameters_gen.go index 697b29e..3321405 100644 --- a/api/oas_parameters_gen.go +++ b/api/oas_parameters_gen.go @@ -1645,6 +1645,71 @@ func decodePaymentsGetParams(args [0]string, argsEscaped bool, r *http.Request) return params, nil } +// PaymentsIDCancelPutParams is parameters of PUT /payments/{id}/cancel operation. +type PaymentsIDCancelPutParams struct { + ID string +} + +func unpackPaymentsIDCancelPutParams(packed middleware.Parameters) (params PaymentsIDCancelPutParams) { + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(string) + } + return params +} + +func decodePaymentsIDCancelPutParams(args [1]string, argsEscaped bool, r *http.Request) (params PaymentsIDCancelPutParams, _ error) { + // Decode path: id. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.ID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "id", + In: "path", + Err: err, + } + } + return params, nil +} + // PaymentsIDGetParams is parameters of GET /payments/{id} operation. type PaymentsIDGetParams struct { ID string diff --git a/api/oas_request_decoders_gen.go b/api/oas_request_decoders_gen.go index 5b1e269..c947f4a 100644 --- a/api/oas_request_decoders_gen.go +++ b/api/oas_request_decoders_gen.go @@ -149,6 +149,77 @@ func (s *Server) decodeCustomersPostRequest(r *http.Request) ( } } +func (s *Server) decodePaymentsIDCancelPutRequest(r *http.Request) ( + req PaymentsIDCancelPutReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, validate.ErrBodyRequired + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, validate.ErrBodyRequired + } + + d := jx.DecodeBytes(buf) + + var request PaymentsIDCancelPutReq + if err := func() error { + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + if err := func() error { + if err := request.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return req, close, errors.Wrap(err, "validate") + } + return request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodePaymentsIDPutRequest(r *http.Request) ( req PaymentsIDPutReq, close func() error, diff --git a/api/oas_request_encoders_gen.go b/api/oas_request_encoders_gen.go index 21ffa18..5eb68cc 100644 --- a/api/oas_request_encoders_gen.go +++ b/api/oas_request_encoders_gen.go @@ -39,6 +39,20 @@ func encodeCustomersPostRequest( return nil } +func encodePaymentsIDCancelPutRequest( + req PaymentsIDCancelPutReq, + r *http.Request, +) error { + const contentType = "application/json" + e := new(jx.Encoder) + { + req.Encode(e) + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodePaymentsIDPutRequest( req PaymentsIDPutReq, r *http.Request, diff --git a/api/oas_response_decoders_gen.go b/api/oas_response_decoders_gen.go index a219f11..444c23f 100644 --- a/api/oas_response_decoders_gen.go +++ b/api/oas_response_decoders_gen.go @@ -815,6 +815,100 @@ func decodePaymentsGetResponse(resp *http.Response) (res PaymentsGetRes, _ error return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodePaymentsIDCancelPutResponse(resp *http.Response) (res PaymentsIDCancelPutRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response PaymentsIDCancelPutOK + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + // Validate response. + if err := func() error { + if err := response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ErrorResponse + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + // Validate response. + if err := func() error { + if err := response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodePaymentsIDGetResponse(resp *http.Response) (res PaymentsIDGetRes, _ error) { switch resp.StatusCode { case 200: diff --git a/api/oas_response_encoders_gen.go b/api/oas_response_encoders_gen.go index ffdee3d..55de908 100644 --- a/api/oas_response_encoders_gen.go +++ b/api/oas_response_encoders_gen.go @@ -308,6 +308,39 @@ func encodePaymentsGetResponse(response PaymentsGetRes, w http.ResponseWriter, s } } +func encodePaymentsIDCancelPutResponse(response PaymentsIDCancelPutRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *PaymentsIDCancelPutOK: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ErrorResponse: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodePaymentsIDGetResponse(response PaymentsIDGetRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *PaymentsIDGetOK: diff --git a/api/oas_router_gen.go b/api/oas_router_gen.go index 4cdfbd7..ab04dc0 100644 --- a/api/oas_router_gen.go +++ b/api/oas_router_gen.go @@ -257,12 +257,15 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // Param: "id" - // Leaf parameter - args[0] = elem - elem = "" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] if len(elem) == 0 { - // Leaf node. switch r.Method { case "GET": s.handlePaymentsIDGetRequest([1]string{ @@ -278,6 +281,31 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + switch elem[0] { + case '/': // Prefix: "/cancel" + origElem := elem + if l := len("/cancel"); len(elem) >= l && elem[0:l] == "/cancel" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "PUT": + s.handlePaymentsIDCancelPutRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "PUT") + } + + return + } + + elem = origElem + } elem = origElem } @@ -604,12 +632,15 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } // Param: "id" - // Leaf parameter - args[0] = elem - elem = "" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] if len(elem) == 0 { - // Leaf node. switch method { case "GET": r.name = "PaymentsIDGet" @@ -631,6 +662,33 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { return } } + switch elem[0] { + case '/': // Prefix: "/cancel" + origElem := elem + if l := len("/cancel"); len(elem) >= l && elem[0:l] == "/cancel" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch method { + case "PUT": + r.name = "PaymentsIDCancelPut" + r.summary = "" + r.operationID = "" + r.pathPattern = "/payments/{id}/cancel" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + + elem = origElem + } elem = origElem } diff --git a/api/oas_schemas_gen.go b/api/oas_schemas_gen.go index 4972a03..e9c43a9 100644 --- a/api/oas_schemas_gen.go +++ b/api/oas_schemas_gen.go @@ -1074,6 +1074,7 @@ func (*ErrorResponse) customersCustomerIDPaymentMethodsPostRes() func (*ErrorResponse) customersIDDeleteRes() {} func (*ErrorResponse) customersIDGetRes() {} func (*ErrorResponse) customersPostRes() {} +func (*ErrorResponse) paymentsIDCancelPutRes() {} func (*ErrorResponse) paymentsIDGetRes() {} func (*ErrorResponse) paymentsIDPutRes() {} func (*ErrorResponse) paymentsPostRes() {} @@ -1195,6 +1196,258 @@ func (o OptInt) Or(d int) int { return d } +// NewOptNilPaymentCancelCardResponseMethod returns new OptNilPaymentCancelCardResponseMethod with value set to v. +func NewOptNilPaymentCancelCardResponseMethod(v PaymentCancelCardResponseMethod) OptNilPaymentCancelCardResponseMethod { + return OptNilPaymentCancelCardResponseMethod{ + Value: v, + Set: true, + } +} + +// OptNilPaymentCancelCardResponseMethod is optional nullable PaymentCancelCardResponseMethod. +type OptNilPaymentCancelCardResponseMethod struct { + Value PaymentCancelCardResponseMethod + Set bool + Null bool +} + +// IsSet returns true if OptNilPaymentCancelCardResponseMethod was set. +func (o OptNilPaymentCancelCardResponseMethod) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilPaymentCancelCardResponseMethod) Reset() { + var v PaymentCancelCardResponseMethod + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilPaymentCancelCardResponseMethod) SetTo(v PaymentCancelCardResponseMethod) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsSet returns true if value is Null. +func (o OptNilPaymentCancelCardResponseMethod) IsNull() bool { return o.Null } + +// SetNull sets value to null. +func (o *OptNilPaymentCancelCardResponseMethod) SetToNull() { + o.Set = true + o.Null = true + var v PaymentCancelCardResponseMethod + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilPaymentCancelCardResponseMethod) Get() (v PaymentCancelCardResponseMethod, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilPaymentCancelCardResponseMethod) Or(d PaymentCancelCardResponseMethod) PaymentCancelCardResponseMethod { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilPaymentCancelCardResponseTds2Status returns new OptNilPaymentCancelCardResponseTds2Status with value set to v. +func NewOptNilPaymentCancelCardResponseTds2Status(v PaymentCancelCardResponseTds2Status) OptNilPaymentCancelCardResponseTds2Status { + return OptNilPaymentCancelCardResponseTds2Status{ + Value: v, + Set: true, + } +} + +// OptNilPaymentCancelCardResponseTds2Status is optional nullable PaymentCancelCardResponseTds2Status. +type OptNilPaymentCancelCardResponseTds2Status struct { + Value PaymentCancelCardResponseTds2Status + Set bool + Null bool +} + +// IsSet returns true if OptNilPaymentCancelCardResponseTds2Status was set. +func (o OptNilPaymentCancelCardResponseTds2Status) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilPaymentCancelCardResponseTds2Status) Reset() { + var v PaymentCancelCardResponseTds2Status + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilPaymentCancelCardResponseTds2Status) SetTo(v PaymentCancelCardResponseTds2Status) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsSet returns true if value is Null. +func (o OptNilPaymentCancelCardResponseTds2Status) IsNull() bool { return o.Null } + +// SetNull sets value to null. +func (o *OptNilPaymentCancelCardResponseTds2Status) SetToNull() { + o.Set = true + o.Null = true + var v PaymentCancelCardResponseTds2Status + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilPaymentCancelCardResponseTds2Status) Get() (v PaymentCancelCardResponseTds2Status, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilPaymentCancelCardResponseTds2Status) Or(d PaymentCancelCardResponseTds2Status) PaymentCancelCardResponseTds2Status { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilPaymentCancelCardResponseTds2Type returns new OptNilPaymentCancelCardResponseTds2Type with value set to v. +func NewOptNilPaymentCancelCardResponseTds2Type(v PaymentCancelCardResponseTds2Type) OptNilPaymentCancelCardResponseTds2Type { + return OptNilPaymentCancelCardResponseTds2Type{ + Value: v, + Set: true, + } +} + +// OptNilPaymentCancelCardResponseTds2Type is optional nullable PaymentCancelCardResponseTds2Type. +type OptNilPaymentCancelCardResponseTds2Type struct { + Value PaymentCancelCardResponseTds2Type + Set bool + Null bool +} + +// IsSet returns true if OptNilPaymentCancelCardResponseTds2Type was set. +func (o OptNilPaymentCancelCardResponseTds2Type) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilPaymentCancelCardResponseTds2Type) Reset() { + var v PaymentCancelCardResponseTds2Type + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilPaymentCancelCardResponseTds2Type) SetTo(v PaymentCancelCardResponseTds2Type) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsSet returns true if value is Null. +func (o OptNilPaymentCancelCardResponseTds2Type) IsNull() bool { return o.Null } + +// SetNull sets value to null. +func (o *OptNilPaymentCancelCardResponseTds2Type) SetToNull() { + o.Set = true + o.Null = true + var v PaymentCancelCardResponseTds2Type + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilPaymentCancelCardResponseTds2Type) Get() (v PaymentCancelCardResponseTds2Type, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilPaymentCancelCardResponseTds2Type) Or(d PaymentCancelCardResponseTds2Type) PaymentCancelCardResponseTds2Type { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptNilPaymentCancelCardResponseTdsType returns new OptNilPaymentCancelCardResponseTdsType with value set to v. +func NewOptNilPaymentCancelCardResponseTdsType(v PaymentCancelCardResponseTdsType) OptNilPaymentCancelCardResponseTdsType { + return OptNilPaymentCancelCardResponseTdsType{ + Value: v, + Set: true, + } +} + +// OptNilPaymentCancelCardResponseTdsType is optional nullable PaymentCancelCardResponseTdsType. +type OptNilPaymentCancelCardResponseTdsType struct { + Value PaymentCancelCardResponseTdsType + Set bool + Null bool +} + +// IsSet returns true if OptNilPaymentCancelCardResponseTdsType was set. +func (o OptNilPaymentCancelCardResponseTdsType) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptNilPaymentCancelCardResponseTdsType) Reset() { + var v PaymentCancelCardResponseTdsType + o.Value = v + o.Set = false + o.Null = false +} + +// SetTo sets value to v. +func (o *OptNilPaymentCancelCardResponseTdsType) SetTo(v PaymentCancelCardResponseTdsType) { + o.Set = true + o.Null = false + o.Value = v +} + +// IsSet returns true if value is Null. +func (o OptNilPaymentCancelCardResponseTdsType) IsNull() bool { return o.Null } + +// SetNull sets value to null. +func (o *OptNilPaymentCancelCardResponseTdsType) SetToNull() { + o.Set = true + o.Null = true + var v PaymentCancelCardResponseTdsType + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptNilPaymentCancelCardResponseTdsType) Get() (v PaymentCancelCardResponseTdsType, ok bool) { + if o.Null { + return v, false + } + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptNilPaymentCancelCardResponseTdsType) Or(d PaymentCancelCardResponseTdsType) PaymentCancelCardResponseTdsType { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptNilPaymentCardResponseMethod returns new OptNilPaymentCardResponseMethod with value set to v. func NewOptNilPaymentCardResponseMethod(v PaymentCardResponseMethod) OptNilPaymentCardResponseMethod { return OptNilPaymentCardResponseMethod{ @@ -3213,38 +3466,38 @@ func (o OptNilString) Or(d string) string { return d } -// NewOptPaymentCardResponseJobCode returns new OptPaymentCardResponseJobCode with value set to v. -func NewOptPaymentCardResponseJobCode(v PaymentCardResponseJobCode) OptPaymentCardResponseJobCode { - return OptPaymentCardResponseJobCode{ +// NewOptPaymentCancelCardResponseJobCode returns new OptPaymentCancelCardResponseJobCode with value set to v. +func NewOptPaymentCancelCardResponseJobCode(v PaymentCancelCardResponseJobCode) OptPaymentCancelCardResponseJobCode { + return OptPaymentCancelCardResponseJobCode{ Value: v, Set: true, } } -// OptPaymentCardResponseJobCode is optional PaymentCardResponseJobCode. -type OptPaymentCardResponseJobCode struct { - Value PaymentCardResponseJobCode +// OptPaymentCancelCardResponseJobCode is optional PaymentCancelCardResponseJobCode. +type OptPaymentCancelCardResponseJobCode struct { + Value PaymentCancelCardResponseJobCode Set bool } -// IsSet returns true if OptPaymentCardResponseJobCode was set. -func (o OptPaymentCardResponseJobCode) IsSet() bool { return o.Set } +// IsSet returns true if OptPaymentCancelCardResponseJobCode was set. +func (o OptPaymentCancelCardResponseJobCode) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptPaymentCardResponseJobCode) Reset() { - var v PaymentCardResponseJobCode +func (o *OptPaymentCancelCardResponseJobCode) Reset() { + var v PaymentCancelCardResponseJobCode o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptPaymentCardResponseJobCode) SetTo(v PaymentCardResponseJobCode) { +func (o *OptPaymentCancelCardResponseJobCode) SetTo(v PaymentCancelCardResponseJobCode) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptPaymentCardResponseJobCode) Get() (v PaymentCardResponseJobCode, ok bool) { +func (o OptPaymentCancelCardResponseJobCode) Get() (v PaymentCancelCardResponseJobCode, ok bool) { if !o.Set { return v, false } @@ -3252,45 +3505,45 @@ func (o OptPaymentCardResponseJobCode) Get() (v PaymentCardResponseJobCode, ok b } // Or returns value if set, or given parameter if does not. -func (o OptPaymentCardResponseJobCode) Or(d PaymentCardResponseJobCode) PaymentCardResponseJobCode { +func (o OptPaymentCancelCardResponseJobCode) Or(d PaymentCancelCardResponseJobCode) PaymentCancelCardResponseJobCode { if v, ok := o.Get(); ok { return v } return d } -// NewOptPaymentCardResponsePayType returns new OptPaymentCardResponsePayType with value set to v. -func NewOptPaymentCardResponsePayType(v PaymentCardResponsePayType) OptPaymentCardResponsePayType { - return OptPaymentCardResponsePayType{ +// NewOptPaymentCancelCardResponsePayType returns new OptPaymentCancelCardResponsePayType with value set to v. +func NewOptPaymentCancelCardResponsePayType(v PaymentCancelCardResponsePayType) OptPaymentCancelCardResponsePayType { + return OptPaymentCancelCardResponsePayType{ Value: v, Set: true, } } -// OptPaymentCardResponsePayType is optional PaymentCardResponsePayType. -type OptPaymentCardResponsePayType struct { - Value PaymentCardResponsePayType +// OptPaymentCancelCardResponsePayType is optional PaymentCancelCardResponsePayType. +type OptPaymentCancelCardResponsePayType struct { + Value PaymentCancelCardResponsePayType Set bool } -// IsSet returns true if OptPaymentCardResponsePayType was set. -func (o OptPaymentCardResponsePayType) IsSet() bool { return o.Set } +// IsSet returns true if OptPaymentCancelCardResponsePayType was set. +func (o OptPaymentCancelCardResponsePayType) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptPaymentCardResponsePayType) Reset() { - var v PaymentCardResponsePayType +func (o *OptPaymentCancelCardResponsePayType) Reset() { + var v PaymentCancelCardResponsePayType o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptPaymentCardResponsePayType) SetTo(v PaymentCardResponsePayType) { +func (o *OptPaymentCancelCardResponsePayType) SetTo(v PaymentCancelCardResponsePayType) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptPaymentCardResponsePayType) Get() (v PaymentCardResponsePayType, ok bool) { +func (o OptPaymentCancelCardResponsePayType) Get() (v PaymentCancelCardResponsePayType, ok bool) { if !o.Set { return v, false } @@ -3298,45 +3551,45 @@ func (o OptPaymentCardResponsePayType) Get() (v PaymentCardResponsePayType, ok b } // Or returns value if set, or given parameter if does not. -func (o OptPaymentCardResponsePayType) Or(d PaymentCardResponsePayType) PaymentCardResponsePayType { +func (o OptPaymentCancelCardResponsePayType) Or(d PaymentCancelCardResponsePayType) PaymentCancelCardResponsePayType { if v, ok := o.Get(); ok { return v } return d } -// NewOptPaymentCardResponseStatus returns new OptPaymentCardResponseStatus with value set to v. -func NewOptPaymentCardResponseStatus(v PaymentCardResponseStatus) OptPaymentCardResponseStatus { - return OptPaymentCardResponseStatus{ +// NewOptPaymentCancelCardResponseStatus returns new OptPaymentCancelCardResponseStatus with value set to v. +func NewOptPaymentCancelCardResponseStatus(v PaymentCancelCardResponseStatus) OptPaymentCancelCardResponseStatus { + return OptPaymentCancelCardResponseStatus{ Value: v, Set: true, } } -// OptPaymentCardResponseStatus is optional PaymentCardResponseStatus. -type OptPaymentCardResponseStatus struct { - Value PaymentCardResponseStatus +// OptPaymentCancelCardResponseStatus is optional PaymentCancelCardResponseStatus. +type OptPaymentCancelCardResponseStatus struct { + Value PaymentCancelCardResponseStatus Set bool } -// IsSet returns true if OptPaymentCardResponseStatus was set. -func (o OptPaymentCardResponseStatus) IsSet() bool { return o.Set } +// IsSet returns true if OptPaymentCancelCardResponseStatus was set. +func (o OptPaymentCancelCardResponseStatus) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptPaymentCardResponseStatus) Reset() { - var v PaymentCardResponseStatus +func (o *OptPaymentCancelCardResponseStatus) Reset() { + var v PaymentCancelCardResponseStatus o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptPaymentCardResponseStatus) SetTo(v PaymentCardResponseStatus) { +func (o *OptPaymentCancelCardResponseStatus) SetTo(v PaymentCancelCardResponseStatus) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptPaymentCardResponseStatus) Get() (v PaymentCardResponseStatus, ok bool) { +func (o OptPaymentCancelCardResponseStatus) Get() (v PaymentCancelCardResponseStatus, ok bool) { if !o.Set { return v, false } @@ -3344,45 +3597,45 @@ func (o OptPaymentCardResponseStatus) Get() (v PaymentCardResponseStatus, ok boo } // Or returns value if set, or given parameter if does not. -func (o OptPaymentCardResponseStatus) Or(d PaymentCardResponseStatus) PaymentCardResponseStatus { +func (o OptPaymentCancelCardResponseStatus) Or(d PaymentCancelCardResponseStatus) PaymentCancelCardResponseStatus { if v, ok := o.Get(); ok { return v } return d } -// NewOptPaymentCardTdsType returns new OptPaymentCardTdsType with value set to v. -func NewOptPaymentCardTdsType(v PaymentCardTdsType) OptPaymentCardTdsType { - return OptPaymentCardTdsType{ +// NewOptPaymentCardResponseJobCode returns new OptPaymentCardResponseJobCode with value set to v. +func NewOptPaymentCardResponseJobCode(v PaymentCardResponseJobCode) OptPaymentCardResponseJobCode { + return OptPaymentCardResponseJobCode{ Value: v, Set: true, } } -// OptPaymentCardTdsType is optional PaymentCardTdsType. -type OptPaymentCardTdsType struct { - Value PaymentCardTdsType +// OptPaymentCardResponseJobCode is optional PaymentCardResponseJobCode. +type OptPaymentCardResponseJobCode struct { + Value PaymentCardResponseJobCode Set bool } -// IsSet returns true if OptPaymentCardTdsType was set. -func (o OptPaymentCardTdsType) IsSet() bool { return o.Set } +// IsSet returns true if OptPaymentCardResponseJobCode was set. +func (o OptPaymentCardResponseJobCode) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptPaymentCardTdsType) Reset() { - var v PaymentCardTdsType +func (o *OptPaymentCardResponseJobCode) Reset() { + var v PaymentCardResponseJobCode o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptPaymentCardTdsType) SetTo(v PaymentCardTdsType) { +func (o *OptPaymentCardResponseJobCode) SetTo(v PaymentCardResponseJobCode) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptPaymentCardTdsType) Get() (v PaymentCardTdsType, ok bool) { +func (o OptPaymentCardResponseJobCode) Get() (v PaymentCardResponseJobCode, ok bool) { if !o.Set { return v, false } @@ -3390,16 +3643,154 @@ func (o OptPaymentCardTdsType) Get() (v PaymentCardTdsType, ok bool) { } // Or returns value if set, or given parameter if does not. -func (o OptPaymentCardTdsType) Or(d PaymentCardTdsType) PaymentCardTdsType { +func (o OptPaymentCardResponseJobCode) Or(d PaymentCardResponseJobCode) PaymentCardResponseJobCode { if v, ok := o.Get(); ok { return v } return d } -// NewOptPaymentDirectdebitResponsePayType returns new OptPaymentDirectdebitResponsePayType with value set to v. -func NewOptPaymentDirectdebitResponsePayType(v PaymentDirectdebitResponsePayType) OptPaymentDirectdebitResponsePayType { - return OptPaymentDirectdebitResponsePayType{ +// NewOptPaymentCardResponsePayType returns new OptPaymentCardResponsePayType with value set to v. +func NewOptPaymentCardResponsePayType(v PaymentCardResponsePayType) OptPaymentCardResponsePayType { + return OptPaymentCardResponsePayType{ + Value: v, + Set: true, + } +} + +// OptPaymentCardResponsePayType is optional PaymentCardResponsePayType. +type OptPaymentCardResponsePayType struct { + Value PaymentCardResponsePayType + Set bool +} + +// IsSet returns true if OptPaymentCardResponsePayType was set. +func (o OptPaymentCardResponsePayType) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentCardResponsePayType) Reset() { + var v PaymentCardResponsePayType + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentCardResponsePayType) SetTo(v PaymentCardResponsePayType) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentCardResponsePayType) Get() (v PaymentCardResponsePayType, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentCardResponsePayType) Or(d PaymentCardResponsePayType) PaymentCardResponsePayType { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptPaymentCardResponseStatus returns new OptPaymentCardResponseStatus with value set to v. +func NewOptPaymentCardResponseStatus(v PaymentCardResponseStatus) OptPaymentCardResponseStatus { + return OptPaymentCardResponseStatus{ + Value: v, + Set: true, + } +} + +// OptPaymentCardResponseStatus is optional PaymentCardResponseStatus. +type OptPaymentCardResponseStatus struct { + Value PaymentCardResponseStatus + Set bool +} + +// IsSet returns true if OptPaymentCardResponseStatus was set. +func (o OptPaymentCardResponseStatus) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentCardResponseStatus) Reset() { + var v PaymentCardResponseStatus + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentCardResponseStatus) SetTo(v PaymentCardResponseStatus) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentCardResponseStatus) Get() (v PaymentCardResponseStatus, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentCardResponseStatus) Or(d PaymentCardResponseStatus) PaymentCardResponseStatus { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptPaymentCardTdsType returns new OptPaymentCardTdsType with value set to v. +func NewOptPaymentCardTdsType(v PaymentCardTdsType) OptPaymentCardTdsType { + return OptPaymentCardTdsType{ + Value: v, + Set: true, + } +} + +// OptPaymentCardTdsType is optional PaymentCardTdsType. +type OptPaymentCardTdsType struct { + Value PaymentCardTdsType + Set bool +} + +// IsSet returns true if OptPaymentCardTdsType was set. +func (o OptPaymentCardTdsType) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentCardTdsType) Reset() { + var v PaymentCardTdsType + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentCardTdsType) SetTo(v PaymentCardTdsType) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentCardTdsType) Get() (v PaymentCardTdsType, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentCardTdsType) Or(d PaymentCardTdsType) PaymentCardTdsType { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptPaymentDirectdebitResponsePayType returns new OptPaymentDirectdebitResponsePayType with value set to v. +func NewOptPaymentDirectdebitResponsePayType(v PaymentDirectdebitResponsePayType) OptPaymentDirectdebitResponsePayType { + return OptPaymentDirectdebitResponsePayType{ Value: v, Set: true, } @@ -4233,180 +4624,1016 @@ func NewOptPaymentMethodDirectDebitResponsePayType(v PaymentMethodDirectDebitRes } } -// OptPaymentMethodDirectDebitResponsePayType is optional PaymentMethodDirectDebitResponsePayType. -type OptPaymentMethodDirectDebitResponsePayType struct { - Value PaymentMethodDirectDebitResponsePayType - Set bool -} +// OptPaymentMethodDirectDebitResponsePayType is optional PaymentMethodDirectDebitResponsePayType. +type OptPaymentMethodDirectDebitResponsePayType struct { + Value PaymentMethodDirectDebitResponsePayType + Set bool +} + +// IsSet returns true if OptPaymentMethodDirectDebitResponsePayType was set. +func (o OptPaymentMethodDirectDebitResponsePayType) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentMethodDirectDebitResponsePayType) Reset() { + var v PaymentMethodDirectDebitResponsePayType + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentMethodDirectDebitResponsePayType) SetTo(v PaymentMethodDirectDebitResponsePayType) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentMethodDirectDebitResponsePayType) Get() (v PaymentMethodDirectDebitResponsePayType, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentMethodDirectDebitResponsePayType) Or(d PaymentMethodDirectDebitResponsePayType) PaymentMethodDirectDebitResponsePayType { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag returns new OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag with value set to v. +func NewOptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag(v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag { + return OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag{ + Value: v, + Set: true, + } +} + +// OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag is optional PaymentMethodDirectDebitResponseRedirectURLAccessedFlag. +type OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag struct { + Value PaymentMethodDirectDebitResponseRedirectURLAccessedFlag + Set bool +} + +// IsSet returns true if OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag was set. +func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Reset() { + var v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) SetTo(v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Get() (v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Or(d PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) PaymentMethodDirectDebitResponseRedirectURLAccessedFlag { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptPaymentMethodDirectDebitResponseStatus returns new OptPaymentMethodDirectDebitResponseStatus with value set to v. +func NewOptPaymentMethodDirectDebitResponseStatus(v PaymentMethodDirectDebitResponseStatus) OptPaymentMethodDirectDebitResponseStatus { + return OptPaymentMethodDirectDebitResponseStatus{ + Value: v, + Set: true, + } +} + +// OptPaymentMethodDirectDebitResponseStatus is optional PaymentMethodDirectDebitResponseStatus. +type OptPaymentMethodDirectDebitResponseStatus struct { + Value PaymentMethodDirectDebitResponseStatus + Set bool +} + +// IsSet returns true if OptPaymentMethodDirectDebitResponseStatus was set. +func (o OptPaymentMethodDirectDebitResponseStatus) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptPaymentMethodDirectDebitResponseStatus) Reset() { + var v PaymentMethodDirectDebitResponseStatus + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptPaymentMethodDirectDebitResponseStatus) SetTo(v PaymentMethodDirectDebitResponseStatus) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptPaymentMethodDirectDebitResponseStatus) Get() (v PaymentMethodDirectDebitResponseStatus, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptPaymentMethodDirectDebitResponseStatus) Or(d PaymentMethodDirectDebitResponseStatus) PaymentMethodDirectDebitResponseStatus { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptString returns new OptString with value set to v. +func NewOptString(v string) OptString { + return OptString{ + Value: v, + Set: true, + } +} + +// OptString is optional string. +type OptString struct { + Value string + Set bool +} + +// IsSet returns true if OptString was set. +func (o OptString) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptString) Reset() { + var v string + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptString) SetTo(v string) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptString) Get() (v string, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// Ref: #/components/schemas/paymentCancelCard +type PaymentCancelCard struct { + PayType PaymentCancelCardPayType `json:"pay_type"` + AccessID string `json:"access_id"` +} + +// GetPayType returns the value of PayType. +func (s *PaymentCancelCard) GetPayType() PaymentCancelCardPayType { + return s.PayType +} + +// GetAccessID returns the value of AccessID. +func (s *PaymentCancelCard) GetAccessID() string { + return s.AccessID +} + +// SetPayType sets the value of PayType. +func (s *PaymentCancelCard) SetPayType(val PaymentCancelCardPayType) { + s.PayType = val +} + +// SetAccessID sets the value of AccessID. +func (s *PaymentCancelCard) SetAccessID(val string) { + s.AccessID = val +} + +type PaymentCancelCardPayType string + +const ( + PaymentCancelCardPayTypeCard PaymentCancelCardPayType = "Card" +) + +// AllValues returns all PaymentCancelCardPayType values. +func (PaymentCancelCardPayType) AllValues() []PaymentCancelCardPayType { + return []PaymentCancelCardPayType{ + PaymentCancelCardPayTypeCard, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardPayType) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardPayTypeCard: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardPayType) UnmarshalText(data []byte) error { + switch PaymentCancelCardPayType(data) { + case PaymentCancelCardPayTypeCard: + *s = PaymentCancelCardPayTypeCard + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Ref: #/components/schemas/paymentCancelCardResponse +type PaymentCancelCardResponse struct { + ShopID OptString `json:"shop_id"` + ID OptString `json:"id"` + PayType OptPaymentCancelCardResponsePayType `json:"pay_type"` + Status OptPaymentCancelCardResponseStatus `json:"status"` + AccessID OptString `json:"access_id"` + ProcessDate OptString `json:"process_date"` + JobCode OptPaymentCancelCardResponseJobCode `json:"job_code"` + ItemCode OptString `json:"item_code"` + Amount OptInt `json:"amount"` + Tax OptInt `json:"tax"` + TotalAmount OptInt `json:"total_amount"` + CustomerGroupID OptNilString `json:"customer_group_id"` + CustomerID OptNilString `json:"customer_id"` + CardNo OptNilString `json:"card_no"` + CardID OptNilString `json:"card_id"` + Expire OptNilString `json:"expire"` + HolderName OptNilString `json:"holder_name"` + CardNoHash OptNilString `json:"card_no_hash"` + Method OptNilPaymentCancelCardResponseMethod `json:"method"` + PayTimes OptNilString `json:"pay_times"` + Forward OptNilString `json:"forward"` + Issuer OptNilString `json:"issuer"` + TransactionID OptNilString `json:"transaction_id"` + Approve OptNilString `json:"approve"` + AuthMaxDate OptNilString `json:"auth_max_date"` + ClientField1 OptNilString `json:"client_field_1"` + ClientField2 OptNilString `json:"client_field_2"` + ClientField3 OptNilString `json:"client_field_3"` + TdsType OptNilPaymentCancelCardResponseTdsType `json:"tds_type"` + Tds2Type OptNilPaymentCancelCardResponseTds2Type `json:"tds2_type"` + Tds2RetURL OptNilString `json:"tds2_ret_url"` + Tds2Status OptNilPaymentCancelCardResponseTds2Status `json:"tds2_status"` + MerchantName OptNilString `json:"merchant_name"` + SendURL OptNilString `json:"send_url"` + SubscriptionID OptNilString `json:"subscription_id"` + Brand OptString `json:"brand"` + ErrorCode OptNilString `json:"error_code"` + Created OptNilString `json:"created"` + Updated OptNilString `json:"updated"` +} + +// GetShopID returns the value of ShopID. +func (s *PaymentCancelCardResponse) GetShopID() OptString { + return s.ShopID +} + +// GetID returns the value of ID. +func (s *PaymentCancelCardResponse) GetID() OptString { + return s.ID +} + +// GetPayType returns the value of PayType. +func (s *PaymentCancelCardResponse) GetPayType() OptPaymentCancelCardResponsePayType { + return s.PayType +} + +// GetStatus returns the value of Status. +func (s *PaymentCancelCardResponse) GetStatus() OptPaymentCancelCardResponseStatus { + return s.Status +} + +// GetAccessID returns the value of AccessID. +func (s *PaymentCancelCardResponse) GetAccessID() OptString { + return s.AccessID +} + +// GetProcessDate returns the value of ProcessDate. +func (s *PaymentCancelCardResponse) GetProcessDate() OptString { + return s.ProcessDate +} + +// GetJobCode returns the value of JobCode. +func (s *PaymentCancelCardResponse) GetJobCode() OptPaymentCancelCardResponseJobCode { + return s.JobCode +} + +// GetItemCode returns the value of ItemCode. +func (s *PaymentCancelCardResponse) GetItemCode() OptString { + return s.ItemCode +} + +// GetAmount returns the value of Amount. +func (s *PaymentCancelCardResponse) GetAmount() OptInt { + return s.Amount +} + +// GetTax returns the value of Tax. +func (s *PaymentCancelCardResponse) GetTax() OptInt { + return s.Tax +} + +// GetTotalAmount returns the value of TotalAmount. +func (s *PaymentCancelCardResponse) GetTotalAmount() OptInt { + return s.TotalAmount +} + +// GetCustomerGroupID returns the value of CustomerGroupID. +func (s *PaymentCancelCardResponse) GetCustomerGroupID() OptNilString { + return s.CustomerGroupID +} + +// GetCustomerID returns the value of CustomerID. +func (s *PaymentCancelCardResponse) GetCustomerID() OptNilString { + return s.CustomerID +} + +// GetCardNo returns the value of CardNo. +func (s *PaymentCancelCardResponse) GetCardNo() OptNilString { + return s.CardNo +} + +// GetCardID returns the value of CardID. +func (s *PaymentCancelCardResponse) GetCardID() OptNilString { + return s.CardID +} + +// GetExpire returns the value of Expire. +func (s *PaymentCancelCardResponse) GetExpire() OptNilString { + return s.Expire +} + +// GetHolderName returns the value of HolderName. +func (s *PaymentCancelCardResponse) GetHolderName() OptNilString { + return s.HolderName +} + +// GetCardNoHash returns the value of CardNoHash. +func (s *PaymentCancelCardResponse) GetCardNoHash() OptNilString { + return s.CardNoHash +} + +// GetMethod returns the value of Method. +func (s *PaymentCancelCardResponse) GetMethod() OptNilPaymentCancelCardResponseMethod { + return s.Method +} + +// GetPayTimes returns the value of PayTimes. +func (s *PaymentCancelCardResponse) GetPayTimes() OptNilString { + return s.PayTimes +} + +// GetForward returns the value of Forward. +func (s *PaymentCancelCardResponse) GetForward() OptNilString { + return s.Forward +} + +// GetIssuer returns the value of Issuer. +func (s *PaymentCancelCardResponse) GetIssuer() OptNilString { + return s.Issuer +} + +// GetTransactionID returns the value of TransactionID. +func (s *PaymentCancelCardResponse) GetTransactionID() OptNilString { + return s.TransactionID +} + +// GetApprove returns the value of Approve. +func (s *PaymentCancelCardResponse) GetApprove() OptNilString { + return s.Approve +} + +// GetAuthMaxDate returns the value of AuthMaxDate. +func (s *PaymentCancelCardResponse) GetAuthMaxDate() OptNilString { + return s.AuthMaxDate +} + +// GetClientField1 returns the value of ClientField1. +func (s *PaymentCancelCardResponse) GetClientField1() OptNilString { + return s.ClientField1 +} + +// GetClientField2 returns the value of ClientField2. +func (s *PaymentCancelCardResponse) GetClientField2() OptNilString { + return s.ClientField2 +} + +// GetClientField3 returns the value of ClientField3. +func (s *PaymentCancelCardResponse) GetClientField3() OptNilString { + return s.ClientField3 +} + +// GetTdsType returns the value of TdsType. +func (s *PaymentCancelCardResponse) GetTdsType() OptNilPaymentCancelCardResponseTdsType { + return s.TdsType +} + +// GetTds2Type returns the value of Tds2Type. +func (s *PaymentCancelCardResponse) GetTds2Type() OptNilPaymentCancelCardResponseTds2Type { + return s.Tds2Type +} + +// GetTds2RetURL returns the value of Tds2RetURL. +func (s *PaymentCancelCardResponse) GetTds2RetURL() OptNilString { + return s.Tds2RetURL +} + +// GetTds2Status returns the value of Tds2Status. +func (s *PaymentCancelCardResponse) GetTds2Status() OptNilPaymentCancelCardResponseTds2Status { + return s.Tds2Status +} + +// GetMerchantName returns the value of MerchantName. +func (s *PaymentCancelCardResponse) GetMerchantName() OptNilString { + return s.MerchantName +} + +// GetSendURL returns the value of SendURL. +func (s *PaymentCancelCardResponse) GetSendURL() OptNilString { + return s.SendURL +} + +// GetSubscriptionID returns the value of SubscriptionID. +func (s *PaymentCancelCardResponse) GetSubscriptionID() OptNilString { + return s.SubscriptionID +} + +// GetBrand returns the value of Brand. +func (s *PaymentCancelCardResponse) GetBrand() OptString { + return s.Brand +} + +// GetErrorCode returns the value of ErrorCode. +func (s *PaymentCancelCardResponse) GetErrorCode() OptNilString { + return s.ErrorCode +} + +// GetCreated returns the value of Created. +func (s *PaymentCancelCardResponse) GetCreated() OptNilString { + return s.Created +} + +// GetUpdated returns the value of Updated. +func (s *PaymentCancelCardResponse) GetUpdated() OptNilString { + return s.Updated +} + +// SetShopID sets the value of ShopID. +func (s *PaymentCancelCardResponse) SetShopID(val OptString) { + s.ShopID = val +} + +// SetID sets the value of ID. +func (s *PaymentCancelCardResponse) SetID(val OptString) { + s.ID = val +} + +// SetPayType sets the value of PayType. +func (s *PaymentCancelCardResponse) SetPayType(val OptPaymentCancelCardResponsePayType) { + s.PayType = val +} + +// SetStatus sets the value of Status. +func (s *PaymentCancelCardResponse) SetStatus(val OptPaymentCancelCardResponseStatus) { + s.Status = val +} + +// SetAccessID sets the value of AccessID. +func (s *PaymentCancelCardResponse) SetAccessID(val OptString) { + s.AccessID = val +} + +// SetProcessDate sets the value of ProcessDate. +func (s *PaymentCancelCardResponse) SetProcessDate(val OptString) { + s.ProcessDate = val +} + +// SetJobCode sets the value of JobCode. +func (s *PaymentCancelCardResponse) SetJobCode(val OptPaymentCancelCardResponseJobCode) { + s.JobCode = val +} + +// SetItemCode sets the value of ItemCode. +func (s *PaymentCancelCardResponse) SetItemCode(val OptString) { + s.ItemCode = val +} + +// SetAmount sets the value of Amount. +func (s *PaymentCancelCardResponse) SetAmount(val OptInt) { + s.Amount = val +} + +// SetTax sets the value of Tax. +func (s *PaymentCancelCardResponse) SetTax(val OptInt) { + s.Tax = val +} + +// SetTotalAmount sets the value of TotalAmount. +func (s *PaymentCancelCardResponse) SetTotalAmount(val OptInt) { + s.TotalAmount = val +} + +// SetCustomerGroupID sets the value of CustomerGroupID. +func (s *PaymentCancelCardResponse) SetCustomerGroupID(val OptNilString) { + s.CustomerGroupID = val +} + +// SetCustomerID sets the value of CustomerID. +func (s *PaymentCancelCardResponse) SetCustomerID(val OptNilString) { + s.CustomerID = val +} + +// SetCardNo sets the value of CardNo. +func (s *PaymentCancelCardResponse) SetCardNo(val OptNilString) { + s.CardNo = val +} + +// SetCardID sets the value of CardID. +func (s *PaymentCancelCardResponse) SetCardID(val OptNilString) { + s.CardID = val +} + +// SetExpire sets the value of Expire. +func (s *PaymentCancelCardResponse) SetExpire(val OptNilString) { + s.Expire = val +} + +// SetHolderName sets the value of HolderName. +func (s *PaymentCancelCardResponse) SetHolderName(val OptNilString) { + s.HolderName = val +} + +// SetCardNoHash sets the value of CardNoHash. +func (s *PaymentCancelCardResponse) SetCardNoHash(val OptNilString) { + s.CardNoHash = val +} + +// SetMethod sets the value of Method. +func (s *PaymentCancelCardResponse) SetMethod(val OptNilPaymentCancelCardResponseMethod) { + s.Method = val +} + +// SetPayTimes sets the value of PayTimes. +func (s *PaymentCancelCardResponse) SetPayTimes(val OptNilString) { + s.PayTimes = val +} + +// SetForward sets the value of Forward. +func (s *PaymentCancelCardResponse) SetForward(val OptNilString) { + s.Forward = val +} + +// SetIssuer sets the value of Issuer. +func (s *PaymentCancelCardResponse) SetIssuer(val OptNilString) { + s.Issuer = val +} + +// SetTransactionID sets the value of TransactionID. +func (s *PaymentCancelCardResponse) SetTransactionID(val OptNilString) { + s.TransactionID = val +} + +// SetApprove sets the value of Approve. +func (s *PaymentCancelCardResponse) SetApprove(val OptNilString) { + s.Approve = val +} + +// SetAuthMaxDate sets the value of AuthMaxDate. +func (s *PaymentCancelCardResponse) SetAuthMaxDate(val OptNilString) { + s.AuthMaxDate = val +} + +// SetClientField1 sets the value of ClientField1. +func (s *PaymentCancelCardResponse) SetClientField1(val OptNilString) { + s.ClientField1 = val +} + +// SetClientField2 sets the value of ClientField2. +func (s *PaymentCancelCardResponse) SetClientField2(val OptNilString) { + s.ClientField2 = val +} + +// SetClientField3 sets the value of ClientField3. +func (s *PaymentCancelCardResponse) SetClientField3(val OptNilString) { + s.ClientField3 = val +} + +// SetTdsType sets the value of TdsType. +func (s *PaymentCancelCardResponse) SetTdsType(val OptNilPaymentCancelCardResponseTdsType) { + s.TdsType = val +} + +// SetTds2Type sets the value of Tds2Type. +func (s *PaymentCancelCardResponse) SetTds2Type(val OptNilPaymentCancelCardResponseTds2Type) { + s.Tds2Type = val +} + +// SetTds2RetURL sets the value of Tds2RetURL. +func (s *PaymentCancelCardResponse) SetTds2RetURL(val OptNilString) { + s.Tds2RetURL = val +} + +// SetTds2Status sets the value of Tds2Status. +func (s *PaymentCancelCardResponse) SetTds2Status(val OptNilPaymentCancelCardResponseTds2Status) { + s.Tds2Status = val +} + +// SetMerchantName sets the value of MerchantName. +func (s *PaymentCancelCardResponse) SetMerchantName(val OptNilString) { + s.MerchantName = val +} + +// SetSendURL sets the value of SendURL. +func (s *PaymentCancelCardResponse) SetSendURL(val OptNilString) { + s.SendURL = val +} + +// SetSubscriptionID sets the value of SubscriptionID. +func (s *PaymentCancelCardResponse) SetSubscriptionID(val OptNilString) { + s.SubscriptionID = val +} + +// SetBrand sets the value of Brand. +func (s *PaymentCancelCardResponse) SetBrand(val OptString) { + s.Brand = val +} + +// SetErrorCode sets the value of ErrorCode. +func (s *PaymentCancelCardResponse) SetErrorCode(val OptNilString) { + s.ErrorCode = val +} + +// SetCreated sets the value of Created. +func (s *PaymentCancelCardResponse) SetCreated(val OptNilString) { + s.Created = val +} + +// SetUpdated sets the value of Updated. +func (s *PaymentCancelCardResponse) SetUpdated(val OptNilString) { + s.Updated = val +} + +type PaymentCancelCardResponseJobCode string + +const ( + PaymentCancelCardResponseJobCodeCHECK PaymentCancelCardResponseJobCode = "CHECK" + PaymentCancelCardResponseJobCodeAUTH PaymentCancelCardResponseJobCode = "AUTH" + PaymentCancelCardResponseJobCodeCAPTURE PaymentCancelCardResponseJobCode = "CAPTURE" + PaymentCancelCardResponseJobCodeSALES PaymentCancelCardResponseJobCode = "SALES" + PaymentCancelCardResponseJobCodeCANCEL PaymentCancelCardResponseJobCode = "CANCEL" +) + +// AllValues returns all PaymentCancelCardResponseJobCode values. +func (PaymentCancelCardResponseJobCode) AllValues() []PaymentCancelCardResponseJobCode { + return []PaymentCancelCardResponseJobCode{ + PaymentCancelCardResponseJobCodeCHECK, + PaymentCancelCardResponseJobCodeAUTH, + PaymentCancelCardResponseJobCodeCAPTURE, + PaymentCancelCardResponseJobCodeSALES, + PaymentCancelCardResponseJobCodeCANCEL, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseJobCode) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseJobCodeCHECK: + return []byte(s), nil + case PaymentCancelCardResponseJobCodeAUTH: + return []byte(s), nil + case PaymentCancelCardResponseJobCodeCAPTURE: + return []byte(s), nil + case PaymentCancelCardResponseJobCodeSALES: + return []byte(s), nil + case PaymentCancelCardResponseJobCodeCANCEL: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseJobCode) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseJobCode(data) { + case PaymentCancelCardResponseJobCodeCHECK: + *s = PaymentCancelCardResponseJobCodeCHECK + return nil + case PaymentCancelCardResponseJobCodeAUTH: + *s = PaymentCancelCardResponseJobCodeAUTH + return nil + case PaymentCancelCardResponseJobCodeCAPTURE: + *s = PaymentCancelCardResponseJobCodeCAPTURE + return nil + case PaymentCancelCardResponseJobCodeSALES: + *s = PaymentCancelCardResponseJobCodeSALES + return nil + case PaymentCancelCardResponseJobCodeCANCEL: + *s = PaymentCancelCardResponseJobCodeCANCEL + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type PaymentCancelCardResponseMethod string -// IsSet returns true if OptPaymentMethodDirectDebitResponsePayType was set. -func (o OptPaymentMethodDirectDebitResponsePayType) IsSet() bool { return o.Set } +const ( + PaymentCancelCardResponseMethod1 PaymentCancelCardResponseMethod = "1" + PaymentCancelCardResponseMethod2 PaymentCancelCardResponseMethod = "2" + PaymentCancelCardResponseMethod5 PaymentCancelCardResponseMethod = "5" +) -// Reset unsets value. -func (o *OptPaymentMethodDirectDebitResponsePayType) Reset() { - var v PaymentMethodDirectDebitResponsePayType - o.Value = v - o.Set = false +// AllValues returns all PaymentCancelCardResponseMethod values. +func (PaymentCancelCardResponseMethod) AllValues() []PaymentCancelCardResponseMethod { + return []PaymentCancelCardResponseMethod{ + PaymentCancelCardResponseMethod1, + PaymentCancelCardResponseMethod2, + PaymentCancelCardResponseMethod5, + } } -// SetTo sets value to v. -func (o *OptPaymentMethodDirectDebitResponsePayType) SetTo(v PaymentMethodDirectDebitResponsePayType) { - o.Set = true - o.Value = v +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseMethod) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseMethod1: + return []byte(s), nil + case PaymentCancelCardResponseMethod2: + return []byte(s), nil + case PaymentCancelCardResponseMethod5: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } } -// Get returns value and boolean that denotes whether value was set. -func (o OptPaymentMethodDirectDebitResponsePayType) Get() (v PaymentMethodDirectDebitResponsePayType, ok bool) { - if !o.Set { - return v, false +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseMethod) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseMethod(data) { + case PaymentCancelCardResponseMethod1: + *s = PaymentCancelCardResponseMethod1 + return nil + case PaymentCancelCardResponseMethod2: + *s = PaymentCancelCardResponseMethod2 + return nil + case PaymentCancelCardResponseMethod5: + *s = PaymentCancelCardResponseMethod5 + return nil + default: + return errors.Errorf("invalid value: %q", data) } - return o.Value, true } -// Or returns value if set, or given parameter if does not. -func (o OptPaymentMethodDirectDebitResponsePayType) Or(d PaymentMethodDirectDebitResponsePayType) PaymentMethodDirectDebitResponsePayType { - if v, ok := o.Get(); ok { - return v +type PaymentCancelCardResponsePayType string + +const ( + PaymentCancelCardResponsePayTypeCard PaymentCancelCardResponsePayType = "Card" +) + +// AllValues returns all PaymentCancelCardResponsePayType values. +func (PaymentCancelCardResponsePayType) AllValues() []PaymentCancelCardResponsePayType { + return []PaymentCancelCardResponsePayType{ + PaymentCancelCardResponsePayTypeCard, } - return d } -// NewOptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag returns new OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag with value set to v. -func NewOptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag(v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag { - return OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag{ - Value: v, - Set: true, +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponsePayType) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponsePayTypeCard: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) } } -// OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag is optional PaymentMethodDirectDebitResponseRedirectURLAccessedFlag. -type OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag struct { - Value PaymentMethodDirectDebitResponseRedirectURLAccessedFlag - Set bool +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponsePayType) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponsePayType(data) { + case PaymentCancelCardResponsePayTypeCard: + *s = PaymentCancelCardResponsePayTypeCard + return nil + default: + return errors.Errorf("invalid value: %q", data) + } } -// IsSet returns true if OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag was set. -func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) IsSet() bool { return o.Set } - -// Reset unsets value. -func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Reset() { - var v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag - o.Value = v - o.Set = false -} +type PaymentCancelCardResponseStatus string -// SetTo sets value to v. -func (o *OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) SetTo(v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) { - o.Set = true - o.Value = v -} +const ( + PaymentCancelCardResponseStatusUNPROCESSED PaymentCancelCardResponseStatus = "UNPROCESSED" + PaymentCancelCardResponseStatusCHECKED PaymentCancelCardResponseStatus = "CHECKED" + PaymentCancelCardResponseStatusAUTHORIZED PaymentCancelCardResponseStatus = "AUTHORIZED" + PaymentCancelCardResponseStatusCAPTURED PaymentCancelCardResponseStatus = "CAPTURED" + PaymentCancelCardResponseStatusCANCELED PaymentCancelCardResponseStatus = "CANCELED" + PaymentCancelCardResponseStatusAUTHENTICATED PaymentCancelCardResponseStatus = "AUTHENTICATED" +) -// Get returns value and boolean that denotes whether value was set. -func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Get() (v PaymentMethodDirectDebitResponseRedirectURLAccessedFlag, ok bool) { - if !o.Set { - return v, false +// AllValues returns all PaymentCancelCardResponseStatus values. +func (PaymentCancelCardResponseStatus) AllValues() []PaymentCancelCardResponseStatus { + return []PaymentCancelCardResponseStatus{ + PaymentCancelCardResponseStatusUNPROCESSED, + PaymentCancelCardResponseStatusCHECKED, + PaymentCancelCardResponseStatusAUTHORIZED, + PaymentCancelCardResponseStatusCAPTURED, + PaymentCancelCardResponseStatusCANCELED, + PaymentCancelCardResponseStatusAUTHENTICATED, } - return o.Value, true } -// Or returns value if set, or given parameter if does not. -func (o OptPaymentMethodDirectDebitResponseRedirectURLAccessedFlag) Or(d PaymentMethodDirectDebitResponseRedirectURLAccessedFlag) PaymentMethodDirectDebitResponseRedirectURLAccessedFlag { - if v, ok := o.Get(); ok { - return v +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseStatus) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseStatusUNPROCESSED: + return []byte(s), nil + case PaymentCancelCardResponseStatusCHECKED: + return []byte(s), nil + case PaymentCancelCardResponseStatusAUTHORIZED: + return []byte(s), nil + case PaymentCancelCardResponseStatusCAPTURED: + return []byte(s), nil + case PaymentCancelCardResponseStatusCANCELED: + return []byte(s), nil + case PaymentCancelCardResponseStatusAUTHENTICATED: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) } - return d } -// NewOptPaymentMethodDirectDebitResponseStatus returns new OptPaymentMethodDirectDebitResponseStatus with value set to v. -func NewOptPaymentMethodDirectDebitResponseStatus(v PaymentMethodDirectDebitResponseStatus) OptPaymentMethodDirectDebitResponseStatus { - return OptPaymentMethodDirectDebitResponseStatus{ - Value: v, - Set: true, +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseStatus) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseStatus(data) { + case PaymentCancelCardResponseStatusUNPROCESSED: + *s = PaymentCancelCardResponseStatusUNPROCESSED + return nil + case PaymentCancelCardResponseStatusCHECKED: + *s = PaymentCancelCardResponseStatusCHECKED + return nil + case PaymentCancelCardResponseStatusAUTHORIZED: + *s = PaymentCancelCardResponseStatusAUTHORIZED + return nil + case PaymentCancelCardResponseStatusCAPTURED: + *s = PaymentCancelCardResponseStatusCAPTURED + return nil + case PaymentCancelCardResponseStatusCANCELED: + *s = PaymentCancelCardResponseStatusCANCELED + return nil + case PaymentCancelCardResponseStatusAUTHENTICATED: + *s = PaymentCancelCardResponseStatusAUTHENTICATED + return nil + default: + return errors.Errorf("invalid value: %q", data) } } -// OptPaymentMethodDirectDebitResponseStatus is optional PaymentMethodDirectDebitResponseStatus. -type OptPaymentMethodDirectDebitResponseStatus struct { - Value PaymentMethodDirectDebitResponseStatus - Set bool -} +type PaymentCancelCardResponseTds2Status string -// IsSet returns true if OptPaymentMethodDirectDebitResponseStatus was set. -func (o OptPaymentMethodDirectDebitResponseStatus) IsSet() bool { return o.Set } +const ( + PaymentCancelCardResponseTds2StatusAUTHENTICATING PaymentCancelCardResponseTds2Status = "AUTHENTICATING" + PaymentCancelCardResponseTds2StatusCHALLENGE PaymentCancelCardResponseTds2Status = "CHALLENGE" + PaymentCancelCardResponseTds2StatusAUTHENTICATED PaymentCancelCardResponseTds2Status = "AUTHENTICATED" +) -// Reset unsets value. -func (o *OptPaymentMethodDirectDebitResponseStatus) Reset() { - var v PaymentMethodDirectDebitResponseStatus - o.Value = v - o.Set = false +// AllValues returns all PaymentCancelCardResponseTds2Status values. +func (PaymentCancelCardResponseTds2Status) AllValues() []PaymentCancelCardResponseTds2Status { + return []PaymentCancelCardResponseTds2Status{ + PaymentCancelCardResponseTds2StatusAUTHENTICATING, + PaymentCancelCardResponseTds2StatusCHALLENGE, + PaymentCancelCardResponseTds2StatusAUTHENTICATED, + } } -// SetTo sets value to v. -func (o *OptPaymentMethodDirectDebitResponseStatus) SetTo(v PaymentMethodDirectDebitResponseStatus) { - o.Set = true - o.Value = v +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseTds2Status) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseTds2StatusAUTHENTICATING: + return []byte(s), nil + case PaymentCancelCardResponseTds2StatusCHALLENGE: + return []byte(s), nil + case PaymentCancelCardResponseTds2StatusAUTHENTICATED: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } } -// Get returns value and boolean that denotes whether value was set. -func (o OptPaymentMethodDirectDebitResponseStatus) Get() (v PaymentMethodDirectDebitResponseStatus, ok bool) { - if !o.Set { - return v, false +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseTds2Status) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseTds2Status(data) { + case PaymentCancelCardResponseTds2StatusAUTHENTICATING: + *s = PaymentCancelCardResponseTds2StatusAUTHENTICATING + return nil + case PaymentCancelCardResponseTds2StatusCHALLENGE: + *s = PaymentCancelCardResponseTds2StatusCHALLENGE + return nil + case PaymentCancelCardResponseTds2StatusAUTHENTICATED: + *s = PaymentCancelCardResponseTds2StatusAUTHENTICATED + return nil + default: + return errors.Errorf("invalid value: %q", data) } - return o.Value, true } -// Or returns value if set, or given parameter if does not. -func (o OptPaymentMethodDirectDebitResponseStatus) Or(d PaymentMethodDirectDebitResponseStatus) PaymentMethodDirectDebitResponseStatus { - if v, ok := o.Get(); ok { - return v +type PaymentCancelCardResponseTds2Type string + +const ( + PaymentCancelCardResponseTds2Type2 PaymentCancelCardResponseTds2Type = "2" + PaymentCancelCardResponseTds2Type3 PaymentCancelCardResponseTds2Type = "3" +) + +// AllValues returns all PaymentCancelCardResponseTds2Type values. +func (PaymentCancelCardResponseTds2Type) AllValues() []PaymentCancelCardResponseTds2Type { + return []PaymentCancelCardResponseTds2Type{ + PaymentCancelCardResponseTds2Type2, + PaymentCancelCardResponseTds2Type3, } - return d } -// NewOptString returns new OptString with value set to v. -func NewOptString(v string) OptString { - return OptString{ - Value: v, - Set: true, +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseTds2Type) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseTds2Type2: + return []byte(s), nil + case PaymentCancelCardResponseTds2Type3: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) } } -// OptString is optional string. -type OptString struct { - Value string - Set bool +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseTds2Type) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseTds2Type(data) { + case PaymentCancelCardResponseTds2Type2: + *s = PaymentCancelCardResponseTds2Type2 + return nil + case PaymentCancelCardResponseTds2Type3: + *s = PaymentCancelCardResponseTds2Type3 + return nil + default: + return errors.Errorf("invalid value: %q", data) + } } -// IsSet returns true if OptString was set. -func (o OptString) IsSet() bool { return o.Set } +type PaymentCancelCardResponseTdsType string -// Reset unsets value. -func (o *OptString) Reset() { - var v string - o.Value = v - o.Set = false -} +const ( + PaymentCancelCardResponseTdsType0 PaymentCancelCardResponseTdsType = "0" + PaymentCancelCardResponseTdsType2 PaymentCancelCardResponseTdsType = "2" +) -// SetTo sets value to v. -func (o *OptString) SetTo(v string) { - o.Set = true - o.Value = v +// AllValues returns all PaymentCancelCardResponseTdsType values. +func (PaymentCancelCardResponseTdsType) AllValues() []PaymentCancelCardResponseTdsType { + return []PaymentCancelCardResponseTdsType{ + PaymentCancelCardResponseTdsType0, + PaymentCancelCardResponseTdsType2, + } } -// Get returns value and boolean that denotes whether value was set. -func (o OptString) Get() (v string, ok bool) { - if !o.Set { - return v, false +// MarshalText implements encoding.TextMarshaler. +func (s PaymentCancelCardResponseTdsType) MarshalText() ([]byte, error) { + switch s { + case PaymentCancelCardResponseTdsType0: + return []byte(s), nil + case PaymentCancelCardResponseTdsType2: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) } - return o.Value, true } -// Or returns value if set, or given parameter if does not. -func (o OptString) Or(d string) string { - if v, ok := o.Get(); ok { - return v +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PaymentCancelCardResponseTdsType) UnmarshalText(data []byte) error { + switch PaymentCancelCardResponseTdsType(data) { + case PaymentCancelCardResponseTdsType0: + *s = PaymentCancelCardResponseTdsType0 + return nil + case PaymentCancelCardResponseTdsType2: + *s = PaymentCancelCardResponseTdsType2 + return nil + default: + return errors.Errorf("invalid value: %q", data) } - return d } // Ref: #/components/schemas/paymentCard @@ -5225,7 +6452,7 @@ const ( PaymentCardResponseStatusCHECKED PaymentCardResponseStatus = "CHECKED" PaymentCardResponseStatusAUTHORIZED PaymentCardResponseStatus = "AUTHORIZED" PaymentCardResponseStatusCAPTURED PaymentCardResponseStatus = "CAPTURED" - PaymentCardResponseStatusCANCELLED PaymentCardResponseStatus = "CANCELLED" + PaymentCardResponseStatusCANCELED PaymentCardResponseStatus = "CANCELED" PaymentCardResponseStatusAUTHENTICATED PaymentCardResponseStatus = "AUTHENTICATED" ) @@ -5236,7 +6463,7 @@ func (PaymentCardResponseStatus) AllValues() []PaymentCardResponseStatus { PaymentCardResponseStatusCHECKED, PaymentCardResponseStatusAUTHORIZED, PaymentCardResponseStatusCAPTURED, - PaymentCardResponseStatusCANCELLED, + PaymentCardResponseStatusCANCELED, PaymentCardResponseStatusAUTHENTICATED, } } @@ -5252,7 +6479,7 @@ func (s PaymentCardResponseStatus) MarshalText() ([]byte, error) { return []byte(s), nil case PaymentCardResponseStatusCAPTURED: return []byte(s), nil - case PaymentCardResponseStatusCANCELLED: + case PaymentCardResponseStatusCANCELED: return []byte(s), nil case PaymentCardResponseStatusAUTHENTICATED: return []byte(s), nil @@ -5276,8 +6503,8 @@ func (s *PaymentCardResponseStatus) UnmarshalText(data []byte) error { case PaymentCardResponseStatusCAPTURED: *s = PaymentCardResponseStatusCAPTURED return nil - case PaymentCardResponseStatusCANCELLED: - *s = PaymentCardResponseStatusCANCELLED + case PaymentCardResponseStatusCANCELED: + *s = PaymentCardResponseStatusCANCELED return nil case PaymentCardResponseStatusAUTHENTICATED: *s = PaymentCardResponseStatusAUTHENTICATED @@ -6092,7 +7319,7 @@ const ( PaymentDirectdebitResponseStatusUNPROCESSED PaymentDirectdebitResponseStatus = "UNPROCESSED" PaymentDirectdebitResponseStatusAWAITINGPAYMENTAPPROVAL PaymentDirectdebitResponseStatus = "AWAITING_PAYMENT_APPROVAL" PaymentDirectdebitResponseStatusCAPTURED PaymentDirectdebitResponseStatus = "CAPTURED" - PaymentDirectdebitResponseStatusCANCELLED PaymentDirectdebitResponseStatus = "CANCELLED" + PaymentDirectdebitResponseStatusCANCELED PaymentDirectdebitResponseStatus = "CANCELED" PaymentDirectdebitResponseStatusFAILED PaymentDirectdebitResponseStatus = "FAILED" ) @@ -6102,7 +7329,7 @@ func (PaymentDirectdebitResponseStatus) AllValues() []PaymentDirectdebitResponse PaymentDirectdebitResponseStatusUNPROCESSED, PaymentDirectdebitResponseStatusAWAITINGPAYMENTAPPROVAL, PaymentDirectdebitResponseStatusCAPTURED, - PaymentDirectdebitResponseStatusCANCELLED, + PaymentDirectdebitResponseStatusCANCELED, PaymentDirectdebitResponseStatusFAILED, } } @@ -6116,7 +7343,7 @@ func (s PaymentDirectdebitResponseStatus) MarshalText() ([]byte, error) { return []byte(s), nil case PaymentDirectdebitResponseStatusCAPTURED: return []byte(s), nil - case PaymentDirectdebitResponseStatusCANCELLED: + case PaymentDirectdebitResponseStatusCANCELED: return []byte(s), nil case PaymentDirectdebitResponseStatusFAILED: return []byte(s), nil @@ -6137,8 +7364,8 @@ func (s *PaymentDirectdebitResponseStatus) UnmarshalText(data []byte) error { case PaymentDirectdebitResponseStatusCAPTURED: *s = PaymentDirectdebitResponseStatusCAPTURED return nil - case PaymentDirectdebitResponseStatusCANCELLED: - *s = PaymentDirectdebitResponseStatusCANCELLED + case PaymentDirectdebitResponseStatusCANCELED: + *s = PaymentDirectdebitResponseStatusCANCELED return nil case PaymentDirectdebitResponseStatusFAILED: *s = PaymentDirectdebitResponseStatusFAILED @@ -6754,7 +7981,7 @@ const ( PaymentDoCardResponseStatusCHECKED PaymentDoCardResponseStatus = "CHECKED" PaymentDoCardResponseStatusAUTHORIZED PaymentDoCardResponseStatus = "AUTHORIZED" PaymentDoCardResponseStatusCAPTURED PaymentDoCardResponseStatus = "CAPTURED" - PaymentDoCardResponseStatusCANCELLED PaymentDoCardResponseStatus = "CANCELLED" + PaymentDoCardResponseStatusCANCELED PaymentDoCardResponseStatus = "CANCELED" PaymentDoCardResponseStatusAUTHENTICATED PaymentDoCardResponseStatus = "AUTHENTICATED" ) @@ -6765,7 +7992,7 @@ func (PaymentDoCardResponseStatus) AllValues() []PaymentDoCardResponseStatus { PaymentDoCardResponseStatusCHECKED, PaymentDoCardResponseStatusAUTHORIZED, PaymentDoCardResponseStatusCAPTURED, - PaymentDoCardResponseStatusCANCELLED, + PaymentDoCardResponseStatusCANCELED, PaymentDoCardResponseStatusAUTHENTICATED, } } @@ -6781,7 +8008,7 @@ func (s PaymentDoCardResponseStatus) MarshalText() ([]byte, error) { return []byte(s), nil case PaymentDoCardResponseStatusCAPTURED: return []byte(s), nil - case PaymentDoCardResponseStatusCANCELLED: + case PaymentDoCardResponseStatusCANCELED: return []byte(s), nil case PaymentDoCardResponseStatusAUTHENTICATED: return []byte(s), nil @@ -6805,8 +8032,8 @@ func (s *PaymentDoCardResponseStatus) UnmarshalText(data []byte) error { case PaymentDoCardResponseStatusCAPTURED: *s = PaymentDoCardResponseStatusCAPTURED return nil - case PaymentDoCardResponseStatusCANCELLED: - *s = PaymentDoCardResponseStatusCANCELLED + case PaymentDoCardResponseStatusCANCELED: + *s = PaymentDoCardResponseStatusCANCELED return nil case PaymentDoCardResponseStatusAUTHENTICATED: *s = PaymentDoCardResponseStatusAUTHENTICATED @@ -11886,6 +13113,88 @@ func (s *PaymentsGetOKListItem) SetUpdated(val OptString) { s.Updated = val } +// PaymentsIDCancelPutOK represents sum type. +type PaymentsIDCancelPutOK struct { + Type PaymentsIDCancelPutOKType // switch on this field + PaymentCancelCardResponse PaymentCancelCardResponse +} + +// PaymentsIDCancelPutOKType is oneOf type of PaymentsIDCancelPutOK. +type PaymentsIDCancelPutOKType string + +// Possible values for PaymentsIDCancelPutOKType. +const ( + PaymentCancelCardResponsePaymentsIDCancelPutOK PaymentsIDCancelPutOKType = "PaymentCancelCardResponse" +) + +// IsPaymentCancelCardResponse reports whether PaymentsIDCancelPutOK is PaymentCancelCardResponse. +func (s PaymentsIDCancelPutOK) IsPaymentCancelCardResponse() bool { + return s.Type == PaymentCancelCardResponsePaymentsIDCancelPutOK +} + +// SetPaymentCancelCardResponse sets PaymentsIDCancelPutOK to PaymentCancelCardResponse. +func (s *PaymentsIDCancelPutOK) SetPaymentCancelCardResponse(v PaymentCancelCardResponse) { + s.Type = PaymentCancelCardResponsePaymentsIDCancelPutOK + s.PaymentCancelCardResponse = v +} + +// GetPaymentCancelCardResponse returns PaymentCancelCardResponse and true boolean if PaymentsIDCancelPutOK is PaymentCancelCardResponse. +func (s PaymentsIDCancelPutOK) GetPaymentCancelCardResponse() (v PaymentCancelCardResponse, ok bool) { + if !s.IsPaymentCancelCardResponse() { + return v, false + } + return s.PaymentCancelCardResponse, true +} + +// NewPaymentCancelCardResponsePaymentsIDCancelPutOK returns new PaymentsIDCancelPutOK from PaymentCancelCardResponse. +func NewPaymentCancelCardResponsePaymentsIDCancelPutOK(v PaymentCancelCardResponse) PaymentsIDCancelPutOK { + var s PaymentsIDCancelPutOK + s.SetPaymentCancelCardResponse(v) + return s +} + +func (*PaymentsIDCancelPutOK) paymentsIDCancelPutRes() {} + +// PaymentsIDCancelPutReq represents sum type. +type PaymentsIDCancelPutReq struct { + Type PaymentsIDCancelPutReqType // switch on this field + PaymentCancelCard PaymentCancelCard +} + +// PaymentsIDCancelPutReqType is oneOf type of PaymentsIDCancelPutReq. +type PaymentsIDCancelPutReqType string + +// Possible values for PaymentsIDCancelPutReqType. +const ( + PaymentCancelCardPaymentsIDCancelPutReq PaymentsIDCancelPutReqType = "PaymentCancelCard" +) + +// IsPaymentCancelCard reports whether PaymentsIDCancelPutReq is PaymentCancelCard. +func (s PaymentsIDCancelPutReq) IsPaymentCancelCard() bool { + return s.Type == PaymentCancelCardPaymentsIDCancelPutReq +} + +// SetPaymentCancelCard sets PaymentsIDCancelPutReq to PaymentCancelCard. +func (s *PaymentsIDCancelPutReq) SetPaymentCancelCard(v PaymentCancelCard) { + s.Type = PaymentCancelCardPaymentsIDCancelPutReq + s.PaymentCancelCard = v +} + +// GetPaymentCancelCard returns PaymentCancelCard and true boolean if PaymentsIDCancelPutReq is PaymentCancelCard. +func (s PaymentsIDCancelPutReq) GetPaymentCancelCard() (v PaymentCancelCard, ok bool) { + if !s.IsPaymentCancelCard() { + return v, false + } + return s.PaymentCancelCard, true +} + +// NewPaymentCancelCardPaymentsIDCancelPutReq returns new PaymentsIDCancelPutReq from PaymentCancelCard. +func NewPaymentCancelCardPaymentsIDCancelPutReq(v PaymentCancelCard) PaymentsIDCancelPutReq { + var s PaymentsIDCancelPutReq + s.SetPaymentCancelCard(v) + return s +} + // PaymentsIDGetOK represents sum type. type PaymentsIDGetOK struct { Type PaymentsIDGetOKType // switch on this field diff --git a/api/oas_server_gen.go b/api/oas_server_gen.go index 9e854d7..dc05dd5 100644 --- a/api/oas_server_gen.go +++ b/api/oas_server_gen.go @@ -44,6 +44,10 @@ type Handler interface { // // GET /payments PaymentsGet(ctx context.Context, params PaymentsGetParams) (PaymentsGetRes, error) + // PaymentsIDCancelPut implements PUT /payments/{id}/cancel operation. + // + // PUT /payments/{id}/cancel + PaymentsIDCancelPut(ctx context.Context, req PaymentsIDCancelPutReq, params PaymentsIDCancelPutParams) (PaymentsIDCancelPutRes, error) // PaymentsIDGet implements GET /payments/{id} operation. // // GET /payments/{id} diff --git a/api/oas_unimplemented_gen.go b/api/oas_unimplemented_gen.go index ad9dc9a..86ab19a 100644 --- a/api/oas_unimplemented_gen.go +++ b/api/oas_unimplemented_gen.go @@ -76,6 +76,13 @@ func (UnimplementedHandler) PaymentsGet(ctx context.Context, params PaymentsGetP return r, ht.ErrNotImplemented } +// PaymentsIDCancelPut implements PUT /payments/{id}/cancel operation. +// +// PUT /payments/{id}/cancel +func (UnimplementedHandler) PaymentsIDCancelPut(ctx context.Context, req PaymentsIDCancelPutReq, params PaymentsIDCancelPutParams) (r PaymentsIDCancelPutRes, _ error) { + return r, ht.ErrNotImplemented +} + // PaymentsIDGet implements GET /payments/{id} operation. // // GET /payments/{id} diff --git a/api/oas_validators_gen.go b/api/oas_validators_gen.go index b795abf..487fbae 100644 --- a/api/oas_validators_gen.go +++ b/api/oas_validators_gen.go @@ -326,6 +326,373 @@ func (s *ErrorResponse) Validate() error { return nil } +func (s *PaymentCancelCard) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.PayType.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "pay_type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s PaymentCancelCardPayType) Validate() error { + switch s { + case "Card": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *PaymentCancelCardResponse) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if value, ok := s.PayType.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "pay_type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Status.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.ProcessDate.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 0, + MaxLengthSet: false, + Email: false, + Hostname: false, + Regex: regexMap["^(\\d{4})/(\\d{2})/(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})[^\r\n\u2028\u2029](\\d{3})$"], + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "process_date", + Error: err, + }) + } + if err := func() error { + if value, ok := s.JobCode.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "job_code", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Expire.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 0, + MaxLengthSet: false, + Email: false, + Hostname: false, + Regex: regexMap["^(\\d{4})$"], + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "expire", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Method.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "method", + Error: err, + }) + } + if err := func() error { + if value, ok := s.TdsType.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tds_type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Tds2Type.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tds2_type", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Tds2Status.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "tds2_status", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Created.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 0, + MaxLengthSet: false, + Email: false, + Hostname: false, + Regex: regexMap["^(\\d{4})/(\\d{2})/(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})[^\r\n\u2028\u2029](\\d{3})$"], + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "created", + Error: err, + }) + } + if err := func() error { + if value, ok := s.Updated.Get(); ok { + if err := func() error { + if err := (validate.String{ + MinLength: 0, + MinLengthSet: false, + MaxLength: 0, + MaxLengthSet: false, + Email: false, + Hostname: false, + Regex: regexMap["^(\\d{4})/(\\d{2})/(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})[^\r\n\u2028\u2029](\\d{3})$"], + }).Validate(string(value)); err != nil { + return errors.Wrap(err, "string") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "updated", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s PaymentCancelCardResponseJobCode) Validate() error { + switch s { + case "CHECK": + return nil + case "AUTH": + return nil + case "CAPTURE": + return nil + case "SALES": + return nil + case "CANCEL": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponseMethod) Validate() error { + switch s { + case "1": + return nil + case "2": + return nil + case "5": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponsePayType) Validate() error { + switch s { + case "Card": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponseStatus) Validate() error { + switch s { + case "UNPROCESSED": + return nil + case "CHECKED": + return nil + case "AUTHORIZED": + return nil + case "CAPTURED": + return nil + case "CANCELED": + return nil + case "AUTHENTICATED": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponseTds2Status) Validate() error { + switch s { + case "AUTHENTICATING": + return nil + case "CHALLENGE": + return nil + case "AUTHENTICATED": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponseTds2Type) Validate() error { + switch s { + case "2": + return nil + case "3": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s PaymentCancelCardResponseTdsType) Validate() error { + switch s { + case "0": + return nil + case "2": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *PaymentCard) Validate() error { if s == nil { return validate.ErrNilPointer @@ -713,7 +1080,7 @@ func (s PaymentCardResponseStatus) Validate() error { return nil case "CAPTURED": return nil - case "CANCELLED": + case "CANCELED": return nil case "AUTHENTICATED": return nil @@ -1001,7 +1368,7 @@ func (s PaymentDirectdebitResponseStatus) Validate() error { return nil case "CAPTURED": return nil - case "CANCELLED": + case "CANCELED": return nil case "FAILED": return nil @@ -1301,7 +1668,7 @@ func (s PaymentDoCardResponseStatus) Validate() error { return nil case "CAPTURED": return nil - case "CANCELLED": + case "CANCELED": return nil case "AUTHENTICATED": return nil @@ -3110,6 +3477,30 @@ func (s PaymentMethodDirectDebitResponseStatus) Validate() error { } } +func (s PaymentsIDCancelPutOK) Validate() error { + switch s.Type { + case PaymentCancelCardResponsePaymentsIDCancelPutOK: + if err := s.PaymentCancelCardResponse.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + +func (s PaymentsIDCancelPutReq) Validate() error { + switch s.Type { + case PaymentCancelCardPaymentsIDCancelPutReq: + if err := s.PaymentCancelCard.Validate(); err != nil { + return err + } + return nil + default: + return errors.Errorf("invalid type %q", s.Type) + } +} + func (s PaymentsIDGetOK) Validate() error { switch s.Type { case PaymentCardResponsePaymentsIDGetOK: diff --git a/payments_test.go b/payments_test.go index 537b883..867f6bd 100644 --- a/payments_test.go +++ b/payments_test.go @@ -103,7 +103,7 @@ func TestPayments(t *testing.T) { t.Run("Get a Payment", func(t *testing.T) { res, err := c.PaymentsIDGet(ctx, api.PaymentsIDGetParams{ - ID: orderID, + ID: orderID, PayType: "Card", }) if err != nil { @@ -125,10 +125,10 @@ func TestPayments(t *testing.T) { t.Run("List Payments", func(t *testing.T) { today := time.Now().Format("2006/01/02") res, err := c.PaymentsGet(ctx, api.PaymentsGetParams{ - PayType: "Card", + PayType: "Card", ProcessDataFrom: api.NewOptString(today), - Limit: api.NewOptInt(100), - CustomerID: api.NewOptString(customerID), + Limit: api.NewOptInt(100), + CustomerID: api.NewOptString(customerID), }) if err != nil { t.Fatal(err) @@ -138,13 +138,59 @@ func TestPayments(t *testing.T) { t.Fatalf("unexpected response: %T, %#v", res, res) } for _, p := range v.List { - if p.AccessID.Value == accessID { + if p.AccessID.Value == accessID { return } } t.Errorf("payment not found: %s", accessID) }) + t.Run("Cancel Payment", func(t *testing.T) { + res, err := c.PaymentsIDCancelPut(ctx, api.PaymentsIDCancelPutReq{ + Type: api.PaymentCancelCardPaymentsIDCancelPutReq, + PaymentCancelCard: api.PaymentCancelCard{ + PayType: "Card", + AccessID: accessID, + }, + }, + api.PaymentsIDCancelPutParams{ + ID: orderID, + }) + if err != nil { + t.Fatal(err) + } + v, ok := res.(*api.PaymentsIDCancelPutOK) + if !ok { + t.Fatalf("unexpected response: %T, %#v", res, res) + } + if want := orderID; v.PaymentCancelCardResponse.ID.Value != want { + t.Errorf("want %s, got %s", want, v.PaymentCancelCardResponse.ID.Value) + } + if want := api.PaymentCancelCardResponseJobCodeCANCEL; v.PaymentCancelCardResponse.JobCode.Value != want { + t.Errorf("want %s, got %s", want, v.PaymentCancelCardResponse.JobCode.Value) + } + if want := api.PaymentCancelCardResponseStatusCANCELED; v.PaymentCancelCardResponse.Status.Value != want { + t.Errorf("want %s, got %s", want, v.PaymentCancelCardResponse.Status.Value) + } + paymentsIDGetRes, err := c.PaymentsIDGet(ctx, api.PaymentsIDGetParams{ + ID: orderID, + PayType: "Card", + }) + if err != nil { + t.Fatal(err) + } + val, ok := paymentsIDGetRes.(*api.PaymentsIDGetOK) + if !ok { + t.Fatalf("unexpected response: %T, %#v", res, res) + } + if want := orderID; val.PaymentCardResponse.ID.Value != want { + t.Errorf("want %s, got %s", want, val.PaymentCardResponse.ID.Value) + } + if want := api.PaymentCardResponseStatusCANCELED; val.PaymentCardResponse.Status.Value != want { + t.Errorf("want %s, got %s", want, val.PaymentCardResponse.Status.Value) + } + }) + t.Run("Get Card", func(t *testing.T) { res, err := c.CustomersCustomerIDCardsIDGet(ctx, api.CustomersCustomerIDCardsIDGetParams{ CustomerID: customerID, diff --git a/spec/openapi3.yml b/spec/openapi3.yml index 26d9cc1..fbf705d 100644 --- a/spec/openapi3.yml +++ b/spec/openapi3.yml @@ -365,6 +365,35 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorResponse' + /payments/{id}/cancel: + put: + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/paymentCancelCard' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/paymentCancelCardResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' /customers: post: requestBody: @@ -1449,7 +1478,7 @@ components: - CHECKED - AUTHORIZED - CAPTURED - - CANCELLED + - CANCELED - AUTHENTICATED access_id: type: string @@ -1590,7 +1619,7 @@ components: - UNPROCESSED - AWAITING_PAYMENT_APPROVAL - CAPTURED - - CANCELLED + - CANCELED - FAILED access_id: type: string @@ -1904,7 +1933,7 @@ components: - CHECKED - AUTHORIZED - CAPTURED - - CANCELLED + - CANCELED - AUTHENTICATED access_id: type: string @@ -2033,6 +2062,159 @@ components: acs_url: type: string nullable: true + paymentCancelCard: + type: object + required: + - pay_type + - access_id + properties: + pay_type: + type: string + enum: + - Card + access_id: + type: string + paymentCancelCardResponse: + type: object + properties: + shop_id: + type: string + id: + type: string + pay_type: + type: string + enum: + - Card + status: + type: string + enum: + - UNPROCESSED + - CHECKED + - AUTHORIZED + - CAPTURED + - CANCELED + - AUTHENTICATED + access_id: + type: string + process_date: + type: string + pattern: '^(\d{4})/(\d{2})/(\d{2}) (\d{2}):(\d{2}):(\d{2}).(\d{3})$' + job_code: + type: string + enum: + - CHECK + - AUTH + - CAPTURE + - SALES + - CANCEL + item_code: + type: string + amount: + type: integer + tax: + type: integer + total_amount: + type: integer + customer_group_id: + type: string + nullable: true + customer_id: + type: string + nullable: true + card_no: + type: string + nullable: true + card_id: + type: string + nullable: true + expire: + type: string + pattern: '^(\d{4})$' + nullable: true + holder_name: + type: string + nullable: true + card_no_hash: + type: string + nullable: true + method: + type: string + nullable: true + enum: + - '1' + - '2' + - '5' + pay_times: + type: string + nullable: true + forward: + type: string + nullable: true + issuer: + type: string + nullable: true + transaction_id: + type: string + nullable: true + approve: + type: string + nullable: true + auth_max_date: + type: string + nullable: true + client_field_1: + type: string + nullable: true + client_field_2: + type: string + nullable: true + client_field_3: + type: string + nullable: true + tds_type: + type: string + nullable: true + enum: + - '0' + - '2' + tds2_type: + type: string + nullable: true + enum: + - '2' + - '3' + tds2_ret_url: + type: string + nullable: true + tds2_status: + type: string + nullable: true + enum: + - AUTHENTICATING + - CHALLENGE + - AUTHENTICATED + merchant_name: + type: string + nullable: true + send_url: + type: string + nullable: true + subscription_id: + type: string + nullable: true + brand: + type: string + error_code: + type: string + nullable: true + created: + type: string + nullable: true + pattern: '^(\d{4})/(\d{2})/(\d{2}) (\d{2}):(\d{2}):(\d{2}).(\d{3})$' + updated: + type: string + nullable: true + pattern: '^(\d{4})/(\d{2})/(\d{2}) (\d{2}):(\d{2}):(\d{2}).(\d{3})$' securitySchemes: BearerAuth: type: http