Class: Ga4Rails::RunPropertyReport
- Defined in:
- lib/ga4-rails/requests/run_property_report.rb
Overview
A class for running GA Data Api property report.
Usage: response = Ga4Rails::RunPropertyReport.new(
data_service: data_service,
property_id: property_id,
body: body
).response
Instance Attribute Summary collapse
-
#body ⇒ String
-
the report request body, example: body = { “date_ranges”: [ { “start_date”: “30daysAgo”, “end_date”: “today” } ], “metrics”: [ { name: “totalUsers” } ] }.
-
-
#data_service ⇒ Ga4Rails::AnalyticsData
-
the data service wraper to run the report.
-
-
#property_id ⇒ String
-
the GA4 roperty ID, example: ‘properties/341194148’.
-
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(data_service:, property_id:, body:) ⇒ RunPropertyReport
constructor
A new instance of RunPropertyReport.
Methods inherited from Request
Constructor Details
#initialize(data_service:, property_id:, body:) ⇒ RunPropertyReport
Returns a new instance of RunPropertyReport.
33 34 35 36 37 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 33 def initialize(data_service:, property_id:, body:) @data_service = data_service @property_id = property_id @body = body end |
Instance Attribute Details
#body ⇒ String
- the report request body, example:
body = {
"date_ranges": [
{
"start_date": "30daysAgo",
"end_date": "today"
}
],
"metrics": [
{ name: "totalUsers" }
]
}
30 31 32 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 30 def body @body end |
#data_service ⇒ Ga4Rails::AnalyticsData
- the data service wraper to run the report
30 31 32 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 30 def data_service @data_service end |
#property_id ⇒ String
- the GA4 roperty ID, example: ‘properties/341194148’
30 31 32 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 30 def property_id @property_id end |
#response ⇒ Object
Returns the value of attribute response.
31 32 33 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 31 def response @response end |
Instance Method Details
#call ⇒ Object
39 40 41 42 43 44 |
# File 'lib/ga4-rails/requests/run_property_report.rb', line 39 def call request = Google::Apis::AnalyticsdataV1beta::RunReportRequest.new(body) @response = data_service.run_property_report(property_id, request) self end |