Sha256: 7f3c0f06b8bc3245f1b709ea5ad612b31de2f7842bb1836e750e1a8d3cd70ca6
Contents?: true
Size: 574 Bytes
Versions: 3
Compression:
Stored size: 574 Bytes
Contents
require 'http' module StratumnSdk ## # Wrapper around HTTP.request that parses the response and raises on error module Request def get(*args) request(:get, *args) end def post(*args) result = request(:post, *args) if result['meta'] && result['meta']['errorMessage'] raise result['meta']['errorMessage'] end result end private def request(verb, *args) result = HTTP.request(verb, *args).parse raise result['error'] if result.is_a?(Hash) && result['error'] result end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stratumn_sdk-1.0.0 | lib/stratumn_sdk/request.rb |
stratumn_sdk-0.2.0 | lib/stratumn_sdk/request.rb |
stratumn_sdk-0.1.0 | lib/stratumn_sdk/request.rb |