/// <summary>
        /// Get data by data_id or data_key. Either data_id or data_key has to be specified.
        ///<remarks>The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <remarks>User API key usage permitted. Returns Data Object if it is in a container with a read_data permission or is associated with current user and in a container with a read_own_data permission.</remarks>
        /// </summary>
        /// <param name="projectId">Project id.</param>
        /// <param name="collectionId">Collection idy defining a collection for which data will be returned.</param>
        /// <param name="collectionKey">Collection key defining a collection for which data will be returned.</param>
        /// <param name="dataId">Data Object's id.</param>
        /// <param name="dataKey">Data Object's key.</param>
        /// <param name="includeChildren">If true, include Data Object children as well (recursively). Default value: False. Max 100 of children are shown in one request.</param>
        /// <param name="depth">Max depth of children to follow. If not specified, will follow all levels until children limit is reached.</param>
        /// <param name="childrenLimit">Limit of children to show (if include_children is True). Default and max value: 100 (some children levels may be incomplete if there are more than this limit).</param>
        /// <returns>DataObject object.</returns>
        public Task <DataObject> GetOne(string projectId, string collectionId = null, string collectionKey = null,
                                        string dataId     = null, string dataKey = null, bool includeChildren = false, int?depth = null,
                                        int childrenLimit = 100)
        {
            if (projectId == null)
            {
                throw new ArgumentNullException();
            }

            if (collectionId == null && collectionKey == null)
            {
                throw new ArgumentNullException();
            }

            if (childrenLimit < 0 || childrenLimit > MaxVauluesPerRequest)
            {
                throw new ArgumentException();
            }

            return(_syncanoClient.GetAsync <DataObject>("data.get_one",
                                                        new
            {
                project_id = projectId,
                collection_id = collectionId,
                collection_key = collectionKey,
                data_id = dataId,
                data_key = dataKey,
                include_children = includeChildren,
                depth,
                children_limit = childrenLimit
            }, "data"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Logs in a user.
        /// <remarks>This method is intended for User API key usage.</remarks>
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">User's password.</param>
        /// <returns>Returns it's auth_key. Use auth_key in following requests.</returns>
        public async Task <string> Login(string userName, string password)
        {
            if (userName == null || password == null)
            {
                throw new ArgumentNullException();
            }

            var authKey = await _syncanoClient.GetAsync <string>("user.login", new { user_name = userName, password }, "auth_key");

            _syncanoClient.SetUserContext(authKey);
            return(authKey);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get one collection from a specified project.
        /// <remarks>The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <remarks>User API key usage permitted if read_data permission is added to specified collection through collection.authorize() or project.authorize().</remarks>
        /// </summary>
        /// <param name="projectId">Project id.</param>
        /// <param name="collectionId">Collection id defining collection.</param>
        /// <param name="collectionKey">Collection key defining collection.</param>
        /// <returns>Collection object.</returns>
        public Task <Collection> GetOne(string projectId, string collectionId = null, string collectionKey = null)
        {
            if (collectionId == null && collectionKey == null)
            {
                throw  new ArgumentNullException();
            }

            if (projectId == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.GetAsync <Collection>("collection.get_one",
                                                        new { project_id = projectId, collection_id = collectionId, collection_key = collectionKey }, "collection"));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get folders for a specified collection.
        /// <remarks>The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <remarks>User API key usage permitted. Returns only collections that have``read_data`` permission added through folder.authorize(), collection.authorize() or project.authorize().</remarks>
        /// </summary>
        /// <param name="projectId">Project id.</param>
        /// <param name="collectionId">Collection id defining the collection for which folders will be returned.</param>
        /// <param name="collectionKey">Collection key defining the collection for which folders will be returned.</param>
        /// <returns>List of Folder objects.</returns>
        public async Task <List <Folder> > Get(string projectId, string collectionId = null,
                                               string collectionKey = null)
        {
            if (collectionId == null && collectionKey == null)
            {
                throw new ArgumentNullException();
            }

            if (projectId == null)
            {
                throw new ArgumentNullException();
            }

            return(await _syncanoClient.GetAsync <List <Folder> >("folder.get", new { project_id = projectId, collection_id = collectionId, collection_key = collectionKey }, "folder"));
        }
 /// <summary>
 /// Lists all permission roles of current instance.
 /// </summary>
 /// <returns>List of Role objects.</returns>
 public async Task <List <Role> > GetRoles()
 {
     return(await _syncanoClient.GetAsync <List <Role> >("role.get", "role"));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Get projects
 /// </summary>
 /// <remarks>User API key usage permitted. Returns only projects that have``read_data`` permission added through project.authorize().</remarks>
 /// <returns>List of Project objects.</returns>
 public Task <List <Project> > Get()
 {
     return(_syncanoClient.GetAsync <List <Project> >("project.get", "project"));
 }