Class: GeneratorLabs::CertErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/generatorlabs/cert.rb

Overview

Certificate error retrieval

Instance Method Summary collapse

Constructor Details

#initialize(handler) ⇒ CertErrors

Returns a new instance of CertErrors.



40
41
42
# File 'lib/generatorlabs/cert.rb', line 40

def initialize(handler)
  @handler = handler
end

Instance Method Details

#get(params = {}) ⇒ Hash

Get certificate errors

Parameters:

  • params (nil, Hash) (defaults to: {})

    Optional parameters

Returns:

  • (Hash)

    Error data



47
48
49
# File 'lib/generatorlabs/cert.rb', line 47

def get(params = {})
  @handler.get('cert/errors', params)
end

#get_all(params = {}) ⇒ Array

Get all errors with automatic pagination

Parameters:

  • params (Hash) (defaults to: {})

    Optional parameters (e.g., page_size)

Returns:

  • (Array)

    All errors across all pages



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/generatorlabs/cert.rb', line 54

def get_all(params = {})
  all_items = []
  page = 1
  params = params.dup

  loop do
    params[:page] = page
    response = get(params)
    errors = response['errors'] || []

    all_items.concat(errors)

    break unless page < (response['total_pages'] || 1) && !errors.empty?

    page += 1
  end

  all_items
end