Class: Coinbase::PayloadSignature
- Inherits:
 - 
      Object
      
        
- Object
 - Coinbase::PayloadSignature
 
 
- Defined in:
 - lib/coinbase/payload_signature.rb
 
Overview
A representation of a Payload Signature.
Defined Under Namespace
Modules: Status
Class Method Summary collapse
- 
  
    
      .create(wallet_id:, address_id:, unsigned_payload:, signature: nil)  ⇒ PayloadSignature 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a new PayloadSignature object.
 - 
  
    
      .list(wallet_id:, address_id:)  ⇒ Enumerable<Coinbase::PayloadSignature> 
    
    
  
  
  
  
  
  
  
  
  
    
Enumerates the payload signatures for a given address belonging to a wallet.
 
Instance Method Summary collapse
- 
  
    
      #address_id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the Address ID of the Payload Signature.
 - 
  
    
      #id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the Payload Signature ID.
 - 
  
    
      #initialize(model)  ⇒ PayloadSignature 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Returns a new PayloadSignature object.
 - 
  
    
      #inspect  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Same as to_s.
 - 
  
    
      #reload  ⇒ PayloadSignature 
    
    
  
  
  
  
  
  
  
  
  
    
# Reload reloads the Payload Signature model with the latest version from the server side.
 - 
  
    
      #signature  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the Signature of the Payload Signature.
 - 
  
    
      #status  ⇒ Symbol 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the status of the Payload Signature.
 - 
  
    
      #terminal_state?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Returns whether the Payload Signature is in a terminal state.
 - 
  
    
      #to_s  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a String representation of the Payload Signature.
 - 
  
    
      #unsigned_payload  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the Unsigned Payload of the Payload Signature.
 - 
  
    
      #wait!(interval_seconds = 0.2, timeout_seconds = 20)  ⇒ PayloadSignature 
    
    
  
  
  
  
  
  
  
  
  
    
Waits until the Payload Signature is signed or failed by polling the server at the given interval.
 - 
  
    
      #wallet_id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the Wallet ID of the Payload Signature.
 
Constructor Details
#initialize(model) ⇒ PayloadSignature
Returns a new PayloadSignature object. Do not use this method directly. Instead use Coinbase::PayloadSignature.create.
      75 76 77 78 79  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 75 def initialize(model) raise unless model.is_a?(Coinbase::Client::PayloadSignature) @model = model end  | 
  
Class Method Details
.create(wallet_id:, address_id:, unsigned_payload:, signature: nil) ⇒ PayloadSignature
Creates a new PayloadSignature object.
      32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 32 def create(wallet_id:, address_id:, unsigned_payload:, signature: nil) create_payload_signature_request = { unsigned_payload: unsigned_payload, signature: signature }.compact model = Coinbase.call_api do addresses_api.create_payload_signature( wallet_id, address_id, create_payload_signature_request: create_payload_signature_request ) end new(model) end  | 
  
.list(wallet_id:, address_id:) ⇒ Enumerable<Coinbase::PayloadSignature>
Enumerates the payload signatures for a given address belonging to a wallet. The result is an enumerator that lazily fetches from the server, and can be iterated over, converted an array, etc…
      53 54 55 56 57 58 59  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 53 def list(wallet_id:, address_id:) Coinbase::Pagination.enumerate( ->(page) { fetch_page(wallet_id, address_id, page) } ) do |payload_signature| new(payload_signature) end end  | 
  
Instance Method Details
#address_id ⇒ String
Returns the Address ID of the Payload Signature.
      95 96 97  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 95 def address_id @model.address_id end  | 
  
#id ⇒ String
Returns the Payload Signature ID.
      83 84 85  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 83 def id @model.payload_signature_id end  | 
  
#inspect ⇒ String
Same as to_s.
      171 172 173  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 171 def inspect to_s end  | 
  
#reload ⇒ PayloadSignature
# Reload reloads the Payload Signature model with the latest version from the server side.
      125 126 127 128 129 130 131  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 125 def reload @model = Coinbase.call_api do addresses_api.get_payload_signature(wallet_id, address_id, id) end self end  | 
  
#signature ⇒ String
Returns the Signature of the Payload Signature.
      107 108 109  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 107 def signature @model.signature end  | 
  
#status ⇒ Symbol
Returns the status of the Payload Signature.
      113 114 115  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 113 def status @model.status end  | 
  
#terminal_state? ⇒ Boolean
Returns whether the Payload Signature is in a terminal state.
      119 120 121  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 119 def terminal_state? Status::TERMINAL_STATES.include?(status) end  | 
  
#to_s ⇒ String
Returns a String representation of the Payload Signature.
      157 158 159 160 161 162 163 164 165 166 167  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 157 def to_s Coinbase.pretty_print_object( self.class, id: id, wallet_id: wallet_id, address_id: address_id, status: status, unsigned_payload: unsigned_payload, signature: signature ) end  | 
  
#unsigned_payload ⇒ String
Returns the Unsigned Payload of the Payload Signature.
      101 102 103  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 101 def unsigned_payload @model.unsigned_payload end  | 
  
#wait!(interval_seconds = 0.2, timeout_seconds = 20) ⇒ PayloadSignature
Waits until the Payload Signature is signed or failed by polling the server at the given interval. Raises a Timeout::Error if the Payload Signature takes longer than the given timeout. in seconds.
      139 140 141 142 143 144 145 146 147 148 149 150 151 152 153  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 139 def wait!(interval_seconds = 0.2, timeout_seconds = 20) start_time = Time.now loop do reload return self if terminal_state? raise Timeout::Error, 'Payload Signature timed out' if Time.now - start_time > timeout_seconds self.sleep interval_seconds end self end  | 
  
#wallet_id ⇒ String
Returns the Wallet ID of the Payload Signature.
      89 90 91  | 
    
      # File 'lib/coinbase/payload_signature.rb', line 89 def wallet_id @model.wallet_id end  |