Class: IOSTSdk::Http::GetContractStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/iost_sdk/http/get_contract_storage.rb

Instance Method Summary collapse

Instance Method Details

#invoke(base_url:, query:) ⇒ Object

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/iost_sdk/http/get_contract_storage.rb', line 9

def invoke(base_url:, query:)
  raise ArgumentError.new('query must be an instance of IOSTSdk::Models::Query::ContractStorage') unless
    query.is_a?(IOSTSdk::Models::Query::ContractStorage)

  resp = HTTParty.post(
    "#{base_url}/getContractStorage",
    body: JSON.generate(query.raw_data),
    headers: { 'Content-Type' => 'application/json' }
  )
  raise HttpRequestError.new(status_code: resp.code, body: resp.body) unless
    resp.code == 200

  { data: JSON.parse(resp.body)['data'] }
end