class Syncano::Resources::Collection

Collection resource

Public Class Methods

find_by_key(client, key, scope_parameters = {}, conditions = {}) click to toggle source

Wrapper for api “get_one” method with collection_key as a key @param [Syncano::Clients::Base] client @param [String] key @param [Hash] scope_parameters @param [Hash] conditions @return [Syncano::Resources::Collection]

# 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

Public Instance Methods

activate(force = false) click to toggle source

Wrapper for api “activate” method @param [TrueClass, FalseClass] force @return [Syncano::Resources::Collection]

# 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) click to toggle source

Wrapper for api “add_tag” method @param [String, Array] tags @param [Numeric] weight @param [TrueClass, FalseClass] remove_other @return [Syncano::Resources::Collection]

# 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) click to toggle source

Wrapper for api “authorize” method @param [Integer] api_client_id @param [String] permission @return [Syncano::Resources::Base]

# 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) click to toggle source

Batch version of “activate” method @param [Jimson::BatchClient] batch_client @param [TrueClass, FalseClass] force @return [Syncano::Response]

# 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) click to toggle source

Batch version of “add_tags” method @param [Jimson::BatchClient] batch_client @param [String, Array] tags @param [Numeric] weight @param [TrueClass, FalseClass] remove_other @return [Syncano::Response]

# 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) click to toggle source

Wrapper for api “authorize” method @param [Jimson::BatchClient] batch_client @param [Integer] api_client_id @param [String] permission @return [Syncano::Resources::Base]

# 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) click to toggle source

Batch version of “deactivate” method @param [Jimson::BatchClient] batch_client @return [Syncano::Response]

# 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) click to toggle source

Wrapper for api “deauthorize” method @param [Jimson::BatchClient] batch_client @param [Integer] api_client_id @param [String] permission @return [Syncano::Resources::Base]

# 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) click to toggle source

Batch version of “delete_tag” method @param [Jimson::BatchClient] batch_client @param [String, Array] tags @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 103
def batch_delete_tag(batch_client, tags)
  perform_delete_tag(batch_client, tags)
end
data_objects() click to toggle source

Association has_many :data_objects @return [Syncano::QueryBuilder] query builder for resource Syncano::Resources::DataObject

# 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
deactivate() click to toggle source

Wrapper for api “deactivate” method @return [Syncano::Resources::Collection]

# 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) click to toggle source

Wrapper for api “deauthorize” method @param [Integer] api_client_id @param [String] permission @return [Syncano::Resources::Base]

# 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) click to toggle source

Wrapper for api “delete_tag” method @param [String, Array] tags @return [Syncano::Resources::Collection]

# File lib/syncano/resources/collection.rb, line 92
def delete_tags(tags)
  response = perform_delete_tag(nil, tags)
  reload! if response.status

  self
end
folders() click to toggle source

Association has_many :folders @return [Syncano::QueryBuilder] query builder for resource Syncano::Resources::Folder

# File lib/syncano/resources/collection.rb, line 7
def folders
  ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::Folder, scope_parameters.merge(collection_id: id))
end
subscribe() click to toggle source

Wrapper for api “subscription.subscribe_collection” method @return [Syncano::Resource::Collection]

# File lib/syncano/resources/collection.rb, line 109
def subscribe
  perform_subscribe
  reload!
end
unsubscribe() click to toggle source

Wrapper for api “subscription.unsubscribe_collection” method @return [Syncano::Resource::Collection]

# File lib/syncano/resources/collection.rb, line 116
def unsubscribe
  perform_unsubscribe
  reload!
end
users() click to toggle source

Association has_many :users @return [Syncano::QueryBuilder] query builder for resource Syncano::Resources::User

# File lib/syncano/resources/collection.rb, line 19
def users
  ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::User, scope_parameters.merge(collection_id: id))
end

Private Instance Methods

perform_activate(batch_client, force) click to toggle source

Executes proper activate request @param [Jimson::BatchClient] batch_client @param [TrueClass, FalseClass] force @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 167
def perform_activate(batch_client, force)
  self.class.make_request(client, batch_client, :activate, scope_parameters.merge(
    self.class.primary_key_name => primary_key,
    force: force
  ))
end
perform_add_tags(batch_client, tags, weight, remove_other) click to toggle source

Executes proper add_tags request @param [Jimson::BatchClient] batch_client @param [String, Array] tags @param [Numeric] weight @param [TrueClass, FalseClass] remove_other @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 189
def perform_add_tags(batch_client, tags, weight, remove_other)
  self.class.make_request(client, batch_client, :add_tag, scope_parameters.merge(
    self.class.primary_key_name => primary_key,
    tags: tags,
    weight: weight,
    remove_other: remove_other
  ))
end
perform_authorize(batch_client, parameters) click to toggle source

Executes proper authorize request @param [Jimson::BatchClient] batch_client @param [Hash] parameters @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 227
def perform_authorize(batch_client, parameters)
  self.class.make_request(client, batch_client, :authorize, scope_parameters.merge(parameters.merge(self.class.primary_key_name.to_sym => primary_key)))
end
perform_deactivate(batch_client) click to toggle source

Executes proper deactivate request @param [Jimson::BatchClient] batch_client @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 177
def perform_deactivate(batch_client)
  self.class.make_request(client, batch_client, :deactivate, scope_parameters.merge(
    self.class.primary_key_name => primary_key
  ))
end
perform_deauthorize(batch_client, parameters) click to toggle source

Executes proper deauthorize request @param [Jimson::BatchClient] batch_client @param [Hash] parameters @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 235
def perform_deauthorize(batch_client, parameters)
  self.class.make_request(client, batch_client, :deauthorize, scope_parameters.merge(parameters.merge(self.class.primary_key_name.to_sym => primary_key)))
end
perform_delete_tags(batch_client, tags) click to toggle source

Executes proper delete_tags request @param [Jimson::BatchClient] batch_client @param [String, Array] tags @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 202
def perform_delete_tags(batch_client, tags)
  self.class.make_request(client, batch_client, :delete_tag, scope_parameters.merge(
    self.class.primary_key_name => primary_key,
    tags: tags
  ))
end
perform_subscribe() click to toggle source

Executes proper subscribe request @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 211
def perform_subscribe
  check_if_sync_client!
  client.make_request(:subscription, :subscribe_collection, scope_parameters.merge(collection_id: id))
end
perform_unsubscribe() click to toggle source

Executes proper unsubscribe request @return [Syncano::Response]

# File lib/syncano/resources/collection.rb, line 218
def perform_unsubscribe
  check_if_sync_client!
  client.make_request(:subscription, :unsubscribe_collection, scope_parameters.merge(collection_id: id))
end