Class: EnomAPI::SearchQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/enom-api/search_query.rb

Overview

Class to define the parameters of an eNom search query

Instance Method Summary collapse

Constructor Details

#initializeSearchQuery

Returns a new instance of SearchQuery.



4
5
6
# File 'lib/enom-api/search_query.rb', line 4

def initialize
  @options = {'responsetype' => 'xml', 'command' => 'advanceddomainsearch'}
end

Instance Method Details

#limit(number) ⇒ Object #limit(start, number) ⇒ Object

Limit the quantity of results returned

Overloads:

  • #limit(number) ⇒ Object

    Parameters:

    • number (Integer)

      Number of records to return

  • #limit(start, number) ⇒ Object

    Parameters:

    • start (Integer)

      Start position in the results

    • number (Integer)

      Number of records to return



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/enom-api/search_query.rb', line 24

def limit(num_or_start, num = nil)
  if num.nil?
    raise ArgumentError, "invalid limit" unless num_or_start.kind_of?(Integer)
    @options['recordstoreturn'] = num_or_start
  else
    raise ArgumentError, "invalid limit start" unless num_or_start.kind_of?(Integer)
    raise ArgumentError, "invalid limit size" unless num_or_start.kind_of?(Integer)
    @options['recordstoreturn'] = num
    @options['startposition'] = num_or_start
  end
  self
end

#order_by(opt) ⇒ Object

Change the ordering of the query results.

Parameters:

  • opt (String)

    Ordering option, one of sld, tld, nsstatus, expdate, or renew

Raises:

  • (ArgumentError)


11
12
13
14
15
# File 'lib/enom-api/search_query.rb', line 11

def order_by(opt)
  raise ArgumentError, "invalid order by value" unless %w(sld tld nsstatus expdate renew).include?(opt)
  @options['orderby'] = opt
  self
end

#to_post_dataObject

Returns POST data options.

Returns:

  • POST data options



44
45
46
47
48
49
# File 'lib/enom-api/search_query.rb', line 44

def to_post_data
  if @options[:creationdate].respond_to?(:strftime)
    @options[:creationdate] = @options[:creationdate].strftime("%m/%d/%Y")
  end
  @options
end

#where(conditions = {}) ⇒ Object

Parameters:

  • conditions (Hash) (defaults to: {})

    Search conditions



38
39
40
41
# File 'lib/enom-api/search_query.rb', line 38

def where(conditions = {})
  @options = conditions.merge(@options)
  self
end