Class: Syncano

Inherits:
Object
  • Object
show all
Defined in:
lib/syncano.rb,
lib/syncano/errors.rb,
lib/syncano/version.rb,
lib/syncano/response.rb,
lib/syncano/batch_queue.rb,
lib/syncano/clients/base.rb,
lib/syncano/clients/rest.rb,
lib/syncano/clients/sync.rb,
lib/syncano/packets/auth.rb,
lib/syncano/packets/base.rb,
lib/syncano/packets/call.rb,
lib/syncano/packets/ping.rb,
lib/syncano/packets/error.rb,
lib/syncano/query_builder.rb,
lib/syncano/resources/base.rb,
lib/syncano/resources/role.rb,
lib/syncano/resources/user.rb,
lib/syncano/packets/message.rb,
lib/syncano/resources/admin.rb,
lib/syncano/sync_connection.rb,
lib/syncano/resources/folder.rb,
lib/syncano/resources/api_key.rb,
lib/syncano/resources/project.rb,
lib/syncano/active_record/base.rb,
lib/syncano/batch_queue_element.rb,
lib/syncano/packets/notification.rb,
lib/syncano/resources/collection.rb,
lib/syncano/packets/call_response.rb,
lib/syncano/resources/data_object.rb,
lib/syncano/resources/subscription.rb,
lib/syncano/active_record/callbacks.rb,
lib/syncano/active_record/associations.rb,
lib/syncano/active_record/scope_builder.rb,
lib/generators/syncano/install_generator.rb,
lib/syncano/resources/notifications/base.rb,
lib/syncano/active_record/association/base.rb,
lib/syncano/resources/notifications/create.rb,
lib/syncano/resources/notifications/update.rb,
lib/syncano/resources/notifications/destroy.rb,
lib/syncano/resources/notifications/message.rb,
lib/syncano/active_record/association/has_one.rb,
lib/syncano/active_record/association/has_many.rb,
lib/syncano/active_record/association/belongs_to.rb

Overview

Main class used for instantizing clients and as scope for other classes

Defined Under Namespace

Modules: ActiveRecord, Clients, Generators, Packets, Resources Classes: ApiError, BaseError, BatchQueue, BatchQueueElement, ConnectionError, QueryBuilder, Response, SyncConnection, TimeoutError

Constant Summary collapse

VERSION =

Syncano version number

'3.1.4'

Class Method Summary collapse

Class Method Details

.client(options = {}) ⇒ Syncano::Clients::Rest

Used for initializing Syncano Rest Client

Parameters:

  • options (Hash) (defaults to: {})

    with keys: instance_name, api_key which can be also provided as constants in the initializer

Returns:



8
9
10
11
12
13
# 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.(options[:username], options[:password]) if client.auth_key.nil? && options[:username].present?
  client
end

.sync_client(options = {}) ⇒ Syncano::Clients::Rest

Used for initializing Syncano Sync Client

Parameters:

  • options (Hash) (defaults to: {})

    with keys: instance_name, api_key which can be also provided as constants in the initializer

Returns:



18
19
20
21
22
23
24
# 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.(options[:username], options[:password]) if client.auth_key.nil? && options[:username].present?
  client.reconnect
  client
end