module Komoju
Constants
- SCHEMA
- VERSION
Public Class Methods
connect(api_key, options=nil)
click to toggle source
# File lib/komoju.rb, line 6 def self.connect(api_key, options=nil) options = custom_options(options) uri = URI.parse(options[:url]) uri.user = api_key uri.password = "" client = Heroics.client_from_schema(SCHEMA, uri.to_s, options) Client.new(client) end
connect_oauth(oauth_token, options=nil)
click to toggle source
Get a Client
configured to use OAuth authentication.
@param oauth_token [String] The OAuth token to use with the API. @param options [Hash<Symbol,String>] Optionally, custom settings
to use with the client. Allowed options are `default_headers`, `cache` and `url`.
@return [Client] A client configured to use the API with OAuth
authentication.
# File lib/komoju/client.rb, line 48 def self.connect_oauth(oauth_token, options=nil) options = custom_options(options) url = options[:url] client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, options) Client.new(client) end
connect_token(token, options=nil)
click to toggle source
Get a Client
configured to use Token authentication.
@param token [String] The token to use with the API. @param options [Hash<Symbol,String>] Optionally, custom settings
to use with the client. Allowed options are `default_headers`, `cache` and `url`.
@return [Client] A client configured to use the API with OAuth
authentication.
# File lib/komoju/client.rb, line 63 def self.connect_token(token, options=nil) options = custom_options(options) url = options[:url] client = Heroics.token_client_from_schema(token, SCHEMA, url, options) Client.new(client) end
Private Class Methods
custom_options(options)
click to toggle source
Get customized options.
# File lib/komoju/client.rb, line 71 def self.custom_options(options) return default_options if options.nil? final_options = default_options if options[:default_headers] final_options[:default_headers].merge!(options[:default_headers]) end final_options[:cache] = options[:cache] || Moneta.new(:Memory) final_options[:url] = options[:url] if options[:url] final_options[:user] = options[:user] if options[:user] final_options end
default_options()
click to toggle source
Get the default options.
# File lib/komoju/client.rb, line 85 def self.default_options default_headers = {} { default_headers: default_headers, url: "https://komoju.com/api/v1" } end