Class: MistApi::SiteEngagement

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/site_engagement.rb

Overview

Note: if hours does not exist, it’s treated as everyday of the week, 00:00-23:59. Currently, we don’t allow multiple ranges for the same day

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(dwell_tag_names = SKIP, dwell_tags = SKIP, hours = SKIP, max_dwell = 43200, min_dwell = SKIP) ⇒ SiteEngagement

Returns a new instance of SiteEngagement.



61
62
63
64
65
66
67
68
# File 'lib/mist_api/models/site_engagement.rb', line 61

def initialize(dwell_tag_names = SKIP, dwell_tags = SKIP, hours = SKIP,
               max_dwell = 43200, min_dwell = SKIP)
  @dwell_tag_names = dwell_tag_names unless dwell_tag_names == SKIP
  @dwell_tags = dwell_tags unless dwell_tags == SKIP
  @hours = hours unless hours == SKIP
  @max_dwell = max_dwell unless max_dwell == SKIP
  @min_dwell = min_dwell unless min_dwell == SKIP
end

Instance Attribute Details

#dwell_tag_namesSiteEngagementDwellTagNames

Name associated to each tag



15
16
17
# File 'lib/mist_api/models/site_engagement.rb', line 15

def dwell_tag_names
  @dwell_tag_names
end

#dwell_tagsSiteEngagementDwellTags

add tags to visits within the duration (in seconds)



19
20
21
# File 'lib/mist_api/models/site_engagement.rb', line 19

def dwell_tags
  @dwell_tags
end

#hoursHours

Days/Hours of operation filter, the available days (mon, tue, wed, thu, fri, sat, sun)

Returns:



24
25
26
# File 'lib/mist_api/models/site_engagement.rb', line 24

def hours
  @hours
end

#max_dwellInteger

Max time, default is 43200(12h), max is 68400 (18h)

Returns:

  • (Integer)


28
29
30
# File 'lib/mist_api/models/site_engagement.rb', line 28

def max_dwell
  @max_dwell
end

#min_dwellInteger

min time

Returns:

  • (Integer)


32
33
34
# File 'lib/mist_api/models/site_engagement.rb', line 32

def min_dwell
  @min_dwell
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/mist_api/models/site_engagement.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  dwell_tag_names = SiteEngagementDwellTagNames.from_hash(hash['dwell_tag_names']) if
    hash['dwell_tag_names']
  dwell_tags = SiteEngagementDwellTags.from_hash(hash['dwell_tags']) if hash['dwell_tags']
  hours = Hours.from_hash(hash['hours']) if hash['hours']
  max_dwell = hash['max_dwell'] ||= 43200
  min_dwell = hash.key?('min_dwell') ? hash['min_dwell'] : SKIP

  # Create object from extracted values.
  SiteEngagement.new(dwell_tag_names,
                     dwell_tags,
                     hours,
                     max_dwell,
                     min_dwell)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/mist_api/models/site_engagement.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dwell_tag_names'] = 'dwell_tag_names'
  @_hash['dwell_tags'] = 'dwell_tags'
  @_hash['hours'] = 'hours'
  @_hash['max_dwell'] = 'max_dwell'
  @_hash['min_dwell'] = 'min_dwell'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/mist_api/models/site_engagement.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
53
54
# File 'lib/mist_api/models/site_engagement.rb', line 46

def self.optionals
  %w[
    dwell_tag_names
    dwell_tags
    hours
    max_dwell
    min_dwell
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



98
99
100
101
102
103
# File 'lib/mist_api/models/site_engagement.rb', line 98

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} dwell_tag_names: #{@dwell_tag_names.inspect}, dwell_tags:"\
  " #{@dwell_tags.inspect}, hours: #{@hours.inspect}, max_dwell: #{@max_dwell.inspect},"\
  " min_dwell: #{@min_dwell.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



91
92
93
94
95
# File 'lib/mist_api/models/site_engagement.rb', line 91

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dwell_tag_names: #{@dwell_tag_names}, dwell_tags: #{@dwell_tags}, hours:"\
  " #{@hours}, max_dwell: #{@max_dwell}, min_dwell: #{@min_dwell}>"
end