Sha256: 2c2edae283f3be0df3c42bce3163c73cc2944abcc0a5f198ce4318ed8e78bc15

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

require 'http'

module StratumnSdk
  module Request

    def get(*args)
      request(:get, *args)
    end

    def post(*args)
      result = request(:post, *args)

      raise result['meta']['errorMessage'] if result['meta'] && result['meta']['errorMessage']

      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

1 entries across 1 versions & 1 rubygems

Version Path
stratumn_sdk-0.0.1 lib/stratumn_sdk/request.rb