Class: Beaconcha::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/beaconcha/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, uri_base: nil) ⇒ Client

Returns a new instance of Client.



3
4
5
6
# File 'lib/beaconcha/client.rb', line 3

def initialize(api_key: nil, uri_base: nil)
  Beaconcha.configuration.api_key = api_key if api_key
  Beaconcha.configuration.uri_base = uri_base if uri_base
end

Class Method Details

.get(path:, query: {}) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/beaconcha/client.rb', line 40

def self.get(path:, query: {})
  HTTParty.get(
    uri(path: path),
    query: query&.compact,
    headers: headers
  )
end

.get_without_version(path:, query: {}) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/beaconcha/client.rb', line 48

def self.get_without_version(path:, query: {})
  HTTParty.get(
    uri_without_version(path: path),
    query: query&.compact,
    headers: headers
  )
end

.post(path:, parameters:) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/beaconcha/client.rb', line 56

def self.post(path:, parameters:)
  HTTParty.post(
    uri(path: path),
    headers: headers,
    body: parameters&.compact&.to_json
  )
end

Instance Method Details

#epochObject



8
9
10
# File 'lib/beaconcha/client.rb', line 8

def epoch
  @epoch ||= Beaconcha::Epoch.new
end

#eth_storeObject



28
29
30
# File 'lib/beaconcha/client.rb', line 28

def eth_store
  @eth_store ||= Beaconcha::EthStore.new
end

#executionObject



24
25
26
# File 'lib/beaconcha/client.rb', line 24

def execution
  @execution ||= Beaconcha::Execution.new
end

#miscObject



32
33
34
# File 'lib/beaconcha/client.rb', line 32

def misc
  @misc ||= Beaconcha::Misc.new
end

#rocketpoolObject



36
37
38
# File 'lib/beaconcha/client.rb', line 36

def rocketpool
  @rocketpool ||= Beaconcha::Rocketpool.new
end

#slotObject



12
13
14
# File 'lib/beaconcha/client.rb', line 12

def slot
  @slot ||= Beaconcha::Slot.new
end

#sync_committeeObject



20
21
22
# File 'lib/beaconcha/client.rb', line 20

def sync_committee
  @sync_committee ||= Beaconcha::SyncCommittee.new
end

#validatorObject



16
17
18
# File 'lib/beaconcha/client.rb', line 16

def validator
  @validator ||= Beaconcha::Validator.new
end