예제 #1
0
        /// <summary>
        /// Parameters:
        ///   user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
        ///   title (required) - string - Internal reference for key.
        ///   public_key (required) - string - Actual contents of SSH key.
        /// </summary>
        public static async Task <PublicKey> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("title") && !(parameters["title"] is string))
            {
                throw new ArgumentException("Bad parameter: title must be of type string", "parameters[\"title\"]");
            }
            if (parameters.ContainsKey("public_key") && !(parameters["public_key"] is string))
            {
                throw new ArgumentException("Bad parameter: public_key must be of type string", "parameters[\"public_key\"]");
            }
            if (!parameters.ContainsKey("title") || parameters["title"] == null)
            {
                throw new ArgumentNullException("Parameter missing: title", "parameters[\"title\"]");
            }
            if (!parameters.ContainsKey("public_key") || parameters["public_key"] == null)
            {
                throw new ArgumentNullException("Parameter missing: public_key", "parameters[\"public_key\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/public_keys", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <PublicKey>(responseJson));
        }
예제 #2
0
        /// <summary>
        /// Parameters:
        ///   cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `destination`.
        ///   mine - boolean - Only show requests of the current user?  (Defaults to true if current user is not a site admin.)
        ///   path - string - Path to show requests for.  If omitted, shows all paths. Send `/` to represent the root directory.
        /// </summary>
        public static async Task <Request[]> List(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("sort_by") && !(parameters["sort_by"] is object))
            {
                throw new ArgumentException("Bad parameter: sort_by must be of type object", "parameters[\"sort_by\"]");
            }
            if (parameters.ContainsKey("mine") && !(parameters["mine"] is bool))
            {
                throw new ArgumentException("Bad parameter: mine must be of type bool", "parameters[\"mine\"]");
            }
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/requests", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <Request[]>(responseJson));
        }
예제 #3
0
        /// <summary>
        /// Send email(s) with a link to bundle
        ///
        /// Parameters:
        ///   to - array(string) - A list of email addresses to share this bundle with. Required unless `recipients` is used.
        ///   note - string - Note to include in email.
        ///   recipients - array(object) - A list of recipients to share this bundle with. Required unless `to` is used.
        /// </summary>
        public static async Task <Bundle> Share(
            Nullable <Int64> id,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("id", id);
            if (parameters.ContainsKey("id") && !(parameters["id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: id must be of type Nullable<Int64>", "parameters[\"id\"]");
            }
            if (parameters.ContainsKey("to") && !(parameters["to"] is string[]))
            {
                throw new ArgumentException("Bad parameter: to must be of type string[]", "parameters[\"to\"]");
            }
            if (parameters.ContainsKey("note") && !(parameters["note"] is string))
            {
                throw new ArgumentException("Bad parameter: note must be of type string", "parameters[\"note\"]");
            }
            if (parameters.ContainsKey("recipients") && !(parameters["recipients"] is object[]))
            {
                throw new ArgumentException("Bad parameter: recipients must be of type object[]", "parameters[\"recipients\"]");
            }
            if (!parameters.ContainsKey("id") || parameters["id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: id", "parameters[\"id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/bundles/{Uri.EscapeDataString(parameters["id"].ToString())}/share", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <Bundle>(responseJson));
        }
예제 #4
0
        /// <summary>
        /// Parameters:
        ///   cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   folder_behavior_id - int64 - ID of the associated Inbox.
        /// </summary>
        public static async Task <InboxRegistration[]> List(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("folder_behavior_id") && !(parameters["folder_behavior_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: folder_behavior_id must be of type Nullable<Int64>", "parameters[\"folder_behavior_id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/inbox_registrations", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <InboxRegistration[]>(responseJson));
        }
예제 #5
0
        /// <summary>
        /// Parameters:
        ///   username - string - Username to sign in as
        ///   password - string - Password for sign in
        ///   otp - string - If this user has a 2FA device, provide its OTP or code here.
        ///   partial_session_id - string - Identifier for a partially-completed login
        /// </summary>
        public static async Task <Session> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("username") && !(parameters["username"] is string))
            {
                throw new ArgumentException("Bad parameter: username must be of type string", "parameters[\"username\"]");
            }
            if (parameters.ContainsKey("password") && !(parameters["password"] is string))
            {
                throw new ArgumentException("Bad parameter: password must be of type string", "parameters[\"password\"]");
            }
            if (parameters.ContainsKey("otp") && !(parameters["otp"] is string))
            {
                throw new ArgumentException("Bad parameter: otp must be of type string", "parameters[\"otp\"]");
            }
            if (parameters.ContainsKey("partial_session_id") && !(parameters["partial_session_id"] is string))
            {
                throw new ArgumentException("Bad parameter: partial_session_id must be of type string", "parameters[\"partial_session_id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/sessions", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <Session>(responseJson));
        }
예제 #6
0
        /// <summary>
        /// Parameters:
        ///   name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
        ///   body - string - Body text of Clickwrap (supports Markdown formatting).
        ///   use_with_bundles - string - Use this Clickwrap for Bundles?
        ///   use_with_inboxes - string - Use this Clickwrap for Inboxes?
        ///   use_with_users - string - Use this Clickwrap for User Registrations?  Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
        /// </summary>
        public static async Task <Clickwrap> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("body") && !(parameters["body"] is string))
            {
                throw new ArgumentException("Bad parameter: body must be of type string", "parameters[\"body\"]");
            }
            if (parameters.ContainsKey("use_with_bundles") && !(parameters["use_with_bundles"] is string))
            {
                throw new ArgumentException("Bad parameter: use_with_bundles must be of type string", "parameters[\"use_with_bundles\"]");
            }
            if (parameters.ContainsKey("use_with_inboxes") && !(parameters["use_with_inboxes"] is string))
            {
                throw new ArgumentException("Bad parameter: use_with_inboxes must be of type string", "parameters[\"use_with_inboxes\"]");
            }
            if (parameters.ContainsKey("use_with_users") && !(parameters["use_with_users"] is string))
            {
                throw new ArgumentException("Bad parameter: use_with_users must be of type string", "parameters[\"use_with_users\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/clickwraps", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <Clickwrap>(responseJson));
        }
예제 #7
0
        /// <summary>
        /// Parameters:
        ///   user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
        ///   cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   project_id (required) - int64 - Project for which to return messages.
        /// </summary>
        public static async Task <Message[]> List(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("project_id") && !(parameters["project_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: project_id must be of type Nullable<Int64>", "parameters[\"project_id\"]");
            }
            if (!parameters.ContainsKey("project_id") || parameters["project_id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: project_id", "parameters[\"project_id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/messages", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <Message[]>(responseJson));
        }
예제 #8
0
        /// <summary>
        /// Parameters:
        ///   cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   path (required) - string - Path to operate on.
        ///   include_children - boolean - Include locks from children objects?
        /// </summary>
        public static async Task <Lock[]> ListFor(
            string path,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("path", path);
            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }
            if (parameters.ContainsKey("include_children") && !(parameters["include_children"] is bool))
            {
                throw new ArgumentException("Bad parameter: include_children must be of type bool", "parameters[\"include_children\"]");
            }
            if (!parameters.ContainsKey("path") || parameters["path"] == null)
            {
                throw new ArgumentNullException("Parameter missing: path", "parameters[\"path\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/locks/{Uri.EscapeDataString(parameters["path"].ToString())}", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <Lock[]>(responseJson));
        }
예제 #9
0
        /// <summary>
        /// Parameters:
        ///   global_access (required) - string - Global permissions.  Can be: `none`, `anyone_with_read`, `anyone_with_full`.
        /// </summary>
        public async Task <Project> Update(Dictionary <string, object> parameters)
        {
            parameters       = parameters != null ? parameters : new Dictionary <string, object>();
            parameters["id"] = attributes["id"];

            if (!attributes.ContainsKey("id"))
            {
                throw new ArgumentException("Current object doesn't have a id");
            }
            if (parameters.ContainsKey("id") && !(parameters["id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: id must be of type Nullable<Int64>", "parameters[\"id\"]");
            }
            if (parameters.ContainsKey("global_access") && !(parameters["global_access"] is string))
            {
                throw new ArgumentException("Bad parameter: global_access must be of type string", "parameters[\"global_access\"]");
            }
            if (!parameters.ContainsKey("id") || parameters["id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: id", "parameters[\"id\"]");
            }
            if (!parameters.ContainsKey("global_access") || parameters["global_access"] == null)
            {
                throw new ArgumentNullException("Parameter missing: global_access", "parameters[\"global_access\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/projects/{Uri.EscapeDataString(attributes["id"].ToString())}", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <Project>(responseJson));
        }
예제 #10
0
        /// <summary>
        /// Parameters:
        ///   name - string - Internal name for the API Key.  For your use.
        ///   expires_at - string - API Key expiration date
        ///   permission_set - string - Permissions for this API Key.  Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations).  Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges.  If you have ideas for permission sets, please let us know.
        /// </summary>
        public async Task <ApiKey> Update(Dictionary <string, object> parameters)
        {
            parameters       = parameters != null ? parameters : new Dictionary <string, object>();
            parameters["id"] = attributes["id"];

            if (!attributes.ContainsKey("id"))
            {
                throw new ArgumentException("Current object doesn't have a id");
            }
            if (parameters.ContainsKey("id") && !(parameters["id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: id must be of type Nullable<Int64>", "parameters[\"id\"]");
            }
            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("expires_at") && !(parameters["expires_at"] is string))
            {
                throw new ArgumentException("Bad parameter: expires_at must be of type string", "parameters[\"expires_at\"]");
            }
            if (parameters.ContainsKey("permission_set") && !(parameters["permission_set"] is string))
            {
                throw new ArgumentException("Bad parameter: permission_set must be of type string", "parameters[\"permission_set\"]");
            }
            if (!parameters.ContainsKey("id") || parameters["id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: id", "parameters[\"id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/api_keys/{Uri.EscapeDataString(attributes["id"].ToString())}", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <ApiKey>(responseJson));
        }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="token">OAuth 2.0 token obtained from Egnyte</param>
        /// <param name="domain">Domain on which you connect to egnyte,
        /// i.e.: domain is 'mydomain', when url looks like: mydomain.egnyte.com</param>
        /// <param name="httpClient">You can provide your own httpClient. Optional</param>
        /// <param name="requestTimeout">You can provide timeout for calling Egnyte API,
        /// by default it's 10 minutes. This parameter is optional</param>
        /// <param name="host">Full host name on which you connect to egnyte,
        /// i.e.: host is 'my.custom.host.com', when url looks like: my.custom.host.com</param>
        public EgnyteClient(
            string token,
            string domain           = "",
            HttpClient httpClient   = null,
            TimeSpan?requestTimeout = null,
            string host             = "")
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                throw new ArgumentNullException(nameof(token));
            }

            if (string.IsNullOrWhiteSpace(domain) && string.IsNullOrWhiteSpace(host))
            {
                throw new ArgumentNullException("domain", "Domain or host has to specified");
            }

            httpClient = httpClient ?? new HttpClient();

            httpClient.Timeout = TimeSpan.FromMinutes(10);
            if (requestTimeout.HasValue)
            {
                httpClient.Timeout = requestTimeout.Value;
            }

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

            Files       = new FilesClient(httpClient, domain, host);
            Users       = new UsersClient(httpClient, domain, host);
            Links       = new LinksClient(httpClient, domain, host);
            Groups      = new GroupsClient(httpClient, domain, host);
            Permissions = new PermissionsClient(httpClient, domain, host);
            Search      = new SearchClient(httpClient, domain, host);
            Audit       = new AuditClient(httpClient, domain, host);
        }
예제 #12
0
        /// <summary>
        /// Parameters:
        ///   name - string - AS2 Name
        ///   uri - string - URL base for AS2 responses
        ///   public_certificate - string
        /// </summary>
        public static async Task <As2Partner> Update(
            Nullable <Int64> id,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("id", id);
            if (parameters.ContainsKey("id") && !(parameters["id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: id must be of type Nullable<Int64>", "parameters[\"id\"]");
            }
            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("uri") && !(parameters["uri"] is string))
            {
                throw new ArgumentException("Bad parameter: uri must be of type string", "parameters[\"uri\"]");
            }
            if (parameters.ContainsKey("public_certificate") && !(parameters["public_certificate"] is string))
            {
                throw new ArgumentException("Bad parameter: public_certificate must be of type string", "parameters[\"public_certificate\"]");
            }
            if (!parameters.ContainsKey("id") || parameters["id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: id", "parameters[\"id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/as2_partners/{Uri.EscapeDataString(parameters["id"].ToString())}", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <As2Partner>(responseJson));
        }
예제 #13
0
        /// <summary>
        /// Parameters:
        ///   token (required) - string - Lock token
        /// </summary>
        public static async Task <Lock> Delete(
            string path,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("path", path);
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }
            if (parameters.ContainsKey("token") && !(parameters["token"] is string))
            {
                throw new ArgumentException("Bad parameter: token must be of type string", "parameters[\"token\"]");
            }
            if (!parameters.ContainsKey("path") || parameters["path"] == null)
            {
                throw new ArgumentNullException("Parameter missing: path", "parameters[\"path\"]");
            }
            if (!parameters.ContainsKey("token") || parameters["token"] == null)
            {
                throw new ArgumentNullException("Parameter missing: token", "parameters[\"token\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/locks/{Uri.EscapeDataString(parameters["path"].ToString())}", System.Net.Http.HttpMethod.Delete, parameters, options);

            return(JsonSerializer.Deserialize <Lock>(responseJson));
        }
예제 #14
0
        /// <summary>
        /// Parameters:
        ///   body (required) - string - Comment body.
        /// </summary>
        public static async Task <MessageComment> Update(
            Nullable <Int64> id,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("id", id);
            if (parameters.ContainsKey("id") && !(parameters["id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: id must be of type Nullable<Int64>", "parameters[\"id\"]");
            }
            if (parameters.ContainsKey("body") && !(parameters["body"] is string))
            {
                throw new ArgumentException("Bad parameter: body must be of type string", "parameters[\"body\"]");
            }
            if (!parameters.ContainsKey("id") || parameters["id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: id", "parameters[\"id\"]");
            }
            if (!parameters.ContainsKey("body") || parameters["body"] == null)
            {
                throw new ArgumentNullException("Parameter missing: body", "parameters[\"body\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/message_comments/{Uri.EscapeDataString(parameters["id"].ToString())}", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <MessageComment>(responseJson));
        }
예제 #15
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new FilesClient(connection);

                var filters = new FileFilters
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 0,
                };

                await client.GetAll(filters);

                Received.InOrder(async() =>
                {
                    await connection.GetAll <File>(
                        Arg.Is <Uri>(u => u.ToString() == "files"),
                        Arg.Is <Dictionary <string, string> >(d => d.Count == 0),
                        Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                            o.PageCount == 1 &&
                                            o.StartPage == 0)
                        );
                });
            }
        /// <summary>
        /// Parameters:
        ///   user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
        ///   emoji (required) - string - Emoji to react with.
        /// </summary>
        public static async Task <MessageCommentReaction> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("emoji") && !(parameters["emoji"] is string))
            {
                throw new ArgumentException("Bad parameter: emoji must be of type string", "parameters[\"emoji\"]");
            }
            if (!parameters.ContainsKey("emoji") || parameters["emoji"] == null)
            {
                throw new ArgumentNullException("Parameter missing: emoji", "parameters[\"emoji\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/message_comment_reactions", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <MessageCommentReaction>(responseJson));
        }
예제 #17
0
        /// <summary>
        /// Parameters:
        ///   body (required) - string - Comment body.
        ///   path (required) - string - File path.
        /// </summary>
        public static async Task <FileComment> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("body") && !(parameters["body"] is string))
            {
                throw new ArgumentException("Bad parameter: body must be of type string", "parameters[\"body\"]");
            }
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }
            if (!parameters.ContainsKey("body") || parameters["body"] == null)
            {
                throw new ArgumentNullException("Parameter missing: body", "parameters[\"body\"]");
            }
            if (!parameters.ContainsKey("path") || parameters["path"] == null)
            {
                throw new ArgumentNullException("Parameter missing: path", "parameters[\"path\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/file_comments", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <FileComment>(responseJson));
        }
예제 #18
0
        /// <summary>
        /// Parameters:
        ///   file (required) - file - Logo for custom branding.
        /// </summary>
        public static async Task <Style> Update(
            string path,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("path", path);
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }
            if (parameters.ContainsKey("file") && !(parameters["file"] is System.Net.Http.ByteArrayContent))
            {
                throw new ArgumentException("Bad parameter: file must be of type System.Net.Http.ByteArrayContent", "parameters[\"file\"]");
            }
            if (!parameters.ContainsKey("path") || parameters["path"] == null)
            {
                throw new ArgumentNullException("Parameter missing: path", "parameters[\"path\"]");
            }
            if (!parameters.ContainsKey("file") || parameters["file"] == null)
            {
                throw new ArgumentNullException("Parameter missing: file", "parameters[\"file\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/styles/{Uri.EscapeDataString(parameters["path"].ToString())}", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <Style>(responseJson));
        }
예제 #19
0
        /// <summary>
        /// Parameters:
        ///   expires_at - string - API Key expiration date
        ///   name - string - Internal name for the API Key.  For your use.
        ///   permission_set - string - Permissions for this API Key.  Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations).  Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges.  If you have ideas for permission sets, please let us know.
        /// </summary>
        public static async Task <ApiKey> UpdateCurrent(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("expires_at") && !(parameters["expires_at"] is string))
            {
                throw new ArgumentException("Bad parameter: expires_at must be of type string", "parameters[\"expires_at\"]");
            }
            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("permission_set") && !(parameters["permission_set"] is string))
            {
                throw new ArgumentException("Bad parameter: permission_set must be of type string", "parameters[\"permission_set\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/api_key", new HttpMethod("PATCH"), parameters, options);

            return(JsonSerializer.Deserialize <ApiKey>(responseJson));
        }
예제 #20
0
        /// <summary>
        /// Parameters:
        ///   user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
        ///   name - string - Internal name for the API Key.  For your use.
        ///   expires_at - string - API Key expiration date
        ///   permission_set - string - Permissions for this API Key.  Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations).  Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges.  If you have ideas for permission sets, please let us know.
        ///   path - string - Folder path restriction for this api key.
        /// </summary>
        public static async Task <ApiKey> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("expires_at") && !(parameters["expires_at"] is string))
            {
                throw new ArgumentException("Bad parameter: expires_at must be of type string", "parameters[\"expires_at\"]");
            }
            if (parameters.ContainsKey("permission_set") && !(parameters["permission_set"] is string))
            {
                throw new ArgumentException("Bad parameter: permission_set must be of type string", "parameters[\"permission_set\"]");
            }
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/api_keys", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <ApiKey>(responseJson));
        }
예제 #21
0
        /// <summary>
        /// Parameters:
        ///   name - string - Group name.
        ///   notes - string - Group notes.
        ///   user_ids - string - A list of user ids. If sent as a string, should be comma-delimited.
        ///   admin_ids - string - A list of group admin user ids. If sent as a string, should be comma-delimited.
        /// </summary>
        public static async Task <Group> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("notes") && !(parameters["notes"] is string))
            {
                throw new ArgumentException("Bad parameter: notes must be of type string", "parameters[\"notes\"]");
            }
            if (parameters.ContainsKey("user_ids") && !(parameters["user_ids"] is string))
            {
                throw new ArgumentException("Bad parameter: user_ids must be of type string", "parameters[\"user_ids\"]");
            }
            if (parameters.ContainsKey("admin_ids") && !(parameters["admin_ids"] is string))
            {
                throw new ArgumentException("Bad parameter: admin_ids must be of type string", "parameters[\"admin_ids\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/groups", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <Group>(responseJson));
        }
예제 #22
0
        /// <summary>
        /// Parameters:
        ///   group_id (required) - int64 - Group ID to add user to.
        ///   user_id (required) - int64 - User ID to add to group.
        ///   admin - boolean - Is the user a group administrator?
        /// </summary>
        public static async Task <GroupUser> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("group_id") && !(parameters["group_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: group_id must be of type Nullable<Int64>", "parameters[\"group_id\"]");
            }
            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("admin") && !(parameters["admin"] is bool))
            {
                throw new ArgumentException("Bad parameter: admin must be of type bool", "parameters[\"admin\"]");
            }
            if (!parameters.ContainsKey("group_id") || parameters["group_id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: group_id", "parameters[\"group_id\"]");
            }
            if (!parameters.ContainsKey("user_id") || parameters["user_id"] == null)
            {
                throw new ArgumentNullException("Parameter missing: user_id", "parameters[\"user_id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/group_users", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <GroupUser>(responseJson));
        }
예제 #23
0
        /// <summary>
        /// Parameters:
        ///   cursor - string - Used for pagination.  Send a cursor value to resume an existing list from the point at which you left off.  Get a cursor from an existing list via either the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `created_at`.
        ///   filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `created_at`.
        ///   filter_gt - object - If set, return records where the specified field is greater than the supplied value. Valid fields are `created_at`.
        ///   filter_gteq - object - If set, return records where the specified field is greater than or equal to the supplied value. Valid fields are `created_at`.
        ///   filter_like - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `created_at`.
        ///   filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `created_at`.
        ///   filter_lteq - object - If set, return records where the specified field is less than or equal to the supplied value. Valid fields are `created_at`.
        ///   bundle_id - int64 - Bundle ID
        ///   bundle_registration_id - int64 - BundleRegistration ID
        /// </summary>
        public static async Task <BundleDownload[]> List(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("sort_by") && !(parameters["sort_by"] is object))
            {
                throw new ArgumentException("Bad parameter: sort_by must be of type object", "parameters[\"sort_by\"]");
            }
            if (parameters.ContainsKey("filter") && !(parameters["filter"] is object))
            {
                throw new ArgumentException("Bad parameter: filter must be of type object", "parameters[\"filter\"]");
            }
            if (parameters.ContainsKey("filter_gt") && !(parameters["filter_gt"] is object))
            {
                throw new ArgumentException("Bad parameter: filter_gt must be of type object", "parameters[\"filter_gt\"]");
            }
            if (parameters.ContainsKey("filter_gteq") && !(parameters["filter_gteq"] is object))
            {
                throw new ArgumentException("Bad parameter: filter_gteq must be of type object", "parameters[\"filter_gteq\"]");
            }
            if (parameters.ContainsKey("filter_like") && !(parameters["filter_like"] is object))
            {
                throw new ArgumentException("Bad parameter: filter_like must be of type object", "parameters[\"filter_like\"]");
            }
            if (parameters.ContainsKey("filter_lt") && !(parameters["filter_lt"] is object))
            {
                throw new ArgumentException("Bad parameter: filter_lt must be of type object", "parameters[\"filter_lt\"]");
            }
            if (parameters.ContainsKey("filter_lteq") && !(parameters["filter_lteq"] is object))
            {
                throw new ArgumentException("Bad parameter: filter_lteq must be of type object", "parameters[\"filter_lteq\"]");
            }
            if (parameters.ContainsKey("bundle_id") && !(parameters["bundle_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: bundle_id must be of type Nullable<Int64>", "parameters[\"bundle_id\"]");
            }
            if (parameters.ContainsKey("bundle_registration_id") && !(parameters["bundle_registration_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: bundle_registration_id must be of type Nullable<Int64>", "parameters[\"bundle_registration_id\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/bundle_downloads", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <BundleDownload[]>(responseJson));
        }
            public void DeletesCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new FilesClient(connection);

                client.Delete(123);

                connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "files/123"));
            }
예제 #25
0
        /// <summary>
        /// Parameters:
        ///   cursor - string - Send cursor to resume an existing list from the point at which you left off.  Get a cursor from an existing list via the X-Files-Cursor-Next header or the X-Files-Cursor-Prev header.
        ///   per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
        ///   path (required) - string - Path to operate on.
        ///   filter - string - If specified, will filter folders/files list by this string.  Wildcards of `*` and `?` are acceptable here.
        ///   preview_size - string - Request a preview size.  Can be `small` (default), `large`, `xlarge`, or `pdf`.
        ///   search - string - If `search_all` is `true`, provide the search string here.  Otherwise, this parameter acts like an alias of `filter`.
        ///   search_all - boolean - Search entire site?
        ///   with_previews - boolean - Include file previews?
        ///   with_priority_color - boolean - Include file priority color information?
        /// </summary>
        public static async Task <RemoteFile[]> ListFor(
            string path,
            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            parameters.Add("path", path);
            if (parameters.ContainsKey("cursor") && !(parameters["cursor"] is string))
            {
                throw new ArgumentException("Bad parameter: cursor must be of type string", "parameters[\"cursor\"]");
            }
            if (parameters.ContainsKey("per_page") && !(parameters["per_page"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: per_page must be of type Nullable<Int64>", "parameters[\"per_page\"]");
            }
            if (parameters.ContainsKey("path") && !(parameters["path"] is string))
            {
                throw new ArgumentException("Bad parameter: path must be of type string", "parameters[\"path\"]");
            }
            if (parameters.ContainsKey("filter") && !(parameters["filter"] is string))
            {
                throw new ArgumentException("Bad parameter: filter must be of type string", "parameters[\"filter\"]");
            }
            if (parameters.ContainsKey("preview_size") && !(parameters["preview_size"] is string))
            {
                throw new ArgumentException("Bad parameter: preview_size must be of type string", "parameters[\"preview_size\"]");
            }
            if (parameters.ContainsKey("search") && !(parameters["search"] is string))
            {
                throw new ArgumentException("Bad parameter: search must be of type string", "parameters[\"search\"]");
            }
            if (parameters.ContainsKey("search_all") && !(parameters["search_all"] is bool))
            {
                throw new ArgumentException("Bad parameter: search_all must be of type bool", "parameters[\"search_all\"]");
            }
            if (parameters.ContainsKey("with_previews") && !(parameters["with_previews"] is bool))
            {
                throw new ArgumentException("Bad parameter: with_previews must be of type bool", "parameters[\"with_previews\"]");
            }
            if (parameters.ContainsKey("with_priority_color") && !(parameters["with_priority_color"] is bool))
            {
                throw new ArgumentException("Bad parameter: with_priority_color must be of type bool", "parameters[\"with_priority_color\"]");
            }
            if (!parameters.ContainsKey("path") || parameters["path"] == null)
            {
                throw new ArgumentNullException("Parameter missing: path", "parameters[\"path\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/folders/{Uri.EscapeDataString(parameters["path"].ToString())}", System.Net.Http.HttpMethod.Get, parameters, options);

            return(JsonSerializer.Deserialize <RemoteFile[]>(responseJson));
        }
예제 #26
0
        /// <summary>
        /// Parameters:
        ///   url (required) - string - URL for testing the webhook.
        ///   method - string - HTTP method(GET or POST).
        ///   encoding - string - HTTP encoding method.  Can be JSON, XML, or RAW (form data).
        ///   headers - object - Additional request headers.
        ///   body - object - Additional body parameters.
        ///   raw_body - string - raw body text
        ///   file_as_body - boolean - Send the file data as the request body?
        ///   file_form_field - string - Send the file data as a named parameter in the request POST body
        ///   action - string - action for test body
        /// </summary>
        public static async Task <WebhookTest> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("url") && !(parameters["url"] is string))
            {
                throw new ArgumentException("Bad parameter: url must be of type string", "parameters[\"url\"]");
            }
            if (parameters.ContainsKey("method") && !(parameters["method"] is string))
            {
                throw new ArgumentException("Bad parameter: method must be of type string", "parameters[\"method\"]");
            }
            if (parameters.ContainsKey("encoding") && !(parameters["encoding"] is string))
            {
                throw new ArgumentException("Bad parameter: encoding must be of type string", "parameters[\"encoding\"]");
            }
            if (parameters.ContainsKey("headers") && !(parameters["headers"] is object))
            {
                throw new ArgumentException("Bad parameter: headers must be of type object", "parameters[\"headers\"]");
            }
            if (parameters.ContainsKey("body") && !(parameters["body"] is object))
            {
                throw new ArgumentException("Bad parameter: body must be of type object", "parameters[\"body\"]");
            }
            if (parameters.ContainsKey("raw_body") && !(parameters["raw_body"] is string))
            {
                throw new ArgumentException("Bad parameter: raw_body must be of type string", "parameters[\"raw_body\"]");
            }
            if (parameters.ContainsKey("file_as_body") && !(parameters["file_as_body"] is bool))
            {
                throw new ArgumentException("Bad parameter: file_as_body must be of type bool", "parameters[\"file_as_body\"]");
            }
            if (parameters.ContainsKey("file_form_field") && !(parameters["file_form_field"] is string))
            {
                throw new ArgumentException("Bad parameter: file_form_field must be of type string", "parameters[\"file_form_field\"]");
            }
            if (parameters.ContainsKey("action") && !(parameters["action"] is string))
            {
                throw new ArgumentException("Bad parameter: action must be of type string", "parameters[\"action\"]");
            }
            if (!parameters.ContainsKey("url") || parameters["url"] == null)
            {
                throw new ArgumentNullException("Parameter missing: url", "parameters[\"url\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/webhook_tests", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <WebhookTest>(responseJson));
        }
예제 #27
0
        /// <summary>
        /// Parameters:
        ///   user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
        ///   start_at - string - Start date/time of export range.
        ///   end_at - string - End date/time of export range.
        ///   query_message - string - Error message associated with the request, if any.
        ///   query_request_method - string - The HTTP request method used by the webhook.
        ///   query_request_url - string - The target webhook URL.
        ///   query_status - string - The HTTP status returned from the server in response to the webhook request.
        ///   query_success - boolean - true if the webhook request succeeded (i.e. returned a 200 or 204 response status). false otherwise.
        ///   query_path - string - Return notifications that were triggered by actions on this specific path.
        ///   query_folder - string - Return notifications that were triggered by actions in this folder.
        /// </summary>
        public static async Task <ActionNotificationExport> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("user_id") && !(parameters["user_id"] is Nullable <Int64>))
            {
                throw new ArgumentException("Bad parameter: user_id must be of type Nullable<Int64>", "parameters[\"user_id\"]");
            }
            if (parameters.ContainsKey("start_at") && !(parameters["start_at"] is string))
            {
                throw new ArgumentException("Bad parameter: start_at must be of type string", "parameters[\"start_at\"]");
            }
            if (parameters.ContainsKey("end_at") && !(parameters["end_at"] is string))
            {
                throw new ArgumentException("Bad parameter: end_at must be of type string", "parameters[\"end_at\"]");
            }
            if (parameters.ContainsKey("query_message") && !(parameters["query_message"] is string))
            {
                throw new ArgumentException("Bad parameter: query_message must be of type string", "parameters[\"query_message\"]");
            }
            if (parameters.ContainsKey("query_request_method") && !(parameters["query_request_method"] is string))
            {
                throw new ArgumentException("Bad parameter: query_request_method must be of type string", "parameters[\"query_request_method\"]");
            }
            if (parameters.ContainsKey("query_request_url") && !(parameters["query_request_url"] is string))
            {
                throw new ArgumentException("Bad parameter: query_request_url must be of type string", "parameters[\"query_request_url\"]");
            }
            if (parameters.ContainsKey("query_status") && !(parameters["query_status"] is string))
            {
                throw new ArgumentException("Bad parameter: query_status must be of type string", "parameters[\"query_status\"]");
            }
            if (parameters.ContainsKey("query_success") && !(parameters["query_success"] is bool))
            {
                throw new ArgumentException("Bad parameter: query_success must be of type bool", "parameters[\"query_success\"]");
            }
            if (parameters.ContainsKey("query_path") && !(parameters["query_path"] is string))
            {
                throw new ArgumentException("Bad parameter: query_path must be of type string", "parameters[\"query_path\"]");
            }
            if (parameters.ContainsKey("query_folder") && !(parameters["query_folder"] is string))
            {
                throw new ArgumentException("Bad parameter: query_folder must be of type string", "parameters[\"query_folder\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/action_notification_exports", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <ActionNotificationExport>(responseJson));
        }
예제 #28
0
        /// <summary>
        /// Parameters:
        ///   name (required) - string - AS2 Name
        ///   domain (required) - string - AS2 Domain
        ///   uri (required) - string - URL base for AS2 responses
        ///   public_certificate (required) - string
        ///   private_key (required) - string
        /// </summary>
        public static async Task <As2Station> Create(

            Dictionary <string, object> parameters = null,
            Dictionary <string, object> options    = null
            )
        {
            parameters = parameters != null ? parameters : new Dictionary <string, object>();
            options    = options != null ? options : new Dictionary <string, object>();

            if (parameters.ContainsKey("name") && !(parameters["name"] is string))
            {
                throw new ArgumentException("Bad parameter: name must be of type string", "parameters[\"name\"]");
            }
            if (parameters.ContainsKey("domain") && !(parameters["domain"] is string))
            {
                throw new ArgumentException("Bad parameter: domain must be of type string", "parameters[\"domain\"]");
            }
            if (parameters.ContainsKey("uri") && !(parameters["uri"] is string))
            {
                throw new ArgumentException("Bad parameter: uri must be of type string", "parameters[\"uri\"]");
            }
            if (parameters.ContainsKey("public_certificate") && !(parameters["public_certificate"] is string))
            {
                throw new ArgumentException("Bad parameter: public_certificate must be of type string", "parameters[\"public_certificate\"]");
            }
            if (parameters.ContainsKey("private_key") && !(parameters["private_key"] is string))
            {
                throw new ArgumentException("Bad parameter: private_key must be of type string", "parameters[\"private_key\"]");
            }
            if (!parameters.ContainsKey("name") || parameters["name"] == null)
            {
                throw new ArgumentNullException("Parameter missing: name", "parameters[\"name\"]");
            }
            if (!parameters.ContainsKey("domain") || parameters["domain"] == null)
            {
                throw new ArgumentNullException("Parameter missing: domain", "parameters[\"domain\"]");
            }
            if (!parameters.ContainsKey("uri") || parameters["uri"] == null)
            {
                throw new ArgumentNullException("Parameter missing: uri", "parameters[\"uri\"]");
            }
            if (!parameters.ContainsKey("public_certificate") || parameters["public_certificate"] == null)
            {
                throw new ArgumentNullException("Parameter missing: public_certificate", "parameters[\"public_certificate\"]");
            }
            if (!parameters.ContainsKey("private_key") || parameters["private_key"] == null)
            {
                throw new ArgumentNullException("Parameter missing: private_key", "parameters[\"private_key\"]");
            }

            string responseJson = await FilesClient.SendRequest($"/as2_stations", System.Net.Http.HttpMethod.Post, parameters, options);

            return(JsonSerializer.Deserialize <As2Station>(responseJson));
        }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new FilesClient(connection);

                await client.Get(123);

                Received.InOrder(async() =>
                {
                    await connection.Get <File>(Arg.Is <Uri>(u => u.ToString() == "files/123"));
                });
            }
예제 #30
0
        public static int Main(string[] args)
        {
            log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            log.Info("Starting up");

            FilesClient filesClient = new FilesClient();

            var commands = GetCommands();
            int result   = ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);

            log.Info("Complete");
            return(result);
        }