Sha256: 6b647c1d1a66d5f837ac2bb88db4deb05fd6badae03c474d4da9a1ed43b57c20

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true

require 'json'

module GoogleAnalyticsV4Api
  class Property
    attr_accessor :name, :propertyType, :createTime, :updateTime, :parent, :displayName, :industryCategory, :timeZone, :currencyCode, :serviceLevel, :deleteTime, :expireTime, :account

    def initialize(client, attributes = {})
      @client = client
      attributes.each do |k, v|
        self.send("#{k}=", v)
      end
    end

    def account
      @client.account(parent)
    end

    def run_report(report)
      response = Request.post(access_token: @client.access_token, path: "/#{name}:runReport", payload: report.to_json)
      ReportResponse.new(response)
    end

    def self.parse_list(client, body)
      JSON.parse(body)["properties"].map do |attrs|
        GoogleAnalyticsV4Api::Property.new(client, attrs)
      end
    end

    def self.parse(client, body)
      GoogleAnalyticsV4Api::Property.new(client, JSON.parse(body))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
google_analytics_v4_api-0.0.6 lib/google_analytics_v4_api/property.rb
google_analytics_v4_api-0.0.5 lib/google_analytics_v4_api/property.rb
google_analytics_v4_api-0.0.4 lib/google_analytics_v4_api/property.rb
google_analytics_v4_api-0.0.3 lib/google_analytics_v4_api/property.rb