Sha256: 49d21ee75228db13a76ee7d328fa6a337c504339ea6fb96963c82e94eceb4fab

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Phaxio
  module Resources
    # Provides functionality for viewing port numbers.
    class PortNumber < Resource
      PORT_NUMBERS_PATH = 'port_numbers'.freeze
      private_constant :PORT_NUMBERS_PATH

      # @return [Integer] the ID associated with this number.
      # @!attribute id

      # @return [String] the E.164 number.
      # @!attribute port_number

      # @return [String] the status of this number.
      # @!attribute status
      
      has_normal_attributes %w(id port_number status)

      class << self
        # Get port number info.
        # @param id [Integer] The ID of the number to retrieve.
        # @param params [Hash]
        #   A hash of parameters to send to Phaxio. This action takes no unique parameters.
        # @return [Phaxio::Resource::PortNumber]
        # @raise [Phaxio::Error::PhaxioError]
        # @see https://www.phaxio.com/docs/api/v2/port_numbers/get_port_number
        def get id, params = {}
          response = Client.request :get, port_number_endpoint(id.to_i), params
          response_record response
        end
        alias :retrieve :get
        alias :find :get

        private

        def port_number_endpoint id
          "#{PORT_NUMBERS_PATH}/#{id}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phaxio-2.1.2 lib/phaxio/resources/port_number.rb
phaxio-2.1.1 lib/phaxio/resources/port_number.rb
phaxio-2.1.0 lib/phaxio/resources/port_number.rb