Sha256: d379716f9234444ea5fd6d672fc766463b7929f97d750b30f37159830c138b33
Contents?: true
Size: 927 Bytes
Versions: 1
Compression:
Stored size: 927 Bytes
Contents
module Loqate # Generic response of a request to Loqate's API class APIResult # Array of hashes representing each item in the response body # # @return [Array<Hash>] # attr_reader :items # Instantiates a new API result # # @param [Array<Hash>] items Array of hashes representing each item in the response body # def initialize(items) @items = items end def self.error(status:) new( [ { 'Error' => '-2', 'Description' => 'Something went wrong - please try again later', 'Resolution' => 'Try again later', 'Cause' => "Server returned response with #{status}" } ] ) end # Whether the response contains errors # # @return [Boolean] true if the response has errors and false otherwise # def errors? !items.dig(0, 'Error').nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
loqate-0.12.0 | lib/loqate/api_result.rb |