class NeverBounce::CLI::Script::AccountInfo

Public Instance Methods

manifest() click to toggle source

@!attribute manifest @return [Manifest]

# File lib/never_bounce/cli/script/account_info.rb, line 21
def manifest
  @manifest ||= Manifest.new(
    name: "nb-account-info",
    function: "Check account balance",
    cmdline: "[options] [VAR1=value] [VAR2=value] ...",
  )
end
request() click to toggle source

An API::Request::AccountInfo. @!attribute request @return [Object]

# File lib/never_bounce/cli/script/account_info.rb, line 11
def request
  @request ||= API::Request::AccountInfo.new({
    api_key: api_key,
  })
end
slim_main() click to toggle source

@return [Integer]

# File lib/never_bounce/cli/script/account_info.rb, line 32
def slim_main
  "Response".tap do |label|
    headings = [
      ["ExecTime", :execution_time, :right],
    ]

    table = Table.new(
      headings: headings.map { |ar| ar[0] },
      rows: [headings.map { |ar| get_table_value(response, ar) }],
    ).align!(headings)

    stdout.puts "\n#{label}:"
    stdout.puts table
  end

  "Credits".tap do |label|
    headings = [
      ["FreeRmn", :free_credits_remaining, :right],
      ["FreeUsed", :free_credits_used, :right],
      (["MonthlyUsage", :monthly_api_usage, :right] if response.credits_info.monthly?),
      (["PaidRmn", :paid_credits_remaining, :right] if response.credits_info.paid?),
      (["PaidUsed", :paid_credits_used, :right] if response.credits_info.paid?),
    ].compact

    table = Table.new(
      headings: headings.map { |ar| ar[0] },
      rows: [headings.map { |ar| get_table_value(response.credits_info, ar) }],
    ).align!(headings)

    stdout.puts "\n#{label}:"
    stdout.puts table
  end

  "JobCounts".tap do |label|
    headings = [
      ["Completed", :completed, :right],
      ["Processing", :processing, :right],
      ["Queued", :queued, :right],
      ["UnderReview", :under_review, :right],
    ]

    table = Table.new(
      headings: headings.map { |ar| ar[0] },
      rows: [headings.map { |ar| get_table_value(response.job_counts, ar) }],
    ).align!(headings)

    stdout.puts "\n#{label}:"
    stdout.puts table
  end

  0
end