Class: Wiq::Commands::PaidSessions

Inherits:
Base
  • Object
show all
Defined in:
lib/wiq/commands/paid_sessions.rb

Constant Summary collapse

PRESET_TYPES =
%w[
  registerable guest_registerable ends_in_future recurring_registerable
  recurring not_recurring not_recurring_with_archived not_archived
  dropin trial trial_or_dropin
].freeze

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wiq/commands/paid_sessions.rb', line 35

def list
  params = { "per_page" => 50 }
  params[:type] = options[:type] if options[:type]

  records, total = fetch_index("/api/v1/paid_sessions", params, key: "paid_sessions")

  if options[:season]
    year = Integer(options[:season])
    y_start = "#{year}-01-01"
    y_end = "#{year}-12-31"
    records = records.select do |ps|
      (ps["start_at"].to_s <= y_end) && ((ps["end_at"].to_s >= y_start) || ps["end_at"].nil?)
    end
  end

  render_index(
    records, total: total,
    summary: "Listed #{records.size} paid sessions#{options[:season] ? " for #{options[:season]}" : ""}.",
    breadcrumbs: [
      { "cmd" => "wiq paid_sessions show <id>", "description" => "Inspect one session" },
      { "cmd" => "wiq reports run PaidSessionAccountingReport --paid-session <id>",
        "description" => "Line-item accounting (admin only)" }
    ]
  )
end

#show(id) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/wiq/commands/paid_sessions.rb', line 68

def show(id)
  ps = client.get("/api/v1/paid_sessions/#{id}")
  render(ps,
         summary: "Paid session #{ps["id"]}#{ps["name"]}",
         breadcrumbs: [
           { "cmd" => "wiq reports run PaidSessionAccountingReport --paid-session #{ps["id"]}",
             "description" => "Line-item accounting (admin only)" },
           { "cmd" => "wiq reports run SessionRegistrationAnswerReport --paid-session #{ps["id"]}",
             "description" => "Full Q&A export" }
         ])
end