class Attune::Model::RankingParams
Inputs for ranking a set of ids for a particular user.
@attr [String] user_agent
@attr [String] ip @attr [Array<Attune::Model::ScopeEntry>] scope @attr [String] anonymous @attr [String] entity_type
@attr [Array<String>] ids @attr [String] customer @attr [Array<Attune::Model::int>] quantities @attr [String] application @attr [String] view
Constants
- ATTRIBUTE_MAP
:internal => :external
Attributes
anonymous[RW]
application[RW]
customer[RW]
entity_type[RW]
ids[RW]
ip[RW]
quantities[RW]
scope[RW]
user_agent[RW]
view[RW]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/attune/models/ranking_params.rb, line 46 def initialize(attributes = {}) return if attributes.empty? # Workaround since JSON.parse has accessors as strings rather than symbols @user_agent = attributes["userAgent"] || attributes[:"user_agent"] # Workaround since JSON.parse has accessors as strings rather than symbols @ip = attributes["ip"] || attributes[:"ip"] value = attributes["scope"] || attributes[:"scope"] if value.is_a?(Array) @scope = value.map{ |v| ScopeEntry.new(v) } end # Workaround since JSON.parse has accessors as strings rather than symbols @anonymous = attributes["anonymous"] || attributes[:"anonymous"] # Workaround since JSON.parse has accessors as strings rather than symbols @entity_type = attributes["entityType"] || attributes[:"entity_type"] value = attributes["ids"] || attributes[:"ids"] if value.is_a?(Array) @ids = value end # Workaround since JSON.parse has accessors as strings rather than symbols @customer = attributes["customer"] || attributes[:"customer"] value = attributes["quantities"] || attributes[:"quantities"] if value.is_a?(Array) @quantities = value end # Workaround since JSON.parse has accessors as strings rather than symbols @application = attributes["application"] || attributes[:"application"] # Workaround since JSON.parse has accessors as strings rather than symbols @view = attributes["view"] || attributes[:"view"] end
Public Instance Methods
to_body()
click to toggle source
# File lib/attune/models/ranking_params.rb, line 81 def to_body Hash[ATTRIBUTE_MAP.map do |internal, external| next unless value = send(internal) [external, value] end.compact] end
to_json(options = {})
click to toggle source
# File lib/attune/models/ranking_params.rb, line 88 def to_json(options = {}) to_body.to_json end