Class: DataDuck::Optimizely::Projects

Inherits:
OptimizelyTable show all
Defined in:
lib/integrations/optimizely/projects.rb

Instance Attribute Summary

Attributes inherited from Table

#data, #errors

Instance Method Summary collapse

Methods inherited from OptimizelyTable

#optimizely_api_token, #should_fully_reload?

Methods inherited from Table

#actions, #batch_size, #building_name, #check_table_valid!, #distribution_key, #etl!, #extract_by_clause, #extract_by_column, #extract_query, #include_with_all?, #limit_clause, #load!, #name, output, #output_column_names, #output_schema, #prefix, #recreate!, #should_fully_reload?, #show, source, #staging_name, #transform!, transforms, validates

Instance Method Details

#extract!(destination, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/integrations/optimizely/projects.rb', line 12

def extract!(destination, options = {})
  self.data = []

  now = DateTime.now
  response = Typhoeus.get("https://www.optimizelyapis.com/experiment/v1/projects", headers: {'Token' => self.optimizely_api_token})

  self.data = Oj.load(response.body)
  self.data.each do |project|
    project[:dataduck_extracted_at] = now
  end
end

#indexesObject



24
25
26
# File 'lib/integrations/optimizely/projects.rb', line 24

def indexes
  ["id", "account_id", "project_name"]
end

#parse_datetimesObject



28
29
30
31
# File 'lib/integrations/optimizely/projects.rb', line 28

def parse_datetimes
  project["created"] = DateTime.parse(project["created"])
  project["last_modified"] = DateTime.parse(project["last_modified"])
end