Sha256: e1878ba00ed8e7f678830de366fe3e12673524addbf63ba76a37ff2bdbdc9248

Contents?: true

Size: 566 Bytes

Versions: 12

Compression:

Stored size: 566 Bytes

Contents

module Meroku
  module Api
    # Wrapper around RestClient.post
    module Request
      def self.post(url, data)
        response = RestClient.post(url, data.to_json,
                                   timeout: 1,
                                   content_type: :json,
                                   accept: :json)
        r = JSON.parse(response)
        yield(r["data"]) if r.key?("data")
        return unless r.key?("errors") && r["errors"].size.positive?
        puts "error: #{r['errors'].map { |x| x['detail'] }.join('. ')}"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meroku-2.0.22 lib/meroku/api/request.rb
meroku-2.0.21 lib/meroku/api/request.rb
meroku-2.0.20 lib/meroku/api/request.rb
meroku-2.0.19 lib/meroku/api/request.rb
meroku-2.0.18 lib/meroku/api/request.rb
meroku-2.0.17 lib/meroku/api/request.rb
meroku-2.0.16 lib/meroku/api/request.rb
meroku-2.0.14 lib/meroku/api/request.rb
meroku-2.0.13 lib/meroku/api/request.rb
meroku-2.0.11 lib/meroku/api/request.rb
meroku-2.0.10 lib/meroku/api/request.rb
meroku-2.0.9 lib/meroku/api/request.rb