lib/genability/client/load_serving_entity.rb in genability-0.2.0 vs lib/genability/client/load_serving_entity.rb in genability-0.3.0
- old
+ new
@@ -15,29 +15,63 @@
#
# @format :json
# @authenticated true
# @rate_limited true
# @param options [Hash] A customizable set of options.
- # @option options [String] :search_string Phrase for searching the names of Load Serving Entities (Optional)
- # @option options [String] :starts_with Indicates the search phrase should match the start of the name. (Optional)
- # @option options [String] :ends_with Indicates the search phrase should match the end of the name. (Optional)
- # @option options [Integer] :page The page number to begin the result set from. If not specified, this will begin with the first result set. (Optional)
- # @option options [Integer] :per_page The number of results to return. If not specified, this will return 25 results. (Optional)
+ # @option options [Integer] :page The page number to begin the result
+ # set from. If not specified, this will begin with the first result
+ # set. (Optional)
+ # @option options [Integer] :per_page The number of results to return.
+ # If not specified, this will return 25 results. (Optional)
+ # @option options [String] :search The string of text to search on. This
+ # can also be a regular expression, in which case you should set the
+ # 'isRegex' flag to true. (Optional)
+ # @option options [String] :search_on Comma separated list of fields to
+ # query on. When searchOn is specified, the text provided in the search
+ # string field will be searched within these fields. The list of fields
+ # to search on depend on the entity being searched for. Read the documentation
+ # for the entity for more details on the fields that can be searched, and
+ # the default fields to be searched if searchOn is not specified. (Optional)
+ # @option options [Boolean] :starts_with When true, the search will only
+ # return results that begin with the specified search string. Otherwise,
+ # any match of the search string will be returned as a result. Default is
+ # false. (Optional)
+ # @option options [Boolean] :ends_with When true, the search will only return
+ # results that end with the specified search string. Otherwise, any match of
+ # the search string will be returned as a result. Default is false. (Optional)
+ # @option options [Boolean] :is_regex When true, the provided search string
+ # will be regarded as a regular expression and the search will return results
+ # matching the regular expression. Default is false. (Optional)
+ # @option options [String] :sort_on Comma separated list of fields to sort on.
+ # This can also be input via Array Inputs (see above). (Optional)
+ # @option options [String] :sort_order Comma separated list of ordering.
+ # Possible values are 'ASC' and 'DESC'. Default is 'ASC'. If your sortOn
+ # contains multiple fields and you would like to order fields individually,
+ # you can pass in a comma separated list here (or use Array Inputs, see above).
+ # For example, if your sortOn contained 5 fields, and your sortOrder contained
+ # 'ASC, DESC, DESC', these would be applied to the first three items in the sortOn
+ # field. The remaining two would default to ASC. (Optional)
+ # @option options [String] :account_id The unique ID of the Account for which
+ # you want to find LSEs. When passed in, the search will look for a territoryId
+ # on the Account and use that to find all LSEs that provide service within that
+ # territory. (Optional)
# @return [Array] List of load serving entities.
# @see https://developer.genability.com/documentation/api-reference/public/lse
# @example Return the first 25 load serving entities
# Genability.load_serving_entities
# @example Return the next 25 load serving entities
# Genability.load_serving_entities(:page => 2)
# @example Return only 10 load serving entities
# Genability.load_serving_entities(:per_page => 10)
# @example Search for load serving entities starting with the letters 'Ka'
- # Genability.load_serving_entities(:starts_with => 'Ka')
+ # Genability.load_serving_entities(:search => 'Ka', :starts_with => 'true')
# @example Search for load serving entities ending with the word 'Inc'
- # Genability.load_serving_entities(:ends_with => 'Inc')
+ # Genability.load_serving_entities(:search => 'Inc', :ends_with => 'true')
# @example Search for load serving entities with the word 'Energy'
- # Genability.load_serving_entities(:search_string => 'Energy')
+ # Genability.load_serving_entities(:search => 'Energy')
+ # @example Search for load serving entities with a regular expression
+ # Genability.load_serving_entities(:search => /\w{5,}/)
def load_serving_entities(options={})
get("public/lses", lses_params(options)).results
end
alias :lses :load_serving_entities
@@ -60,17 +94,13 @@
private
def lses_params(options)
{
- 'searchString' => search_string(options),
- 'startsWith' => convert_to_boolean(options[:starts_with]),
- 'endsWith' => convert_to_boolean(options[:ends_with])
- }.delete_if{ |k,v| v.nil? }.merge( pagination_params(options) )
- end
-
- def search_string(options)
- options[:search_string] || options[:contains] || options[:starts_with] || options[:ends_with]
+ 'accountId' => options[:account_id]
+ }.delete_if{ |k,v| v.nil? }.
+ merge( pagination_params(options) ).
+ merge( search_params(options) )
end
end
end
end