Class: Syncano::Clients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/syncano/clients/base.rb

Overview

Base class for representing clients

Direct Known Subclasses

Rest, Sync

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance_name, api_key, auth_key) ⇒ Base

Constructor for Syncano::Clients::Base object

Parameters:

  • instance_name (String)
  • api_key (String)


11
12
13
14
15
16
17
# File 'lib/syncano/clients/base.rb', line 11

def initialize(instance_name, api_key, auth_key)
  super()

  self.instance_name = instance_name
  self.api_key = api_key
  self.auth_key = auth_key if auth_key.present?
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/syncano/clients/base.rb', line 6

def api_key
  @api_key
end

#auth_keyObject

Returns the value of attribute auth_key.



6
7
8
# File 'lib/syncano/clients/base.rb', line 6

def auth_key
  @auth_key
end

#instance_nameObject

Returns the value of attribute instance_name.



6
7
8
# File 'lib/syncano/clients/base.rb', line 6

def instance_name
  @instance_name
end

Instance Method Details

#adminsSyncano::QueryBuilder

Returns query builder for Syncano::Resources::Admin objects



28
29
30
# File 'lib/syncano/clients/base.rb', line 28

def admins
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Admin)
end

#api_keysSyncano::QueryBuilder

Returns query builder for Syncano::Resources::ApiKey objects



34
35
36
# File 'lib/syncano/clients/base.rb', line 34

def api_keys
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::ApiKey)
end

#collections(project_id) ⇒ Syncano::QueryBuilder

Returns query builder for Syncano::Resources::Project objects

Parameters:

  • project_id (Integer, String)

Returns:



53
54
55
# File 'lib/syncano/clients/base.rb', line 53

def collections(project_id)
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Collection, project_id: project_id)
end

#data_objects(project_id, collection_id) ⇒ Syncano::QueryBuilder

Returns query builder for Syncano::Resources::DataObject objects

Parameters:

  • project_id (Integer, String)
  • collection_id (Integer, String)

Returns:



69
70
71
# File 'lib/syncano/clients/base.rb', line 69

def data_objects(project_id, collection_id)
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::DataObject, project_id: project_id, collection_id: collection_id)
end

#folders(project_id, collection_id) ⇒ Syncano::QueryBuilder

Returns query builder for Syncano::Resources::Folder objects

Parameters:

  • project_id (Integer, String)
  • collection_id (Integer, String)

Returns:



61
62
63
# File 'lib/syncano/clients/base.rb', line 61

def folders(project_id, collection_id)
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Collection, project_id: project_id, collection_id: collection_id)
end

#logoutTrueClass, FalseClass

Deletes saved auth_key

Returns:

  • (TrueClass, FalseClass)


21
22
23
24
# File 'lib/syncano/clients/base.rb', line 21

def logout
  self.auth_key = nil
  self.auth_key.nil?
end

#make_batch_request(batch_client, resource_name, method_name, params = {}) ⇒ Object

Performs batch request to Syncano api This should be overwritten in inherited classes

Parameters:

  • batch_client (Jimson::BatchClient)
  • resource_name (String)
  • method_name (String)
  • params (Hash) (defaults to: {})

    additional params sent in the request



97
98
# File 'lib/syncano/clients/base.rb', line 97

def make_batch_request(batch_client, resource_name, method_name, params = {})
end

#make_request(resource_name, method_name, params = {}, response_key = nil) ⇒ Syncano::Response

Performs request to Syncano api This should be overwritten in inherited classes

Parameters:

  • resource_name (String)
  • method_name (String)
  • params (Hash) (defaults to: {})

    additional params sent in the request

  • response_key (String) (defaults to: nil)

    for cases when response from api is incompatible with the convention

Returns:



88
89
# File 'lib/syncano/clients/base.rb', line 88

def make_request(resource_name, method_name, params = {}, response_key = nil)
end

#projectsSyncano::QueryBuilder

Returns query builder for Syncano::Resources::Project objects



46
47
48
# File 'lib/syncano/clients/base.rb', line 46

def projects
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Project)
end

#rolesSyncano::QueryBuilder

Returns query builder for Syncano::Resources::Role objects



40
41
42
# File 'lib/syncano/clients/base.rb', line 40

def roles
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Role)
end

#usersSyncano::QueryBuilder

Returns query builder for Syncano::Resources::User objects

Parameters:

  • project_id (Integer, String)
  • collection_id (Integer, String)

Returns:



77
78
79
# File 'lib/syncano/clients/base.rb', line 77

def users
  ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::User)
end