Class: Blockchain::API::V2::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/blockchain/api/v2/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
# File 'lib/blockchain/api/v2/client.rb', line 9

def initialize(options = {})
  @options = options

  %i(xpub key).each do |key|
    raise ArgumentError.new("No :#{ key } given!") unless @options[key]
  end
end

Instance Method Details

#checkgap(query = {}) ⇒ Object Also known as: check_gap



25
26
27
28
# File 'lib/blockchain/api/v2/client.rb', line 25

def checkgap(query = {})
  query.merge!(@options)
  self.class.get('/receive/checkgap', query: query).parsed_response
end

#checkgap!(query = {}) ⇒ Object Also known as: check_gap!, gap

Returns an explicit Integer, just for convenience



34
35
36
# File 'lib/blockchain/api/v2/client.rb', line 34

def checkgap!(query = {})
  checkgap(query)['gap']
end

#receive(query = {}) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
# File 'lib/blockchain/api/v2/client.rb', line 17

def receive(query = {})
  query.merge!(@options)
  raise ArgumentError.new(":callback is mandatory!") unless query[:callback]
  raise ArgumentError.new(":index and :gap are mutually exclusive (remove one of them)!") if query[:index] && query[:gap]

  self.class.get('/receive', query: query).parsed_response
end