Sha256: 0f76862dfe37fcbaaf7133c6a9936d1bf48d3b0c62c91c18bda8e120dcc891a1
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
# Copyright (C) 2017 Stratumn SAS # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. require 'http' module AgentClient ## # 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stratumn_agent_client-1.0.0 | lib/agent_client/request.rb |
stratumn_agent_client-0.2.0 | lib/agent_client/request.rb |