module Cryptoprocessing
Ruby module for to access Cryptoprocessing
API
Copyright 2018 OOM.AG.
Constants
- MAJOR
Current major release. @return [Integer]
- MINOR
Current minor release. @return [Integer]
- PATCH
Current patch level. @return [Integer]
- VERSION
Full release version. @return [String]
Public Class Methods
check_response_status(resp)
click to toggle source
# File lib/cryptoprocessing/client/net_response.rb, line 31 def self.check_response_status(resp) if resp.status == 200 && resp.body.kind_of?(Array) return end (resp.body['warnings'] || []).each do |warning| message = "WARNING: #{warning['message']}" message += " (#{warning['url']})" if warning["url"] $stderr.puts message end # OAuth2 errors if resp.status >= 400 && resp.body['error'] raise Cryptoprocessing::APIError, resp.body['error_description'] end # Regular errors if resp.body['errors'] case resp.status when 400 case resp.body['errors'].first['id'] when 'param_required' then raise ParamRequiredError, format_error(resp) when 'invalid_request' then raise InvalidRequestError, format_error(resp) when 'personal_details_required' then raise PersonalDetailsRequiredError, format_error(resp) end raise BadRequestError, format_error(resp) when 401 case resp.body['errors'].first['id'] when 'authentication_error' then raise AuthenticationError, format_error(resp) when 'unverified_email' then raise UnverifiedEmailError, format_error(resp) when 'invalid_token' then raise InvalidTokenError, format_error(resp) when 'revoked_token' then raise RevokedTokenError, format_error(resp) when 'expired_token' then raise ExpiredTokenError, format_error(resp) end raise AuthenticationError, format_error(resp) when 402 then raise TwoFactorRequiredError, format_error(resp) when 403 then raise InvalidScopeError, format_error(resp) when 404 then raise NotFoundError, format_error(resp) when 422 then raise ValidationError, format_error(resp) when 429 then raise RateLimitError, format_error(resp) when 500 then raise InternalServerError, format_error(resp) when 503 then raise ServiceUnavailableError, format_error(resp) end end # API errors if resp.body['status'] == 'fail' raise Cryptoprocessing::APIError, resp.body['message'] end if resp.status > 400 raise Cryptoprocessing::APIError, "[#{resp.status}] #{resp.body}" end end
client()
click to toggle source
API client based on configured options {Configurable}
@return [Cryptoprocessing::Client] API wrapper
# File lib/cryptoprocessing.rb, line 14 def client return @client if defined?(@client) && @client.same_options?(options) @client = Cryptoprocessing::Client.new(options) end
Private Class Methods
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/cryptoprocessing.rb, line 25 def method_missing(method_name, *args, &block) if client.respond_to?(method_name) return client.send(method_name, *args, &block) end super end
respond_to_missing?(method_name, include_private=false)
click to toggle source
# File lib/cryptoprocessing.rb, line 21 def respond_to_missing?(method_name, include_private=false) client.respond_to?(method_name, include_private) end