Module: ECMBlockchain::Request

Included in:
Asset, CA, Tokens
Defined in:
lib/ecm-blockchain-api/request.rb

Constant Summary collapse

HTTP_VERBS =
%i(post get delete patch)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



5
6
7
# File 'lib/ecm-blockchain-api/request.rb', line 5

def self.extended(base)
  base.include HTTParty
end

Instance Method Details

#request(method, url, data = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ecm-blockchain-api/request.rb', line 11

def request(method, url, data=nil)
  ECMBlockchain.has_api_key?
  check_http_verb(method)
  response = api_client_call(method, url, data)
  raise ECMBlockchain::Error.raise_error(response) unless response.success?
  JSON.parse(response.body, symbolize_names: true) if response.body
end