github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/pending_airdrop_id.go (about)

     1  package hedera
     2  
     3  /*-
     4   *
     5   * Hedera Go SDK
     6   *
     7   * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
     8   *
     9   * Licensed under the Apache License, Version 2.0 (the "License");
    10   * you may not use this file except in compliance with the License.
    11   * You may obtain a copy of the License at
    12   *
    13   *      http://www.apache.org/licenses/LICENSE-2.0
    14   *
    15   * Unless required by applicable law or agreed to in writing, software
    16   * distributed under the License is distributed on an "AS IS" BASIS,
    17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    18   * See the License for the specific language governing permissions and
    19   * limitations under the License.
    20   *
    21   */
    22  
    23  import (
    24  	"fmt"
    25  
    26  	"github.com/hashgraph/hedera-protobufs-go/services"
    27  )
    28  
    29  /**
    30   * A unique, composite, identifier for a pending airdrop.
    31   *
    32   * Each pending airdrop SHALL be uniquely identified by a PendingAirdropId.
    33   * A PendingAirdropId SHALL be recorded when created and MUST be provided in any transaction
    34   * that would modify that pending airdrop (such as a `claimAirdrop` or `cancelAirdrop`).
    35   */
    36  type PendingAirdropId struct {
    37  	sender   *AccountID
    38  	receiver *AccountID
    39  	tokenID  *TokenID
    40  	nftID    *NftID
    41  }
    42  
    43  func (pendingAirdropId *PendingAirdropId) NewPendingAirdropId() *PendingAirdropId {
    44  	return &PendingAirdropId{}
    45  }
    46  
    47  // GetSender returns the AccountID of the sender
    48  func (pendingAirdropId *PendingAirdropId) GetSender() *AccountID {
    49  	return pendingAirdropId.sender
    50  }
    51  
    52  // SetSender sets the AccountID of the sender
    53  func (pendingAirdropId *PendingAirdropId) SetSender(sender AccountID) *PendingAirdropId {
    54  	pendingAirdropId.sender = &sender
    55  	return pendingAirdropId
    56  }
    57  
    58  // GetReceiver returns the AccountID of the receiver
    59  func (pendingAirdropId *PendingAirdropId) GetReceiver() *AccountID {
    60  	return pendingAirdropId.receiver
    61  }
    62  
    63  // SetReceiver sets the AccountID of the receiver
    64  func (pendingAirdropId *PendingAirdropId) SetReceiver(receiver AccountID) *PendingAirdropId {
    65  	pendingAirdropId.receiver = &receiver
    66  	return pendingAirdropId
    67  }
    68  
    69  // GetTokenID returns the TokenID of the pending airdrop
    70  func (pendingAirdropId *PendingAirdropId) GetTokenID() *TokenID {
    71  	return pendingAirdropId.tokenID
    72  }
    73  
    74  // SetTokenID sets the TokenID of the pending airdrop
    75  func (pendingAirdropId *PendingAirdropId) SetTokenID(tokenID TokenID) *PendingAirdropId {
    76  	pendingAirdropId.tokenID = &tokenID
    77  	return pendingAirdropId
    78  }
    79  
    80  // GetNftID returns the NftID of the pending airdrop
    81  func (pendingAirdropId *PendingAirdropId) GetNftID() *NftID {
    82  	return pendingAirdropId.nftID
    83  }
    84  
    85  // SetNftID sets the NftID of the pending airdrop
    86  func (pendingAirdropId *PendingAirdropId) SetNftID(nftID NftID) *PendingAirdropId {
    87  	pendingAirdropId.nftID = &nftID
    88  	return pendingAirdropId
    89  }
    90  
    91  func _PendingAirdropIdFromProtobuf(pb *services.PendingAirdropId) *PendingAirdropId {
    92  	if pb.GetFungibleTokenType() != nil {
    93  		return &PendingAirdropId{
    94  			sender:   _AccountIDFromProtobuf(pb.GetSenderId()),
    95  			receiver: _AccountIDFromProtobuf(pb.GetReceiverId()),
    96  			tokenID:  _TokenIDFromProtobuf(pb.GetFungibleTokenType()),
    97  		}
    98  	} else {
    99  		nftID := _NftIDFromProtobuf(pb.GetNonFungibleToken())
   100  		return &PendingAirdropId{
   101  			sender:   _AccountIDFromProtobuf(pb.GetSenderId()),
   102  			receiver: _AccountIDFromProtobuf(pb.GetReceiverId()),
   103  			nftID:    &nftID,
   104  		}
   105  	}
   106  }
   107  
   108  func (pendingAirdropId *PendingAirdropId) _ToProtobuf() *services.PendingAirdropId {
   109  	pb := &services.PendingAirdropId{}
   110  
   111  	if pendingAirdropId.sender != nil {
   112  		pb.SenderId = pendingAirdropId.sender._ToProtobuf()
   113  	}
   114  
   115  	if pendingAirdropId.receiver != nil {
   116  		pb.ReceiverId = pendingAirdropId.receiver._ToProtobuf()
   117  	}
   118  
   119  	if pendingAirdropId.tokenID != nil {
   120  		pb.TokenReference = &services.PendingAirdropId_FungibleTokenType{
   121  			FungibleTokenType: pendingAirdropId.tokenID._ToProtobuf(),
   122  		}
   123  	} else {
   124  		pb.TokenReference = &services.PendingAirdropId_NonFungibleToken{
   125  			NonFungibleToken: pendingAirdropId.nftID._ToProtobuf(),
   126  		}
   127  	}
   128  	return pb
   129  }
   130  
   131  func (pendingAirdropId *PendingAirdropId) String() string {
   132  	const nilString = "nil"
   133  	var senderStr, receiverStr, tokenIDStr, nftIDStr string
   134  
   135  	if pendingAirdropId.sender != nil {
   136  		senderStr = pendingAirdropId.sender.String()
   137  	} else {
   138  		senderStr = nilString
   139  	}
   140  
   141  	if pendingAirdropId.receiver != nil {
   142  		receiverStr = pendingAirdropId.receiver.String()
   143  	} else {
   144  		receiverStr = nilString
   145  	}
   146  
   147  	if pendingAirdropId.tokenID != nil {
   148  		tokenIDStr = pendingAirdropId.tokenID.String()
   149  	} else {
   150  		tokenIDStr = nilString
   151  	}
   152  
   153  	if pendingAirdropId.nftID != nil {
   154  		nftIDStr = pendingAirdropId.nftID.String()
   155  	} else {
   156  		nftIDStr = nilString
   157  	}
   158  
   159  	return fmt.Sprintf("Sender: %s, Receiver: %s, TokenID: %s, NftID: %s", senderStr, receiverStr, tokenIDStr, nftIDStr)
   160  }