Sha256: fe8cfc1d862aae15b2acb44b6c8ffae96893a7c65090550ede1c8f474cf53061

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

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

module Seatsio
  class ChartReportsClient
    def initialize(secret_key, workspace_key, base_url)
      @http_client = ::Seatsio::HttpClient.new(secret_key, workspace_key, base_url)
    end

    def by_label(chart_key, book_whole_tables = nil)
      get_chart_report('byLabel', chart_key, book_whole_tables)
    end

    def by_object_type(chart_key, book_whole_tables = nil)
      get_chart_report('byObjectType', chart_key, book_whole_tables)
    end

    def by_category_key(chart_key, book_whole_tables = nil)
      get_chart_report('byCategoryKey', chart_key, book_whole_tables)
    end

    def by_category_label(chart_key, book_whole_tables = nil)
      get_chart_report('byCategoryLabel', chart_key, book_whole_tables)
    end

    private

    def get_chart_report(report_type, chart_key, book_whole_tables)
      params = book_whole_tables.nil? ? {} : { bookWholeTables: book_whole_tables }
      url = "reports/charts/#{chart_key}/#{report_type}"
      body = @http_client.get(url, params)
      ChartReport.new(body)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seatsio-32.5.0 lib/seatsio/chart_reports.rb
seatsio-32.2.0 lib/seatsio/chart_reports.rb
seatsio-32.1.0 lib/seatsio/chart_reports.rb