Sha256: 0e9d07c9c5eae9caab4dbbe5c66456720ca9a8305dd8a5032e90a5e7ad74e1fe

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

class Syncano
  module Resources
    # Project resource
    class Project < ::Syncano::Resources::Base
      # Association has_many :collections
      # @return [Syncano::QueryBuilder] query builder for resource Syncano::Resources::Collection
      def collections
        ::Syncano::QueryBuilder.new(client, ::Syncano::Resources::Collection, project_id: id)
      end

      # Wrapper for api "subscription.subscribe_project" method
      # @return [Syncano::Resource::Project]
      def subscribe
        perform_subscribe
        reload!
      end

      # Wrapper for api "subscription.unsubscribe_project" method
      # @return [Syncano::Resource::Project]
      def unsubscribe
        perform_unsubscribe
        reload!
      end

      private

      # Executes proper subscribe request
      # @return [Syncano::Response]
      def perform_subscribe
        check_if_sync_client!
        client.make_request(:subscription, :subscribe_project, { project_id: id })
      end

      # Executes proper unsubscribe request
      # @return [Syncano::Response]
      def perform_unsubscribe
        check_if_sync_client!
        client.make_request(:subscription, :unsubscribe_project, { project_id: id })
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
syncano-3.1.1.beta lib/syncano/resources/project.rb