Class: Wiq::Commands::Charges

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

Constant Summary collapse

STATUS_TO_INT =

Match Charge.statuses in app/models/charge.rb. Values are integer-backed via Rails enum (‘enum status: { successful: 0, failed: 1 }`). Ransack 4.x does NOT auto-translate enum strings on integer columns, so the CLI translates here before sending q. Without this translation Ransack silently drops the predicate and returns every row — the kind of failure that’s worse than a 422.

{ "successful" => 0, "failed" => 1 }.freeze
STATUSES =
STATUS_TO_INT.keys.freeze
DEFAULT_PER_PAGE =
50

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?

Instance Method Details

#listObject



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

def list
  params = build_list_params
  records, total = fetch_index("/api/v1/charges", params, key: "charges")
  render_index(
    records, total: total,
    summary: "Listed #{records.size} charges#{summary_filters_suffix}.",
    breadcrumbs: [
      { "cmd" => "wiq billing_profiles show <id> --profile-type ParentProfile",
        "description" => "Look up the family behind a billing_profile_id" },
      { "cmd" => "wiq workflows show failed-payments-recent",
        "description" => "Canonical failed-payment cross-check workflow" }
    ]
  )
end