Sha256: 2f12604e95e8c378ce6cda0686d26f4975d9f982e720109eb4ef16bf19a0498f

Contents?: true

Size: 1.34 KB

Versions: 48

Compression:

Stored size: 1.34 KB

Contents

module PortaText
  module Command
    module Api
      # The dids/search endpoint.
      # https://github.com/PortaText/docs/wiki/REST-API#api_dids_search
      #
      # Author::    Marcelo Gornstein (mailto:marcelog@portatext.com)
      # Copyright:: Copyright (c) 2015 PortaText
      # License::   Apache-2.0
      class DidSearch < Base
        def for_country(iso_code)
          set :country, iso_code
        end

        def toll_free
          type 'toll_free'
        end

        def local
          type 'local'
        end

        def national
          type 'national'
        end

        def mobile
          type 'mobile'
        end

        def page(page)
          set :page, page
        end

        def starts_with(pattern)
          with_pattern 'starts_with', pattern
        end

        def ends_with(pattern)
          with_pattern 'ends_with', pattern
        end

        def contains(pattern)
          with_pattern 'anywhere', pattern
        end

        def body(_method)
          ''
        end

        def endpoint(_method)
          qs = URI.encode_www_form @args
          "dids/search?#{qs}"
        end

        private

        def type(type)
          set :type, type
        end

        def with_pattern(type, pattern)
          set :where_pattern, type
          set :pattern, pattern
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
portatext-1.6.1 lib/portatext/command/api/did_search.rb
portatext-1.6.0 lib/portatext/command/api/did_search.rb
portatext-1.5.23 lib/portatext/command/api/did_search.rb
portatext-1.5.22 lib/portatext/command/api/did_search.rb
portatext-1.5.21 lib/portatext/command/api/did_search.rb
portatext-1.5.20 lib/portatext/command/api/did_search.rb
portatext-1.5.19 lib/portatext/command/api/did_search.rb
portatext-1.5.18 lib/portatext/command/api/did_search.rb
portatext-1.5.17 lib/portatext/command/api/did_search.rb
portatext-1.5.16 lib/portatext/command/api/did_search.rb
portatext-1.5.15 lib/portatext/command/api/did_search.rb
portatext-1.5.14 lib/portatext/command/api/did_search.rb
portatext-1.5.13 lib/portatext/command/api/did_search.rb
portatext-1.5.12 lib/portatext/command/api/did_search.rb
portatext-1.5.11 lib/portatext/command/api/did_search.rb
portatext-1.5.10 lib/portatext/command/api/did_search.rb
portatext-1.5.9 lib/portatext/command/api/did_search.rb
portatext-1.5.8 lib/portatext/command/api/did_search.rb
portatext-1.5.7 lib/portatext/command/api/did_search.rb
portatext-1.5.6 lib/portatext/command/api/did_search.rb