class Syncano
Main class used for instantizing clients and as scope for other classes
Constants
- VERSION
Syncano
version number
Public Class Methods
client(options = {})
click to toggle source
Used for initializing Syncano
Rest Client @param [Hash] options with keys: instance_name, api_key which can be also provided as constants in the initializer @return [Syncano::Clients::Rest] Syncano
client.
# File lib/syncano.rb, line 8 def self.client(options = {}) auth_data = self.auth_data(options) client = Syncano::Clients::Rest.new(auth_data[:instance_name], auth_data[:api_key], auth_data[:auth_key]) client.login(options[:username], options[:password]) if client.auth_key.nil? && options[:username].present? client end
sync_client(options = {})
click to toggle source
Used for initializing Syncano
Sync Client @param [Hash] options with keys: instance_name, api_key which can be also provided as constants in the initializer @return [Syncano::Clients::Rest] Syncano
client.
# File lib/syncano.rb, line 18 def self.sync_client(options = {}) auth_data = self.auth_data(options) client = Syncano::Clients::Sync.instance(auth_data[:instance_name], auth_data[:api_key], auth_data[:auth_key]) client.login(options[:username], options[:password]) if client.auth_key.nil? && options[:username].present? client.reconnect client end
Private Class Methods
auth_data(options = {})
click to toggle source
Prepares hash with auth data from options or constants in initializer @param [Hash] options with keys: instance_name, api_key which can be also provided as constants in the initializer @return [Hash]
# File lib/syncano.rb, line 31 def self.auth_data(options = {}) instance_name = options[:instance_name] || ::SYNCANO_INSTANCE_NAME raise 'Syncano instance name cannot be blank!' if instance_name.nil? api_key = options[:api_key] || ::SYNCANO_API_KEY raise 'Syncano api key cannot be blank!' if api_key.nil? { instance_name: instance_name, api_key: api_key, auth_key: options[:auth_key] } end