Module: Fera::API
- Defined in:
- lib/fera/api.rb,
lib/fera/api/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Api-Client' => "fera_ruby_sdk-#{ API::VERSION }", }
- VERSION =
"0.2.4"
Class Method Summary collapse
-
.configure(api_key, api_url: nil, strict_mode: false, debug_mode: false, api_type: nil) ⇒ Object, ::Fera::API
Result of the block operation if given, otherwise self.
- .debug_mode? ⇒ Boolean
- .revoke_token!(client_id:, client_secret:, auth_token:) ⇒ Object
Class Method Details
.configure(api_key, api_url: nil, strict_mode: false, debug_mode: false, api_type: nil) ⇒ Object, ::Fera::API
Returns Result of the block operation if given, otherwise self.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fera/api.rb', line 22 def self.configure(api_key, api_url: nil, strict_mode: false, debug_mode: false, api_type: nil) previous_base_site = Base.site.dup previous_base_headers = Base.headers.dup previous_debug_mode = @debug_mode api_url ||= 'https://api.fera.ai' api_type ||= api_key.include?('pk_') ? 'public' : 'private' Base.site = "#{ api_url.chomp('/') }/v3/#{ api_type }" @debug_mode = debug_mode Base.api_key = api_key Base.headers['Strict-Mode'] = strict_mode if strict_mode if block_given? begin result = yield ensure Base.site = previous_base_site Base.headers = previous_base_headers @debug_mode = previous_debug_mode end result else self end end |
.debug_mode? ⇒ Boolean
51 |
# File 'lib/fera/api.rb', line 51 def self.debug_mode?; @debug_mode; end |
.revoke_token!(client_id:, client_secret:, auth_token:) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fera/api.rb', line 57 def self.revoke_token!(client_id:, client_secret:, auth_token:) previous_site = Base.site Base.site = "https://app.fera.ai" body = { client_id: client_id, client_secret: client_secret, token: auth_token } result = Base.connection.post("https://app.fera.ai/oauth/revoke", body.to_json) Base.site = previous_site result end |