コード例 #1
0
        /// <summary>
        /// Logs in the API client and returns session_id for session id or cookie-based authentication. Session is valid for 2 hours and is automatically renewed whenever it is used.
        /// <remarks>User API key usage permitted.</remarks>
        /// </summary>
        /// <param name="timeZone">Sets default timezone for all subsequent requests using returned session_id.</param>
        /// <returns>Assigned session id. This can be passed for subsequent calls as authentication.</returns>
        public async Task <string> StartSession(TimeZoneInfo timeZone = null)
        {
            var sessionId = await _syncanoClient.PostAsync <string>("apikey.start_session", new { timezone = _timeZoneConverter.GetString(timeZone) }, "session_id");

            _syncanoClient.SetSessionContext(sessionId);
            return(sessionId);
        }
コード例 #2
0
        /// <summary>
        /// Create a new project.
        /// </summary>
        /// <param name="name">New project's name.</param>
        /// <param name="description">New project's description.</param>
        /// <returns>New Project object.</returns>
        public Task <Project> New(string name, string description = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.PostAsync <Project>("project.new", new { name, description }, "project"));
        }
コード例 #3
0
        /// <summary>
        /// Create a new collection within the specified project.
        /// </summary>
        /// <param name="projectId">Project id that the collection will be created for.</param>
        /// <param name="name">New collection's name.</param>
        /// <param name="key">New collection's key.</param>
        /// <param name="description">New collection's description.</param>
        /// <returns>New Collection object.</returns>
        public Task <Collection> New(string projectId, string name, string key = null,
                                     string description = null)
        {
            if (projectId == null || name == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.PostAsync <Collection>("collection.new",
                                                         new { project_id = projectId, name, key, description }, "collection"));
        }
コード例 #4
0
        /// <summary>
        /// Creates a new user.
        /// <remarks>User API key usage permitted if add_user permission is added through apikey.authorize().</remarks>
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">User's password.</param>
        /// <param name="nick">User's nickname.</param>
        /// <param name="avatar">User's avatar in Base64 format.</param>
        /// <returns>New User object.</returns>
        public Task <User> New(string userName, string password = null, string nick = null, string avatar = null)
        {
            if (userName == null)
            {
                throw new ArgumentNullException();
            }

            return(_syncanoClient.PostAsync <User>("user.new", new
            {
                user_name = userName,
                nick,
                avatar,
                password
            }, "user"));
        }
コード例 #5
0
        /// <summary>
        /// Creates a new Data Object.
        /// <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. Requires create_data permission added through folder.authorize(), collection.authorize() or project.authorize(). user_name field is automatically filled in with current user's info.</remarks>
        /// </summary>
        /// <param name="request">Request defining new object.</param>
        /// <returns>New DataObject object.</returns>
        public Task <DataObject> New(DataObjectDefinitionRequest request)
        {
            if (request.ProjectId == null)
            {
                throw new ArgumentNullException();
            }

            if (request.CollectionId == null && request.CollectionKey == null)
            {
                throw new ArgumentNullException();
            }

            if (request.Text != null && request.Text.Length > MaxTextLenght)
            {
                throw new ArgumentException();
            }

            if (request.Title != null && request.Title.Length > MaxTitleLenght)
            {
                throw new ArgumentException();
            }

            AssertAditionals(request.Additional);

            return(_syncanoClient.PostAsync <DataObject>("data.new",
                                                         new
            {
                project_id = request.ProjectId,
                collection_id = request.CollectionId,
                collection_key = request.CollectionKey,
                data_key = request.DataKey,
                user_name = request.UserName,
                source_url = request.SourceUrl,
                title = request.Title,
                text = request.Text,
                link = request.Link,
                image = request.ImageBase64,
                image_url = request.ImageUrl,
                folder = request.Folder,
                state = request.State.ToString(),
                parent_id = request.ParentId,
                data1 = request.DataOne,
                data2 = request.DataTwo,
                data3 = request.DataThree,
                additionals = request.Additional
            }, "data"));
        }
コード例 #6
0
        /// <summary>
        /// Updates specified admin's permission role. Only administrators whose role is defined as "Admin" or "Owner" can edit their instance's administrators.
        /// </summary>
        /// <param name="roleId">New admin's instance role id to set (see role.get()).</param>
        /// <param name="adminId">The admin id to update.</param>
        /// <param name="adminEmail">The admin email to update.</param>
        /// <returns>Updated Administrator object.</returns>
        public Task <Administrator> Update(string roleId, string adminId = null, string adminEmail = null)
        {
            if (adminId == null && adminEmail == null)
            {
                throw new ArgumentNullException();
            }

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

            return(_syncanoClient.PostAsync <Administrator>("admin.update",
                                                            new { admin_id = adminId, admin_email = adminEmail, role_id = roleId }, "admin"));
        }
コード例 #7
0
        /// <summary>
        /// Create new folder within a specified collection.
        /// </summary>
        /// <remarks>The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.</remarks>
        /// <param name="projectId">Project id.</param>
        /// <param name="name">Folder name.</param>
        /// <param name="collectionId">Collection id defining collection where folder will be created.</param>
        /// <param name="collectionKey">Collection key defining collection where folder will be created.</param>
        /// <returns>New Folder object.</returns>
        public Task <Folder> New(string projectId, string name, string collectionId = null,
                                 string collectionKey = null)
        {
            if (collectionId == null && collectionKey == null)
            {
                throw new ArgumentNullException();
            }

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

            return(_syncanoClient.PostAsync <Folder>("folder.new", new { project_id = projectId, collection_id = collectionId, collection_key = collectionKey, name },
                                                     "folder"));
        }