Sha256: 362b6acf73c4c4a09dfe6a130d297d4e9ab9ae7db1229f2f33c6c1082f510c19
Contents?: true
Size: 627 Bytes
Versions: 3
Compression:
Stored size: 627 Bytes
Contents
module MessagebirdTexter class Response class Error attr_reader :code, :description ERROR_CODES = { 2 => 'Request not allowed', 9 => 'Missing params', 10 => 'Invalid params', 20 => 'Not found', 25 => 'Not enough balance', 98 => 'API not found', 99 => 'Internal error' } def initialize(error) @errors = JSON.parse(error, symbolize_names: true)[:errors] end def errors @errors.map { |e| e.merge(error_message: ERROR_CODES[e[:code]]) } end def count @errors.count end end end end
Version data entries
3 entries across 3 versions & 1 rubygems