/// <summary>
        /// Sends a reminder for an agreement.
        /// </summary>
        /// <param name="agreementId">The agreement identifier, as returned by the agreement creation API or retrieved from the API to fetch agreements</param>
        /// <returns>AgreementInfo</returns>
        public async Task <ReminderCreationResult> SendReminders(ReminderCreationInfo info)
        {
            string serializedObject = JsonConvert.SerializeObject(info);

            using (StringContent content = new StringContent(serializedObject, Encoding.UTF8))
            {
                content.Headers.Remove("Content-Type");
                content.Headers.Add("Content-Type", "application/json");

                HttpResponseMessage result = await client.PostAsync(apiEndpointVer + "/reminders", content).ConfigureAwait(false);

                if (result.IsSuccessStatusCode)
                {
                    string response = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                    ReminderCreationResult agreement = JsonConvert.DeserializeObject <ReminderCreationResult>(response);

                    return(agreement);
                }
                else
                {
                    string response = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                    HandleError(result.StatusCode, response, false);

                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a reminder for an agreement.
        /// </summary>
        public virtual Task <ReminderCreationResult> SendReminderAsync(ReminderCreationInfo info)
        {
            var request = new RestRequest(Method.POST);

            request.JsonSerializer = new Serialization.NewtonSoftSerializer();
            request.Resource       = "reminders";
            request.AddJsonBody(info);
            return(this.Sdk.ExecuteAsync <ReminderCreationResult>(request));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Sends a reminder for an agreement. Sends a reminder for an agreement.
        /// </summary>
        /// <param name="accessToken">
        ///     An &lt;a href&#x3D;\&quot;#\&quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc()\&quot;
        ///     oncontextmenu&#x3D;\&quot;this.href&#x3D;oauthDoc()\&quot; target&#x3D;\&quot;oauthDoc\&quot;&gt;OAuth Access Token
        ///     &lt;/a&gt; with scopes:&lt;ul&gt;&lt;li style&#x3D;&#39;list-style-type: square&#39;&gt;&lt;a href&#x3D;\&quot;#\
        ///     &quot; onclick&#x3D;\&quot;this.href&#x3D;oauthDoc(&#39;agreement_write&#39;)\&quot; oncontextmenu&#x3D;\&quot;
        ///     this.href&#x3D;oauthDoc(&#39;agreement_write&#39;)\&quot; target&#x3D;\&quot;oauthDoc\&quot;&gt;agreement_write&lt;
        ///     /a&gt;&lt;/li&gt;&lt;/ul&gt;
        /// </param>
        /// <param name="reminderCreationInfo">Information about the reminder.</param>
        /// <param name="xApiUser">
        ///     The userId or email of API caller using the account or group token in the format &lt;b&gt;
        ///     userid:{userId} OR email:{email}.&lt;/b&gt; If it is not specified, then the caller is inferred from the token.
        /// </param>
        /// <returns>ReminderCreationResult</returns>
        public ReminderCreationResult CreateReminder(string accessToken, ReminderCreationInfo reminderCreationInfo, string xApiUser)
        {
            // verify the required parameter 'accessToken' is set
            if (accessToken == null)
            {
                throw new ApiException(400, "Missing required parameter 'accessToken' when calling CreateReminder");
            }

            // verify the required parameter 'reminderCreationInfo' is set
            if (reminderCreationInfo == null)
            {
                throw new ApiException(400, "Missing required parameter 'reminderCreationInfo' when calling CreateReminder");
            }


            string path = "/reminders";

            path = path.Replace("{format}", "json");

            Dictionary <string, string>        queryParams  = new Dictionary <string, string>();
            Dictionary <string, string>        headerParams = new Dictionary <string, string>();
            Dictionary <string, string>        formParams   = new Dictionary <string, string>();
            Dictionary <string, FileParameter> fileParams   = new Dictionary <string, FileParameter>();
            string postBody = null;

            if (accessToken != null)
            {
                headerParams.Add("Access-Token", ApiClient.ParameterToString(accessToken));                      // header parameter
            }
            if (xApiUser != null)
            {
                headerParams.Add("x-api-user", ApiClient.ParameterToString(xApiUser)); // header parameter
            }
            postBody = ApiClient.Serialize(reminderCreationInfo);                      // http body (model) parameter

            // authentication setting, if any
            string[] authSettings = { };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if ((int)response.StatusCode >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling CreateReminder: " + response.Content, response.Content);
            }
            if ((int)response.StatusCode == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling CreateReminder: " + response.ErrorMessage, response.ErrorMessage);
            }

            return((ReminderCreationResult)ApiClient.Deserialize(response.Content, typeof(ReminderCreationResult), response.Headers));
        }