Sha256: 0c8f452db95d18c8f88b462a2fea0bb5548bfda1b3823aa196c7acdcbef5ed03

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

module PirschApi
  class Client
    
    BASE_URL = 'https://api.pirsch.io/api/v1'

    def initialize(client_id:, client_secret:)
      @client_id     = client_id.to_s
      @client_secret = client_secret.to_s
    end

    def valid?
      true if token rescue false
    end

    def token
      @token ||= TokenResource.new(@client_id, @client_secret).run
    end

    def domains
      DomainResource.new(client: self).run
    end

    def visitors(filters: {}, domain:)
      VisitorResource.new(client: self, filters: filters, domain: domain).run
    end

    def pages(filters: {}, domain:)
      PageResource.new(client: self, filters: filters, domain: domain).run
    end

    def referrers(filters: {}, domain:)
      ReferrerResource.new(client: self, filters: filters, domain: domain).run
    end

    def active(filters: {}, domain:)
      ActiveResource.new(client: self, filters: filters, domain: domain).run
    end

    def growth(filters: {}, domain:)
      GrowthResource.new(client: self, filters: filters, domain: domain).run
    end

    def events(filters: {}, domain:)
      EventResource.new(client: self, filters: filters, domain: domain).run
    end

    def utm_source(filters: {}, domain:)
      UtmSourceResource.new(client: self, filters: filters, domain: domain).run
    end

    def utm_medium(filters: {}, domain:)
      UtmMediumResource.new(client: self, filters: filters, domain: domain).run
    end

    def utm_campaign(filters: {}, domain:)
      UtmCampaignResource.new(client: self, filters: filters, domain: domain).run
    end

    def duration_session(filters: {}, domain:)
      DurationSessionResource.new(client: self, filters: filters, domain: domain).run
    end

    def duration_page(filters: {}, domain:)
      DurationPageResource.new(client: self, filters: filters, domain: domain).run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pirsch_api-0.0.5 lib/pirsch_api/client.rb
pirsch_api-0.0.4 lib/pirsch_api/client.rb