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