require 'date'
module Phrase
class KeysSearchParameters
# specify the branch to use
attr_accessor :branch
# Sort by field. Can be one of: name, created_at, updated_at.
attr_accessor :sort
# Order direction. Can be one of: asc, desc.
attr_accessor :order
# Specify a query to do broad search for keys by name (including wildcards).
The following qualifiers are also supported in the search term:
ids:key_id,...
for queries on a comma-separated list of idsname:key_name
for text queries on exact key names - spaces, commas, and colons need to be escaped with double backslashestags:tag_name
to filter for keys with certain tagstranslated:{true|false}
for translation status (also requires locale_id
to be specified)updated_at:{>=|<=}2013-02-21T00:00:00Z
for date range queriesunmentioned_in_upload:upload_id
to filter keys unmentioned within uploadtags
are added to filter the search, the search will be limited to a maximum of 65,536 tagged keys.
attr_accessor :q
# Locale used to determine the translation state of a key when filtering for untranslated or translated keys.
attr_accessor :locale_id
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'branch' => :'branch',
:'sort' => :'sort',
:'order' => :'order',
:'q' => :'q',
:'locale_id' => :'locale_id'
}
end
# Attribute type mapping.
def self.openapi_types
{
:'branch' => :'String',
:'sort' => :'String',
:'order' => :'String',
:'q' => :'String',
:'locale_id' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeysSearchParameters` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeysSearchParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'branch')
self.branch = attributes[:'branch']
end
if attributes.key?(:'sort')
self.sort = attributes[:'sort']
end
if attributes.key?(:'order')
self.order = attributes[:'order']
end
if attributes.key?(:'q')
self.q = attributes[:'q']
end
if attributes.key?(:'locale_id')
self.locale_id = attributes[:'locale_id']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
true
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
branch == o.branch &&
sort == o.sort &&
order == o.order &&
q == o.q &&
locale_id == o.locale_id
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[branch, sort, order, q, locale_id].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
new.build_from_hash(attributes)
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.openapi_types.each_pair do |key, type|
if type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?