Class: Ga4Rails::GetPropertyMetadata
- Defined in:
- lib/ga4-rails/requests/get_property_metadata.rb
Overview
A class for running GA Data Api property report.
Usage: metrics = Ga4Rails::GetPropertyMetadata.new(
data_service: data_service,
property_id: property_id
).metrics dimensions = Ga4Rails::GetPropertyMetadata.new(
data_service: data_service,
property_id: property_id
).dimensions
Instance Attribute Summary collapse
-
#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
- #dimensions ⇒ Object
-
#initialize(data_service:, property_id:) ⇒ GetPropertyMetadata
constructor
A new instance of GetPropertyMetadata.
- #metrics ⇒ Object
Methods inherited from Request
Constructor Details
#initialize(data_service:, property_id:) ⇒ GetPropertyMetadata
Returns a new instance of GetPropertyMetadata.
22 23 24 25 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 22 def initialize(data_service:, property_id:) @data_service = data_service @property_id = property_id end |
Instance Attribute Details
#data_service ⇒ Ga4Rails::AnalyticsData
- the data service wraper to run the report
19 20 21 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 19 def data_service @data_service end |
#property_id ⇒ String
- the GA4 roperty ID, example: ‘properties/341194148’
19 20 21 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 19 def property_id @property_id end |
#response ⇒ Object
Returns the value of attribute response.
20 21 22 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 20 def response @response end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 35 def call @response = data_service.("#{property_id}/metadata") self end |
#dimensions ⇒ Object
31 32 33 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 31 def dimensions @dimensions ||= JSON.parse(response.dimensions.to_json) end |
#metrics ⇒ Object
27 28 29 |
# File 'lib/ga4-rails/requests/get_property_metadata.rb', line 27 def metrics @metrics ||= JSON.parse(response.metrics.to_json) end |