Class: Syncano::Resources::Collection

Inherits:
Base
  • Object
show all
Defined in:
lib/syncano/resources/collection.rb

Overview

Collection resource

Instance Attribute Summary

Attributes inherited from Base

#attributes, #destroyed, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, all, #batch, batch_create, #batch_destroy, #batch_save, #batch_update, count, create, #destroy, #destroyed?, find, #initialize, #new_record?, #reload!, #save, #saved?, #update

Constructor Details

This class inherits a constructor from Syncano::Resources::Base

Class Method Details

.find_by_key(client, key, scope_parameters = {}, conditions = {}) ⇒ Syncano::Resources::Collection

Wrapper for api “get_one” method with collection_key as a key

Parameters:

  • client (Syncano::Clients::Base)
  • key (String)
  • scope_parameters (Hash) (defaults to: {})
  • conditions (Hash) (defaults to: {})

Returns:



29
30
31
# File 'lib/syncano/resources/collection.rb', line 29

def self.find_by_key(client, key, scope_parameters = {}, conditions = {})
  perform_find(client, :key, key, scope_parameters, conditions)
end

Instance Method Details

#activate(force = false) ⇒ Syncano::Resources::Collection

Wrapper for api “activate” method

Parameters:

  • force (TrueClass, FalseClass) (defaults to: false)

Returns:



36
37
38
39
40
41
# File 'lib/syncano/resources/collection.rb', line 36

def activate(force = false)
  response = perform_activate(nil, force)
  reload! if response.status

  self
end

#add_tag(tags, weight = 1, remove_other = false) ⇒ Syncano::Resources::Collection

Wrapper for api “add_tag” method

Parameters:

  • tags (String, Array)
  • weight (Numeric) (defaults to: 1)
  • remove_other (TrueClass, FalseClass) (defaults to: false)

Returns:



72
73
74
75
76
77
# File 'lib/syncano/resources/collection.rb', line 72

def add_tag(tags, weight = 1, remove_other = false)
  response = perform_add_tag(nil, tags, weight, remove_other)
  reload! if response.status

  self
end

#authorize(api_client_id, permission) ⇒ Syncano::Resources::Base

Wrapper for api “authorize” method

Parameters:

  • api_client_id (Integer)
  • permission (String)

Returns:



125
126
127
128
# File 'lib/syncano/resources/collection.rb', line 125

def authorize(api_client_id, permission)
  perform_authorize(nil, api_client_id: api_client_id, permission: permission)
  self
end

#batch_activate(batch_client, force = false) ⇒ Syncano::Response

Batch version of “activate” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • force (TrueClass, FalseClass) (defaults to: false)

Returns:



47
48
49
# File 'lib/syncano/resources/collection.rb', line 47

def batch_activate(batch_client, force = false)
  perform_activate(batch_client, force)
end

#batch_add_tags(batch_client, tags, weight = 1, remove_other = false) ⇒ Syncano::Response

Batch version of “add_tags” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • tags (String, Array)
  • weight (Numeric) (defaults to: 1)
  • remove_other (TrueClass, FalseClass) (defaults to: false)

Returns:



85
86
87
# File 'lib/syncano/resources/collection.rb', line 85

def batch_add_tags(batch_client, tags, weight = 1, remove_other = false)
  perform_add_tag(batch_client, tags, weight, remove_other)
end

#batch_authorize(batch_client, api_client_id, permission) ⇒ Syncano::Resources::Base

Wrapper for api “authorize” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • api_client_id (Integer)
  • permission (String)

Returns:



135
136
137
138
# File 'lib/syncano/resources/collection.rb', line 135

def batch_authorize(batch_client, api_client_id, permission)
  perform_authorize(batch_client, api_client_id: api_client_id, permission: permission)
  self
end

#batch_deactivate(batch_client) ⇒ Syncano::Response

Batch version of “deactivate” method

Parameters:

  • batch_client (Jimson::BatchClient)

Returns:



63
64
65
# File 'lib/syncano/resources/collection.rb', line 63

def batch_deactivate(batch_client)
  perform_deactivate(batch_client)
end

#batch_deauthorize(batch_client, api_client_id, permission) ⇒ Syncano::Resources::Base

Wrapper for api “deauthorize” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • api_client_id (Integer)
  • permission (String)

Returns:



154
155
156
157
# File 'lib/syncano/resources/collection.rb', line 154

def batch_deauthorize(batch_client, api_client_id, permission)
  perform_deauthorize(batch_client, api_client_id: api_client_id, permission: permission)
  self
end

#batch_delete_tag(batch_client, tags) ⇒ Syncano::Response

Batch version of “delete_tag” method

Parameters:

  • batch_client (Jimson::BatchClient)
  • tags (String, Array)

Returns:



103
104
105
# File 'lib/syncano/resources/collection.rb', line 103

def batch_delete_tag(batch_client, tags)
  perform_delete_tag(batch_client, tags)
end

#data_objectsSyncano::QueryBuilder

Association has_many :data_objects

Returns:



13
14
15
# File 'lib/syncano/resources/collection.rb', line 13

def data_objects
  ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::DataObject, scope_parameters.merge(collection_id: id))
end

#deactivateSyncano::Resources::Collection

Wrapper for api “deactivate” method



53
54
55
56
57
58
# File 'lib/syncano/resources/collection.rb', line 53

def deactivate
  response = perform_deactivate(nil)
  reload! if response.status

  self
end

#deauthorize(api_client_id, permission) ⇒ Syncano::Resources::Base

Wrapper for api “deauthorize” method

Parameters:

  • api_client_id (Integer)
  • permission (String)

Returns:



144
145
146
147
# File 'lib/syncano/resources/collection.rb', line 144

def deauthorize(api_client_id, permission)
  perform_deauthorize(nil, api_client_id: api_client_id, permission: permission)
  self
end

#delete_tags(tags) ⇒ Syncano::Resources::Collection

Wrapper for api “delete_tag” method

Parameters:

  • tags (String, Array)

Returns:



92
93
94
95
96
97
# File 'lib/syncano/resources/collection.rb', line 92

def delete_tags(tags)
  response = perform_delete_tag(nil, tags)
  reload! if response.status

  self
end

#foldersSyncano::QueryBuilder

Association has_many :folders

Returns:



7
8
9
# File 'lib/syncano/resources/collection.rb', line 7

def folders
  ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::Folder, scope_parameters.merge(collection_id: id))
end

#subscribeSyncano::Resource::Collection

Wrapper for api “subscription.subscribe_collection” method

Returns:

  • (Syncano::Resource::Collection)


109
110
111
112
# File 'lib/syncano/resources/collection.rb', line 109

def subscribe
  perform_subscribe
  reload!
end

#unsubscribeSyncano::Resource::Collection

Wrapper for api “subscription.unsubscribe_collection” method

Returns:

  • (Syncano::Resource::Collection)


116
117
118
119
# File 'lib/syncano/resources/collection.rb', line 116

def unsubscribe
  perform_unsubscribe
  reload!
end

#usersSyncano::QueryBuilder

Association has_many :users

Returns:



19
20
21
# File 'lib/syncano/resources/collection.rb', line 19

def users
  ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::User, scope_parameters.merge(collection_id: id))
end