Class: DeepL::Resources::CustomTagUsageReport

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/resources/custom_tag_usage_report.rb

Overview

Custom tag usage analytics report. next_page is nil on the last page.

Instance Attribute Summary collapse

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

Constructor Details

#initialize(data, *args) ⇒ CustomTagUsageReport

rubocop:disable Metrics/AbcSize



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 46

def initialize(data, *args) # rubocop:disable Metrics/AbcSize
  super(*args)
  report = data.is_a?(Hash) ? data['custom_tag_usage_report'] : nil
  report = {} unless report.is_a?(Hash)
  @aggregate_by = report['aggregate_by'].is_a?(String) ? report['aggregate_by'] : nil
  @start_date = Utils::TimeParser.parse_optional_utc_time(report['start_date'])
  @end_date = Utils::TimeParser.parse_optional_utc_time(report['end_date'])
  @next_page = report['next_page'].is_a?(Integer) ? report['next_page'] : nil
  usages = report['usage'].is_a?(Array) ? report['usage'] : []
  @usage = usages.grep(Hash).map { |item| CustomTagUsage.new(item) }
end

Instance Attribute Details

#aggregate_by ⇒ Object (readonly)

Returns the value of attribute aggregate_by.



44
45
46
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 44

def aggregate_by
  @aggregate_by
end

#end_date ⇒ Object (readonly)

Returns the value of attribute end_date.



44
45
46
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 44

def end_date
  @end_date
end

#next_page ⇒ Object (readonly)

Returns the value of attribute next_page.



44
45
46
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 44

def next_page
  @next_page
end

#start_date ⇒ Object (readonly)

Returns the value of attribute start_date.



44
45
46
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 44

def start_date
  @start_date
end

#usage ⇒ Object (readonly)

Returns the value of attribute usage.



44
45
46
# File 'lib/deepl/resources/custom_tag_usage_report.rb', line 44

def usage
  @usage
end