Sha256: 84a636c10619cd7a0f148f613303c05d3fa57a1247ff1903a204c6d8cf4e09a3

Contents?: true

Size: 720 Bytes

Versions: 6

Compression:

Stored size: 720 Bytes

Contents

module SmsBroker
  module Client
    module Response
      class NexmoError < Error
        SENDER_ID_NOT_SUPPORTED = '15'.freeze

        def initialize(nexmo_response)
          super :nexmo, nexmo_response, serialize_error_response(nexmo_response)
        end

        private

        def serialize_error_response(nexmo_response)
          errors = {}.tap do |hash|
            nexmo_response['messages'].each do |message|
              hash[message['status']] = [message['error-text']]
            end

            hash
          end

          if errors.keys.include?(SENDER_ID_NOT_SUPPORTED)
            errors['sender_id'] = ['is invalid']
          end

          errors
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sms_broker-1.0.8 lib/sms_broker/client/response/nexmo_error.rb
sms_broker-1.0.7 lib/sms_broker/client/response/nexmo_error.rb
sms_broker-1.0.5 lib/sms_broker/client/response/nexmo_error.rb
sms_broker-1.0.4 lib/sms_broker/client/response/nexmo_error.rb
sms_broker-1.0.3 lib/sms_broker/client/response/nexmo_error.rb
sms_broker-1.0.2 lib/sms_broker/client/response/nexmo_error.rb