Sha256: fa7b2a3850e63c2d01471e5cff4fcb1fba71752c48d61de231df0e182fc378bf

Contents?: true

Size: 946 Bytes

Versions: 17

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

require_relative 'application_api_client'

# An usage example of the `my_api_client`.
# See also: my_api/app/controllers/status_controller.rb
class MyErrorApiClient < ApplicationApiClient
  error_handling json: { '$.error.message': /You requested error code/ },
                 raise: MyErrors::ErrorCodeOther

  error_handling json: { '$.error.code': :zero? },
                 raise: MyErrors::ErrorCode00

  error_handling json: { '$.error.code': 10 },
                 raise: MyErrors::ErrorCode10

  error_handling json: { '$.error.code': 20..29 },
                 raise: MyErrors::ErrorCode2x

  error_handling json: { '$.error.code': 30 },
                 status_code: 400,
                 raise: MyErrors::ErrorCode30

  # GET error/:code
  def get_error(code:)
    get "error/#{code}", headers: headers
  end

  private

  def headers
    { 'Content-Type': 'application/json;charset=UTF-8' }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
my_api_client-1.1.0 example/api_clients/my_error_api_client.rb
my_api_client-1.0.0 example/api_clients/my_error_api_client.rb
my_api_client-0.27.0 example/api_clients/my_error_api_client.rb
my_api_client-0.26.0 example/api_clients/my_error_api_client.rb
my_api_client-0.25.0 example/api_clients/my_error_api_client.rb
my_api_client-0.24.0 example/api_clients/my_error_api_client.rb
my_api_client-0.23.0 example/api_clients/my_error_api_client.rb
my_api_client-0.22.0 example/api_clients/my_error_api_client.rb
my_api_client-0.21.0 example/api_clients/my_error_api_client.rb
my_api_client-0.20.0 example/api_clients/my_error_api_client.rb
my_api_client-0.19.0 example/api_clients/my_error_api_client.rb
my_api_client-0.18.0 example/api_clients/my_error_api_client.rb
my_api_client-0.17.0 example/api_clients/my_error_api_client.rb
my_api_client-0.16.1 example/api_clients/my_error_api_client.rb
my_api_client-0.16.0 example/api_clients/my_error_api_client.rb
my_api_client-0.15.0 example/api_clients/my_error_api_client.rb
my_api_client-0.14.0 example/api_clients/my_error_api_client.rb