Try to use generated yookassa client (unsuccessful)
This commit is contained in:
@@ -1535,6 +1535,115 @@ func (s *BadRequestType) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *BankCard) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *BankCard) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("card")
|
||||
s.Card.Encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfBankCard = [2]string{
|
||||
0: "type",
|
||||
1: "card",
|
||||
}
|
||||
|
||||
// Decode decodes BankCard from json.
|
||||
func (s *BankCard) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode BankCard to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "card":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
if err := s.Card.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"card\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode BankCard")
|
||||
}
|
||||
// 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(jsonFieldsNameOfBankCard) {
|
||||
name = jsonFieldsNameOfBankCard[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 *BankCard) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *BankCard) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *BankCardData) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
@@ -28019,9 +28128,15 @@ func (s *PayoutRequest) encodeFields(e *jx.Encoder) {
|
||||
s.Metadata.Encode(e)
|
||||
}
|
||||
}
|
||||
{
|
||||
if s.Test.Set {
|
||||
e.FieldStart("test")
|
||||
s.Test.Encode(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfPayoutRequest = [8]string{
|
||||
var jsonFieldsNameOfPayoutRequest = [9]string{
|
||||
0: "amount",
|
||||
1: "payout_destination_data",
|
||||
2: "payout_token",
|
||||
@@ -28030,6 +28145,7 @@ var jsonFieldsNameOfPayoutRequest = [8]string{
|
||||
5: "deal",
|
||||
6: "personal_data",
|
||||
7: "metadata",
|
||||
8: "test",
|
||||
}
|
||||
|
||||
// Decode decodes PayoutRequest from json.
|
||||
@@ -28037,7 +28153,7 @@ func (s *PayoutRequest) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode PayoutRequest to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
var requiredBitSet [2]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
@@ -28128,6 +28244,16 @@ func (s *PayoutRequest) Decode(d *jx.Decoder) error {
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"metadata\"")
|
||||
}
|
||||
case "test":
|
||||
if err := func() error {
|
||||
s.Test.Reset()
|
||||
if err := s.Test.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"test\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
@@ -28137,8 +28263,9 @@ func (s *PayoutRequest) Decode(d *jx.Decoder) error {
|
||||
}
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
for i, mask := range [2]uint8{
|
||||
0b00000001,
|
||||
0b00000000,
|
||||
} {
|
||||
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
||||
// Mask only required fields and check equality to mask using XOR.
|
||||
@@ -28304,31 +28431,31 @@ func (s PayoutRequestPayoutDestinationData) Encode(e *jx.Encoder) {
|
||||
|
||||
func (s PayoutRequestPayoutDestinationData) encodeFields(e *jx.Encoder) {
|
||||
switch s.Type {
|
||||
case PayoutToYooMoneyDestinationDataPayoutRequestPayoutDestinationData:
|
||||
case YooMoneyPayoutRequestPayoutDestinationData:
|
||||
e.FieldStart("type")
|
||||
e.Str("PayoutToYooMoneyDestinationData")
|
||||
e.Str("yoo_money")
|
||||
{
|
||||
s := s.PayoutToYooMoneyDestinationData
|
||||
s := s.YooMoney
|
||||
{
|
||||
e.FieldStart("account_number")
|
||||
e.Str(s.AccountNumber)
|
||||
}
|
||||
}
|
||||
case PayoutToBankCardDestinationDataPayoutRequestPayoutDestinationData:
|
||||
case BankCardPayoutRequestPayoutDestinationData:
|
||||
e.FieldStart("type")
|
||||
e.Str("PayoutToBankCardDestinationData")
|
||||
e.Str("bank_card")
|
||||
{
|
||||
s := s.PayoutToBankCardDestinationData
|
||||
s := s.BankCard
|
||||
{
|
||||
e.FieldStart("card")
|
||||
s.Card.Encode(e)
|
||||
}
|
||||
}
|
||||
case PayoutToSbpDestinationDataPayoutRequestPayoutDestinationData:
|
||||
case SbpPayoutRequestPayoutDestinationData:
|
||||
e.FieldStart("type")
|
||||
e.Str("PayoutToSbpDestinationData")
|
||||
e.Str("sbp")
|
||||
{
|
||||
s := s.PayoutToSbpDestinationData
|
||||
s := s.Sbp
|
||||
{
|
||||
e.FieldStart("phone")
|
||||
e.Str(s.Phone)
|
||||
@@ -28364,14 +28491,14 @@ func (s *PayoutRequestPayoutDestinationData) Decode(d *jx.Decoder) error {
|
||||
return err
|
||||
}
|
||||
switch typ {
|
||||
case "PayoutToYooMoneyDestinationData":
|
||||
s.Type = PayoutToYooMoneyDestinationDataPayoutRequestPayoutDestinationData
|
||||
case "yoo_money":
|
||||
s.Type = YooMoneyPayoutRequestPayoutDestinationData
|
||||
found = true
|
||||
case "PayoutToBankCardDestinationData":
|
||||
s.Type = PayoutToBankCardDestinationDataPayoutRequestPayoutDestinationData
|
||||
case "bank_card":
|
||||
s.Type = BankCardPayoutRequestPayoutDestinationData
|
||||
found = true
|
||||
case "PayoutToSbpDestinationData":
|
||||
s.Type = PayoutToSbpDestinationDataPayoutRequestPayoutDestinationData
|
||||
case "sbp":
|
||||
s.Type = SbpPayoutRequestPayoutDestinationData
|
||||
found = true
|
||||
default:
|
||||
return errors.Errorf("unknown type %s", typ)
|
||||
@@ -28387,16 +28514,16 @@ func (s *PayoutRequestPayoutDestinationData) Decode(d *jx.Decoder) error {
|
||||
return errors.New("unable to detect sum type variant")
|
||||
}
|
||||
switch s.Type {
|
||||
case PayoutToYooMoneyDestinationDataPayoutRequestPayoutDestinationData:
|
||||
if err := s.PayoutToYooMoneyDestinationData.Decode(d); err != nil {
|
||||
case YooMoneyPayoutRequestPayoutDestinationData:
|
||||
if err := s.YooMoney.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
case PayoutToBankCardDestinationDataPayoutRequestPayoutDestinationData:
|
||||
if err := s.PayoutToBankCardDestinationData.Decode(d); err != nil {
|
||||
case BankCardPayoutRequestPayoutDestinationData:
|
||||
if err := s.BankCard.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
case PayoutToSbpDestinationDataPayoutRequestPayoutDestinationData:
|
||||
if err := s.PayoutToSbpDestinationData.Decode(d); err != nil {
|
||||
case SbpPayoutRequestPayoutDestinationData:
|
||||
if err := s.Sbp.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
@@ -28729,115 +28856,6 @@ func (s *PayoutStatus) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *PayoutToBankCardDestinationData) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *PayoutToBankCardDestinationData) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("card")
|
||||
s.Card.Encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfPayoutToBankCardDestinationData = [2]string{
|
||||
0: "type",
|
||||
1: "card",
|
||||
}
|
||||
|
||||
// Decode decodes PayoutToBankCardDestinationData from json.
|
||||
func (s *PayoutToBankCardDestinationData) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode PayoutToBankCardDestinationData to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "card":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
if err := s.Card.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"card\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode PayoutToBankCardDestinationData")
|
||||
}
|
||||
// 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(jsonFieldsNameOfPayoutToBankCardDestinationData) {
|
||||
name = jsonFieldsNameOfPayoutToBankCardDestinationData[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 *PayoutToBankCardDestinationData) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *PayoutToBankCardDestinationData) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *PayoutToCardDestination) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
@@ -29094,134 +29112,6 @@ func (s *PayoutToSbpDestination) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *PayoutToSbpDestinationData) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *PayoutToSbpDestinationData) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("phone")
|
||||
e.Str(s.Phone)
|
||||
}
|
||||
{
|
||||
e.FieldStart("bank_id")
|
||||
e.Str(s.BankID)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfPayoutToSbpDestinationData = [3]string{
|
||||
0: "type",
|
||||
1: "phone",
|
||||
2: "bank_id",
|
||||
}
|
||||
|
||||
// Decode decodes PayoutToSbpDestinationData from json.
|
||||
func (s *PayoutToSbpDestinationData) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode PayoutToSbpDestinationData to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "phone":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.Phone = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"phone\"")
|
||||
}
|
||||
case "bank_id":
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.BankID = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"bank_id\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode PayoutToSbpDestinationData")
|
||||
}
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00000111,
|
||||
} {
|
||||
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(jsonFieldsNameOfPayoutToSbpDestinationData) {
|
||||
name = jsonFieldsNameOfPayoutToSbpDestinationData[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 *PayoutToSbpDestinationData) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *PayoutToSbpDestinationData) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *PayoutToYooMoneyDestination) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
@@ -29331,117 +29221,6 @@ func (s *PayoutToYooMoneyDestination) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *PayoutToYooMoneyDestinationData) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *PayoutToYooMoneyDestinationData) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("account_number")
|
||||
e.Str(s.AccountNumber)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfPayoutToYooMoneyDestinationData = [2]string{
|
||||
0: "type",
|
||||
1: "account_number",
|
||||
}
|
||||
|
||||
// Decode decodes PayoutToYooMoneyDestinationData from json.
|
||||
func (s *PayoutToYooMoneyDestinationData) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode PayoutToYooMoneyDestinationData to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "account_number":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.AccountNumber = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"account_number\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode PayoutToYooMoneyDestinationData")
|
||||
}
|
||||
// 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(jsonFieldsNameOfPayoutToYooMoneyDestinationData) {
|
||||
name = jsonFieldsNameOfPayoutToYooMoneyDestinationData[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 *PayoutToYooMoneyDestinationData) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *PayoutToYooMoneyDestinationData) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes PayoutsGetInternalServerError as json.
|
||||
func (s *PayoutsGetInternalServerError) Encode(e *jx.Encoder) {
|
||||
unwrapped := (*TooManyRequests)(s)
|
||||
@@ -37969,6 +37748,134 @@ func (s *SavePaymentMethodType) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *Sbp) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *Sbp) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("phone")
|
||||
e.Str(s.Phone)
|
||||
}
|
||||
{
|
||||
e.FieldStart("bank_id")
|
||||
e.Str(s.BankID)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfSbp = [3]string{
|
||||
0: "type",
|
||||
1: "phone",
|
||||
2: "bank_id",
|
||||
}
|
||||
|
||||
// Decode decodes Sbp from json.
|
||||
func (s *Sbp) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode Sbp to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "phone":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.Phone = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"phone\"")
|
||||
}
|
||||
case "bank_id":
|
||||
requiredBitSet[0] |= 1 << 2
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.BankID = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"bank_id\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode Sbp")
|
||||
}
|
||||
// Validate required fields.
|
||||
var failures []validate.FieldError
|
||||
for i, mask := range [1]uint8{
|
||||
0b00000111,
|
||||
} {
|
||||
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(jsonFieldsNameOfSbp) {
|
||||
name = jsonFieldsNameOfSbp[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 *Sbp) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *Sbp) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes SbpBankBic as json.
|
||||
func (s SbpBankBic) Encode(e *jx.Encoder) {
|
||||
unwrapped := string(s)
|
||||
@@ -41949,6 +41856,117 @@ func (s *WebhooksWebhookIDDeleteOK) UnmarshalJSON(data []byte) error {
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode implements json.Marshaler.
|
||||
func (s *YooMoney) Encode(e *jx.Encoder) {
|
||||
e.ObjStart()
|
||||
s.encodeFields(e)
|
||||
e.ObjEnd()
|
||||
}
|
||||
|
||||
// encodeFields encodes fields.
|
||||
func (s *YooMoney) encodeFields(e *jx.Encoder) {
|
||||
{
|
||||
e.FieldStart("type")
|
||||
s.Type.Encode(e)
|
||||
}
|
||||
{
|
||||
e.FieldStart("account_number")
|
||||
e.Str(s.AccountNumber)
|
||||
}
|
||||
}
|
||||
|
||||
var jsonFieldsNameOfYooMoney = [2]string{
|
||||
0: "type",
|
||||
1: "account_number",
|
||||
}
|
||||
|
||||
// Decode decodes YooMoney from json.
|
||||
func (s *YooMoney) Decode(d *jx.Decoder) error {
|
||||
if s == nil {
|
||||
return errors.New("invalid: unable to decode YooMoney to nil")
|
||||
}
|
||||
var requiredBitSet [1]uint8
|
||||
|
||||
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
||||
switch string(k) {
|
||||
case "type":
|
||||
requiredBitSet[0] |= 1 << 0
|
||||
if err := func() error {
|
||||
if err := s.Type.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"type\"")
|
||||
}
|
||||
case "account_number":
|
||||
requiredBitSet[0] |= 1 << 1
|
||||
if err := func() error {
|
||||
v, err := d.Str()
|
||||
s.AccountNumber = string(v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return errors.Wrap(err, "decode field \"account_number\"")
|
||||
}
|
||||
default:
|
||||
return d.Skip()
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "decode YooMoney")
|
||||
}
|
||||
// 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(jsonFieldsNameOfYooMoney) {
|
||||
name = jsonFieldsNameOfYooMoney[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 *YooMoney) MarshalJSON() ([]byte, error) {
|
||||
e := jx.Encoder{}
|
||||
s.Encode(&e)
|
||||
return e.Bytes(), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements stdjson.Unmarshaler.
|
||||
func (s *YooMoney) UnmarshalJSON(data []byte) error {
|
||||
d := jx.DecodeBytes(data)
|
||||
return s.Decode(d)
|
||||
}
|
||||
|
||||
// Encode encodes YooMoneyAccountNumber as json.
|
||||
func (s YooMoneyAccountNumber) Encode(e *jx.Encoder) {
|
||||
unwrapped := string(s)
|
||||
|
||||
Reference in New Issue
Block a user