Class: BSV::Network::Protocols::WoCREST
- Inherits:
-
BSV::Network::Protocol
- Object
- BSV::Network::Protocol
- BSV::Network::Protocols::WoCREST
- Defined in:
- lib/bsv/network/protocols/woc_rest.rb
Overview
WoCREST implements the WhatsOnChain REST API as a Protocol subclass.
Provides endpoints covering chain info, block headers, transactions, UTXOs, scripts, address queries, broadcast, search, stats, and health. Escape hatches handle WoC-specific body formats and field remapping.
Network resolution
WoC uses main and test in its URL paths. The constructor accepts symbolic aliases (:mainnet, :testnet, :stn) and resolves them to the correct string.
Usage
woc = BSV::Network::Protocols::WoCREST.new(network: :main)
result = woc.call(:get_tx, 'abc123...')
puts result.data if result.success?
Constant Summary collapse
- NETWORKS =
{ 'main' => 'main', 'test' => 'test', 'stn' => 'stn', main: 'main', test: 'test', stn: 'stn', mainnet: 'main', testnet: 'test' }.freeze
Instance Attribute Summary collapse
-
#network_name ⇒ Object
readonly
Returns the value of attribute network_name.
Attributes inherited from BSV::Network::Protocol
#api_key, #auth, #base_url, #http_client, #network
Instance Method Summary collapse
-
#initialize(base_url:, network: :main, api_key: nil, auth: nil, http_client: nil) ⇒ WoCREST
constructor
A new instance of WoCREST.
Methods inherited from BSV::Network::Protocol
#call, commands, #default_call, endpoint, endpoints, inherited, subscription, subscriptions
Constructor Details
#initialize(base_url:, network: :main, api_key: nil, auth: nil, http_client: nil) ⇒ WoCREST
Returns a new instance of WoCREST.
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/bsv/network/protocols/woc_rest.rb', line 132 def initialize(base_url:, network: :main, api_key: nil, auth: nil, http_client: nil) @network_name = resolve_network(network) # Translate legacy api_key: to auth: { api_key: } so the base class sends # the raw key without a Bearer prefix, matching WoC's expected auth format. resolved_auth = auth || (api_key ? { api_key: api_key } : nil) super( base_url: base_url, auth: resolved_auth, network: @network_name, http_client: http_client ) end |
Instance Attribute Details
#network_name ⇒ Object (readonly)
Returns the value of attribute network_name.
122 123 124 |
# File 'lib/bsv/network/protocols/woc_rest.rb', line 122 def network_name @network_name end |