Class: AppnexusApi::LogLevelDataService

Inherits:
Service
  • Object
show all
Defined in:
lib/appnexusapi/log_level_data_service.rb

Constant Summary

Constants inherited from Service

Service::DEFAULT_NUMBER_OF_ELEMENTS

Instance Method Summary collapse

Methods inherited from Service

#create, #delete, #get, #get_all, #name, #parse_response, #plural_name, #plural_uri_name, #resource_class, #resource_name, #update, #uri_suffix

Constructor Details

#initialize(connection, options = {}) ⇒ LogLevelDataService

Returns a new instance of LogLevelDataService.



2
3
4
5
6
7
# File 'lib/appnexusapi/log_level_data_service.rb', line 2

def initialize(connection, options = {})
  @read_only = true
  @siphon_name = options[:siphon_name]

  super(connection)
end

Instance Method Details

#since(time = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/appnexusapi/log_level_data_service.rb', line 9

def since(time = nil)
  params = {}
  params[:siphon_name] = @siphon_name if @siphon_name
  params[:updated_since] = time.strftime('%Y_%m_%d_%H') if time

  # Anything with the same name and hour but with a newer timestamp is a republished replacement for an older file
  # When this happens appnexus is supposed to set the checksum for the old file to null but they do not always
  # actually do this.
  siphons = get(params)
  siphons.reject do |siphon|
    (siphons - [siphon]).any? { |s| s.name == siphon.name && s.hour == siphon.hour && s.timestamp > siphon.timestamp }
  end
end

#uri_nameObject



23
24
25
# File 'lib/appnexusapi/log_level_data_service.rb', line 23

def uri_name
  'siphon'
end