Sha256: dbc761baca8a646b868c322b65df3a985bfa061eb1d6430502266ffbf806980d

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 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_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)
      Domain::ChartReport.new(body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
seatsio-26.2.0 lib/seatsio/chart_reports.rb