Class: Tabscanner::Credits

Inherits:
Object
  • Object
show all
Extended by:
HttpClient
Defined in:
lib/tabscanner/credits.rb

Overview

Handles credit balance retrieval from the Tabscanner API

This class manages HTTP requests to check the remaining API credits for the authenticated account.

Examples:

Check remaining credits

Credits.get_credits

Class Method Summary collapse

Methods included from HttpClient

build_connection, build_raw_response_data, handle_response_with_common_errors, log_request_response, parse_error_message

Class Method Details

.get_creditsInteger

Get remaining API credits for the authenticated account

Raises:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tabscanner/credits.rb', line 22

def self.get_credits
  config = Tabscanner.config
  config.validate!

  # Build the connection
  conn = build_connection(config, additional_headers: { 'Accept' => 'application/json' })

  # Make the GET request to credit endpoint
  response = conn.get('/api/credit')

  # Debug logging for request/response
  log_request_response('GET', '/api/credit', response, config) if config.debug?

  handle_response_with_common_errors(response) do |resp|
    parse_credits_response(resp)
  end
end