Class: Attune::Model::RankingParams

Inherits:
Object
  • Object
show all
Defined in:
lib/attune/models/ranking_params.rb

Overview

Inputs for ranking a set of ids for a particular user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ RankingParams

Returns a new instance of RankingParams.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 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

Instance Attribute Details

#anonymousString

Returns the current value of anonymous.

Returns:

  • (String)

    the current value of anonymous



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def anonymous
  @anonymous
end

#applicationString

Returns the current value of application.

Returns:

  • (String)

    the current value of application



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def application
  @application
end

#customerString

Returns the current value of customer.

Returns:

  • (String)

    the current value of customer



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def customer
  @customer
end

#entity_typeString

Returns the current value of entity_type.

Returns:

  • (String)

    the current value of entity_type



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def entity_type
  @entity_type
end

#idsArray<String>

Returns the current value of ids.

Returns:

  • (Array<String>)

    the current value of ids



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def ids
  @ids
end

#ipString

Returns the current value of ip.

Returns:

  • (String)

    the current value of ip



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def ip
  @ip
end

#quantitiesArray<Attune::Model::int>

Returns the current value of quantities.

Returns:

  • (Array<Attune::Model::int>)

    the current value of quantities



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def quantities
  @quantities
end

#scopeArray<Attune::Model::ScopeEntry>

Returns the current value of scope.

Returns:



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def scope
  @scope
end

#user_agentString

Returns the current value of user_agent.

Returns:

  • (String)

    the current value of user_agent



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def user_agent
  @user_agent
end

#viewString

Returns the current value of view.

Returns:

  • (String)

    the current value of view



15
16
17
# File 'lib/attune/models/ranking_params.rb', line 15

def view
  @view
end

Instance Method Details

#to_bodyObject



81
82
83
84
85
86
# 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 = {}) ⇒ Object



88
89
90
# File 'lib/attune/models/ranking_params.rb', line 88

def to_json(options = {})
  to_body.to_json
end