Class: NeverBounce::CLI::Script::AccountInfo
- Inherits:
-
RequestMaker
- Object
- Base
- Meaningful
- RequestMaker
- NeverBounce::CLI::Script::AccountInfo
- Defined in:
- lib/never_bounce/cli/script/account_info.rb
Constant Summary
Constants inherited from RequestMaker
Instance Attribute Summary collapse
- #manifest ⇒ Manifest
-
#request ⇒ Object
An
API::Request::AccountInfo
.
Attributes inherited from RequestMaker
#api_key, #api_url, #request_curl, #response, #server_raw, #session, #user_config
Attributes inherited from Meaningful
#banner_text, #envar_text, #help_text, #options_text
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from RequestMaker
#get_table_value, #inil, #print_curl_request, #print_error_response, #print_server_raw, #slim_main1
Methods inherited from Meaningful
#call_slim_main, error_klasses, format_envar_examples, #handle_help_and_options, #help?, #main, #option_parser, #options
Methods inherited from Base
#env_falsey?, #env_truthy?, env_value_truthy?, #main, #system, #verbose?
Instance Attribute Details
#manifest ⇒ Manifest
21 22 23 24 25 26 27 |
# 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 ⇒ Object
An API::Request::AccountInfo
.
11 12 13 14 15 |
# File 'lib/never_bounce/cli/script/account_info.rb', line 11 def request @request ||= API::Request::AccountInfo.new({ api_key: api_key, }) end |
Instance Method Details
#slim_main ⇒ Integer
32 33 34 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# 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 |