Class: EnomAPI::SearchQuery
- Inherits:
-
Object
- Object
- EnomAPI::SearchQuery
- Defined in:
- lib/enom-api/search_query.rb
Overview
Class to define the parameters of an eNom search query
Instance Method Summary collapse
-
#initialize ⇒ SearchQuery
constructor
A new instance of SearchQuery.
-
#limit(num_or_start, num = nil) ⇒ Object
Limit the quantity of results returned.
-
#order_by(opt) ⇒ Object
Change the ordering of the query results.
-
#to_post_data ⇒ Object
POST data options.
- #where(conditions = {}) ⇒ Object
Constructor Details
#initialize ⇒ SearchQuery
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
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.
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_data ⇒ Object
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
38 39 40 41 |
# File 'lib/enom-api/search_query.rb', line 38 def where(conditions = {}) @options = conditions.merge(@options) self end |