Sha256: 81a02a6cbc55da0e615e2cdb76191236ab699e796273537c103c153cfe80df9a
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module ZohoHub class Response def initialize(params) @params = params || {} end def invalid_data? return false if data.is_a?(Array) data[:code] == 'INVALID_DATA' end # {:code=>"INVALID_TOKEN", :details=>{}, :message=>"invalid oauth token", :status=>"error"} def invalid_token? return false if data.is_a?(Array) data[:code] == 'INVALID_TOKEN' end def authentication_failure? return false if data.is_a?(Array) data[:code] == 'AUTHENTICATION_FAILURE' end def empty? @params.empty? end def data data = @params[:data] if @params.dig(:data) data ||= @params return data.first if data.is_a?(Array) && data.size == 1 data end def msg msg = data[:message] if data.dig(:details, :expected_data_type) expected = data.dig(:details, :expected_data_type) field = data.dig(:details, :api_name) msg << ", expected #{expected} for '#{field}'" end msg end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zoho_hub-0.1.6 | lib/zoho_hub/response.rb |