Sha256: 22187870b8b98337049ff21da950a196d7f36994e5b850a68574294cddcc162e

Contents?: true

Size: 921 Bytes

Versions: 14

Compression:

Stored size: 921 Bytes

Contents

require 'seatsio/exception'
require 'seatsio/httpClient'
require 'seatsio/domain'
require 'json'
require 'cgi'

module Seatsio
  class UsageReportsClient
    def initialize(http_client)
      @http_client = http_client
    end

    def summary_for_all_months
      url = "reports/usage"
      body = @http_client.get(url)
      UsageSummaryForAllMonths.new(body)
    end

    def details_for_month(month)
      url = "reports/usage/month/" + month.serialize
      body = @http_client.get(url)
      body.map { |item| UsageDetails.new(item) }
    end

    def details_for_event_in_month(eventId, month)
      url = "reports/usage/month/" + month.serialize + "/event/" + eventId.to_s
      body = @http_client.get(url)
      if body.empty? or !body[0].key?('usageByReason')
        body.map { |item| UsageForObjectV1.new(item) }
      else
        body.map { |item| UsageForObjectV2.new(item) }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
seatsio-46.4.0 lib/seatsio/usage_reports.rb
seatsio-46.3.0 lib/seatsio/usage_reports.rb
seatsio-46.2.0 lib/seatsio/usage_reports.rb
seatsio-46.1.0 lib/seatsio/usage_reports.rb
seatsio-46.0.0 lib/seatsio/usage_reports.rb
seatsio-45.2.0 lib/seatsio/usage_reports.rb
seatsio-45.1.0 lib/seatsio/usage_reports.rb
seatsio-45.0.0 lib/seatsio/usage_reports.rb
seatsio-44.2.0 lib/seatsio/usage_reports.rb
seatsio-44.1.0 lib/seatsio/usage_reports.rb
seatsio-44.0.0 lib/seatsio/usage_reports.rb
seatsio-43.3.0 lib/seatsio/usage_reports.rb
seatsio-43.2.0 lib/seatsio/usage_reports.rb
seatsio-43.1.0 lib/seatsio/usage_reports.rb