Sha256: 67d5c9b62cef7d53f5596eadee2b817033fc36782ab6e04336f8b293b6278a4b

Contents?: true

Size: 867 Bytes

Versions: 6

Compression:

Stored size: 867 Bytes

Contents

module SmsBroker
  module Client
    module Response
      class TwilioSuccess < Success
        def initialize(twilio_response)
          super :twilio, twilio_response, serialize(twilio_response)
        end

        private

        def serialize(response)
          {
            to: response.to,
            from: response.from,
            message_id: response.sid,
            raw: response_to_hash(response)
          }
        end

        def response_to_hash(response)
          attributes = %i(
            to sid uri from body price status price_unit error_code
            account_sid api_version date_created error_message
            messaging_service_sid
          )

          {}.tap do |hash|
            attributes.each do |attr|
              hash[attr] = response.send(attr)
            end
          end
        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/twilio_success.rb
sms_broker-1.0.7 lib/sms_broker/client/response/twilio_success.rb
sms_broker-1.0.5 lib/sms_broker/client/response/twilio_success.rb
sms_broker-1.0.4 lib/sms_broker/client/response/twilio_success.rb
sms_broker-1.0.3 lib/sms_broker/client/response/twilio_success.rb
sms_broker-1.0.2 lib/sms_broker/client/response/twilio_success.rb