Class: ITCAutoingest::ITCAutoingest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/itc_autoingest.rb

Constant Summary collapse

REPORT_TYPES =
['Sales']
REPORT_SUB_TYPES =
['Summary', 'Opt-In']
REPORT_TIMEFRAME =
['Daily', 'Weekly']

Instance Method Summary collapse

Constructor Details

#initialize(username, password, vndnumber) ⇒ ITCAutoingest

Returns a new instance of ITCAutoingest.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/itc_autoingest.rb', line 17

def initialize(username, password, vndnumber)
  @auth = {:USERNAME => username, :PASSWORD => password, :VNDNUMBER => vndnumber }

  REPORT_TIMEFRAME.each { |timeframe|
    REPORT_TYPES.each { |report_type|
      REPORT_SUB_TYPES.each { |report_sub_type|
        (class << self; self; end).class_eval {
          define_method("#{timeframe.downcase}_#{report_type.downcase}_#{report_sub_type.sub('-', '').downcase}_report") { |*args|
            reportdate = (args.length == 0 ? (Time.now - 86400).strftime('%Y%m%d') : args[0])
            self.send('ingest', report_type, timeframe, report_sub_type, reportdate, :report)
          }
          define_method("#{timeframe.downcase}_#{report_type.downcase}_#{report_sub_type.sub('-', '').downcase}_raw") { |*args|
            reportdate = (args.length == 0 ? (Time.now - 86400).strftime('%Y%m%d') : args[0])
            self.send('ingest', report_type, timeframe, report_sub_type, reportdate, :raw)
          }
        }
      }
    }
  }
end