Module: Meroku::Api::Request
- Defined in:
- lib/meroku/api/request.rb
Overview
Wrapper around RestClient.post
Class Method Summary collapse
Class Method Details
.post(url, data) {|r["data"]| ... } ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/meroku/api/request.rb', line 5 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 |