Class: Coinbase::AddressReputation

Inherits:
Object
  • Object
show all
Defined in:
lib/coinbase/address_reputation.rb

Overview

A representation of the reputation of a blockchain address.

Defined Under Namespace

Classes: Metadata

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ AddressReputation

Returns a new instance of AddressReputation.

Raises:

  • (ArgumentError)


37
38
39
40
41
# File 'lib/coinbase/address_reputation.rb', line 37

def initialize(model)
  raise ArgumentError, 'must be an AddressReputation object' unless model.is_a?(Coinbase::Client::AddressReputation)

  @model = model
end

Class Method Details

.fetch(address_id:, network: Coinbase.default_network) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/coinbase/address_reputation.rb', line 20

def fetch(address_id:, network: Coinbase.default_network)
  network = Coinbase::Network.from_id(network)

  model = Coinbase.call_api do
    reputation_api.get_address_reputation(network.normalized_id, address_id)
  end

  new(model)
end

Instance Method Details

#inspectObject



63
64
65
# File 'lib/coinbase/address_reputation.rb', line 63

def inspect
  to_s
end

#metadataObject



47
48
49
# File 'lib/coinbase/address_reputation.rb', line 47

def 
  @metadata ||= Metadata.new(**@model.)
end

#risky?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/coinbase/address_reputation.rb', line 51

def risky?
  score.negative?
end

#scoreObject



43
44
45
# File 'lib/coinbase/address_reputation.rb', line 43

def score
  @model.score
end

#to_sObject



55
56
57
58
59
60
61
# File 'lib/coinbase/address_reputation.rb', line 55

def to_s
  Coinbase.pretty_print_object(
    self.class,
    score: score,
    **.to_h
  )
end