Sha256: ad63b8d0eeb3f1fe9af2a11037f414081d2b4e725c47fb29a782730deb11a533

Contents?: true

Size: 1006 Bytes

Versions: 4

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

module TwilioBase
  module Fake
    class IncomingPhoneNumber
      PhoneNumber = Struct.new(:phone_number) do
        attr_accessor :attributes

        def update(attributes)
          self.attributes = attributes
        end

        def sms_application_sid
          attributes[:sms_application_sid]
        end

        def voice_application_sid
          attributes[:voice_application_sid]
        end
      end

      cattr_accessor :phone_numbers
      self.phone_numbers = []

      def phone_numbers
        self
      end

      def create(phone_number:)
        new_phone_number = PhoneNumber.new(phone_number)
        self.class.phone_numbers << new_phone_number
        new_phone_number
      end

      def list(phone_number: nil)
        if phone_number.present?
          self.class.phone_numbers.select do |pn|
            pn.phone_number == phone_number
          end
        else
          self.class.phone_numbers
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 spec/support/twilio_base/fake/incoming_phone_number.rb
twilio_base-1.11.11 spec/support/twilio_base/fake/incoming_phone_number.rb
twilio_base-1.9.0 spec/support/twilio_base/fake/incoming_phone_number.rb
twilio_base-1.8.0 spec/support/twilio_base/fake/incoming_phone_number.rb