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.



42
43
44
45
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
# File 'lib/attune/models/ranking_params.rb', line 42

def initialize(attributes = {})
  return if attributes.empty?
  # 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
  @view = attributes["view"] || attributes[:"view"]
  # 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["quantities"] || attributes[:"quantities"]
  if value.is_a?(Array)
    @quantities = value

  end
  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
  @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"]
  

end

Instance Attribute Details

#anonymousString

Returns the current value of anonymous.

Returns:

  • (String)

    the current value of anonymous



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

def anonymous
  @anonymous
end

#customerString

Returns the current value of customer.

Returns:

  • (String)

    the current value of customer



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

def customer
  @customer
end

#entity_typeString

Returns the current value of entity_type.

Returns:

  • (String)

    the current value of entity_type



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

def entity_type
  @entity_type
end

#idsArray<String>

Returns the current value of ids.

Returns:

  • (Array<String>)

    the current value of ids



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

def ids
  @ids
end

#ipString

Returns the current value of ip.

Returns:

  • (String)

    the current value of ip



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

def ip
  @ip
end

#quantitiesArray<String>

Returns the current value of quantities.

Returns:

  • (Array<String>)

    the current value of quantities



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

def quantities
  @quantities
end

#scopeArray<Attune::Model::ScopeEntry>

Returns the current value of scope.

Returns:



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

def scope
  @scope
end

#user_agentString

Returns the current value of user_agent.

Returns:

  • (String)

    the current value of user_agent



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

def user_agent
  @user_agent
end

#viewString

Returns the current value of view.

Returns:

  • (String)

    the current value of view



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

def view
  @view
end

Instance Method Details

#to_bodyObject



75
76
77
78
79
80
# File 'lib/attune/models/ranking_params.rb', line 75

def to_body
  Hash[ATTRIBUTE_MAP.map do |internal, external|
    next unless value = send(internal)
    [external, value]
  end.compact]
end

#to_json(options = {}) ⇒ Object



82
83
84
# File 'lib/attune/models/ranking_params.rb', line 82

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