Sha256: d8d72a16202c9b6c265fdee7d94e449f9458a3823f2895dda805c139bd23f979
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
require "faraday" module RiseAi class Resource def post_request(url, body:, headers: {}) handle_response(connection.post(url, body, headers)) end private def handle_response(response) error_message = response.body case response.status when 401 raise Error, "Invalid authorization credentials: #{error_message}" when 404 raise Error, "Not found: #{error_message}" when 422 raise Error, "Unprocessable entity: #{error_message}" when 406 raise Error, "Not acceptable. Missing mandatory fields: #{error_message}" when 409 raise Error, "Conflict: Only one custom trigger can be created." when 502 raise Error, "Bad gateway: Custom trigger is not enabled for this Shopify domain" when 503 raise Error, "Timed out: #{error_message}" end response end def connection @connection ||= Faraday.new do |conn| conn.request :json conn.adapter Faraday.default_adapter end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rise_ai-0.1.3 | lib/rise_ai/resource.rb |
rise_ai-0.1.2 | lib/rise_ai/resource.rb |