Sha256: fe336806a8163685ee407f321915894bbb9038d829b8efd43de2de2b08473228

Contents?: true

Size: 443 Bytes

Versions: 5

Compression:

Stored size: 443 Bytes

Contents

module SmsTraffic
  class Client
    class Reply
      attr_reader :xml, :hash

      def initialize(xml, xml_parser: SmsTraffic.configuration.xml_parser)
        @xml  = xml.gsub!(/\s+/, ' ')
        @hash = fetch_value(xml_parser.parse(xml), :reply)
      end

      private

      def fetch_value(hash, key)
        hash.fetch(key.to_s, nil) || hash.fetch(key.to_sym, nil)
      rescue NoMethodError
        nil
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sms_traffic_sdk-0.0.7 lib/sms_traffic/client/reply.rb
sms_traffic_sdk-0.0.6 lib/sms_traffic/client/reply.rb
sms_traffic_sdk-0.0.5 lib/sms_traffic/client/reply.rb
sms_traffic_sdk-0.0.4 lib/sms_traffic/client/reply.rb
sms_traffic_sdk-0.0.3 lib/sms_traffic/client/reply.rb