Class: SelectPdf::UsageClient

Inherits:
ApiClient show all
Defined in:
lib/selectpdf.rb

Overview

Get usage details for SelectPdf Online API.

Instance Attribute Summary

Attributes inherited from ApiClient

#api_async_endpoint, #api_endpoint, #api_web_elements_endpoint, #async_calls_max_pings, #async_calls_ping_interval, #number_of_pages

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ UsageClient

Construct the Usage client.

Parameters:

  • api_key

    API Key.


453
454
455
456
457
# File 'lib/selectpdf.rb', line 453

def initialize(api_key)
  super()
  @api_endpoint = 'https://selectpdf.com/api2/usage/'
  @parameters['key'] = api_key
end

Instance Method Details

#get_usage(get_history = false) ⇒ Object

Get API usage information with history if specified.

Parameters:

  • get_history (defaults to: false)

    Get history or not.

Returns:

  • Usage information.


463
464
465
466
467
468
469
# File 'lib/selectpdf.rb', line 463

def get_usage(get_history = false)
  @headers['Accept'] = 'text/json'
  @parameters['get_history'] = 'True' if get_history

  result = perform_post
  JSON.parse(result)
end