Sha256: 7f7c2a12c1a39d10ad93d21b4c11291140b08053b1e77028fd84f69cd3c7988f
Contents?: true
Size: 754 Bytes
Versions: 3
Compression:
Stored size: 754 Bytes
Contents
module Akatus class Service def send_request path = self.class::PATH method = self.class::METHOD url = Akatus.config.api_url + path + ".json" payload = self.to_payload begin if method == :post data = RestClient.post(url, payload.to_json, :content_type => :json, :accept => :json) elsif method == :get data = RestClient.get(url, { :params => payload }) else raise "Invalid method: #{method}" end JSON.parse(data)['resposta'] rescue RestClient::UnprocessableEntity => exc message = JSON.load(exc.response)['resposta']['descricao'] raise Akatus::UnprocessableEntityError.new(message) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
akatus-1.0.2 | lib/akatus/service.rb |
akatus-1.0.1 | lib/akatus/service.rb |
akatus-1.0.0 | lib/akatus/service.rb |