/// <summary>
        /// Gets the list of forms and form group
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <returns>The tuple of forms and form group lists</returns>
        public static (FormSummaryList forms, FormGroupSummaryList formGroups) GetFormsAndFormGroups(
            string basePath,
            string accessToken,
            string accountId)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var formGroupsApi    = new FormGroupsApi(apiClient);
            var formLibrariesApi = new FormLibrariesApi(apiClient);

            FormLibrarySummaryList formLibraries = formLibrariesApi.GetFormLibraries(accountId);

            FormSummaryList forms = new FormSummaryList(new List <FormSummary>());

            if (formLibraries.FormsLibrarySummaries.Any())
            {
                forms = formLibrariesApi.GetFormLibraryForms(
                    accountId,
                    formLibraries.FormsLibrarySummaries.First().FormsLibraryId);
            }

            FormGroupSummaryList formGroups = formGroupsApi.GetFormGroups(accountId);

            return(forms, formGroups);
        }
        public ActionResult GrantAccess(OfficeAccessModel roomDocumentModel)
        {
            string accessToken = RequestItemsService.User.AccessToken;
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var formGroupsApi = new FormGroupsApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId;

            try
            {
                // Step 5 start
                formGroupsApi.GrantOfficeAccessToFormGroup(accountId, new Guid(roomDocumentModel.FormGroupId), roomDocumentModel.OfficeId);
                // Step 5 end

                ViewBag.h1      = "Access is granted for the office";
                ViewBag.message = $"To the office with Id'{roomDocumentModel.OfficeId}' granted access for the form group with id '{roomDocumentModel.FormGroupId}'";

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
        public override IActionResult Get()
        {
            base.Get();
            string accessToken = RequestItemsService.User.AccessToken;
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2 start
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            // Step 2 end

            var formGroupsApi    = new FormGroupsApi(apiClient);
            var formLibrariesApi = new FormLibrariesApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId;

            try
            {
                // Step 3 start
                FormLibrarySummaryList formLibraries = formLibrariesApi.GetFormLibraries(accountId);

                FormSummaryList forms = new FormSummaryList(new List <FormSummary>());
                if (formLibraries.FormsLibrarySummaries.Any())
                {
                    forms = formLibrariesApi.GetFormLibraryForms(
                        accountId,
                        formLibraries.FormsLibrarySummaries.First().FormsLibraryId);
                }
                // Step 3 end

                // Step 4 start
                FormGroupSummaryList formGroups = formGroupsApi.GetFormGroups(accountId);
                // Step 4 end

                FormFormGroupModel = new FormFormGroupModel {
                    Forms = forms.Forms, FormGroups = formGroups.FormGroups
                };

                return(View("Eg09", this));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
Example #4
0
        /// <summary>
        /// Grants office access to a form group
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="formGroupId">The Id of the specified form group</param>
        /// <param name="officeId">The Id of the specified office</param>
        /// <returns></returns>
        public static void GrantAccess(
            string basePath,
            string accessToken,
            string accountId,
            string formGroupId,
            int?officeId)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var formGroupsApi = new FormGroupsApi(apiClient);

            // Call the Rooms API to grant office access to a form group
            formGroupsApi.GrantOfficeAccessToFormGroup(accountId, new Guid(formGroupId), officeId);
        }
        /// <summary>
        /// Grants office access to a form group
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="formGroupId">The Id of the specified form group</param>
        /// <param name="formToAssign">The form to be assigned to form group</param>
        /// <returns>The form to be assigned to form group</returns>
        public static FormGroupFormToAssign AssignForm(
            string basePath,
            string accessToken,
            string accountId,
            string formGroupId,
            FormGroupFormToAssign formToAssign)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var formGroupsApi = new FormGroupsApi(apiClient);

            // Call the Rooms API to assign form to form group
            return(formGroupsApi.AssignFormGroupForm(accountId, new Guid(formGroupId), formToAssign));
        }
        /// <summary>
        /// Creates form group
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <param name="groupName">The name of new group</param>
        /// <returns>The new form group</returns>
        public static FormGroup CreateGroup(
            string basePath,
            string accessToken,
            string accountId,
            string groupName)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}");
            var formGroupsApi = new FormGroupsApi(apiClient);

            var formGroupForCreate = new FormGroupForCreate(groupName);

            // Call the Rooms API to create form group
            return(formGroupsApi.CreateFormGroup(accountId, formGroupForCreate));
        }
Example #7
0
        /// <summary>
        /// Gets the list of offices and form group
        /// </summary>
        /// <param name="basePath">BasePath for API calls (URI)</param>
        /// <param name="accessToken">Access Token for API call (OAuth)</param>
        /// <param name="accountId">The DocuSign Account ID (GUID or short version) for which the APIs call would be made</param>
        /// <returns>The tuple of office and form group lists</returns>
        public static (OfficeSummaryList offices, FormGroupSummaryList formGroups) GetOfficesAndFormGroups(
            string basePath,
            string accessToken,
            string accountId)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            var officesApi    = new OfficesApi(apiClient);
            var formGroupsApi = new FormGroupsApi(apiClient);

            // Call the Rooms API to get offices
            var offices = officesApi.GetOffices(accountId);

            // Call the Rooms API to get form groups
            var formGroups = formGroupsApi.GetFormGroups(accountId);

            return(offices, formGroups);
        }
        public override IActionResult Get()
        {
            base.Get();
            string accessToken = RequestItemsService.User.AccessToken;
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2 start
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            // Step 2 end

            var officesApi    = new OfficesApi(apiClient);
            var formGroupsApi = new FormGroupsApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId;

            try
            {
                // Step 3 start
                var offices = officesApi.GetOffices(accountId);
                // Step 3 end

                // Step 4 start
                var formGroups = formGroupsApi.GetFormGroups(accountId);
                // Step 4 end

                OfficeAccessModel = new OfficeAccessModel {
                    Offices = offices.OfficeSummaries, FormGroups = formGroups.FormGroups
                };

                return(View("Eg08", this));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
        public ActionResult CreateFormGroup(FormGroupModel formGroupModel)
        {
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2 start
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            // Step 2 end

            var    formGroupsApi = new FormGroupsApi(apiClient);
            string accountId     = RequestItemsService.Session.AccountId;

            try
            {
                // Step 3 start
                var formGroupForCreate = new FormGroupForCreate(formGroupModel.Name);
                // Step 3 end

                // Step 4 start
                FormGroup formGroup = formGroupsApi.CreateFormGroup(accountId, formGroupForCreate);
                // Step 4 end

                ViewBag.h1          = "The form group was successfully created";
                ViewBag.message     = $"The form group was successfully created, FormGroupId: '{formGroup.FormGroupId}'";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(formGroup, Formatting.Indented);

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
        public ActionResult AssignFormToFormGroup(FormFormGroupModel formFormGroupModel)
        {
            string accessToken = RequestItemsService.User.AccessToken;
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);

            var formGroupsApi = new FormGroupsApi(apiClient);

            string accountId = RequestItemsService.Session.AccountId;

            try
            {
                // Step 6 start
                FormGroupFormToAssign formGroupFormToAssign = formGroupsApi.AssignFormGroupForm(accountId, new Guid(formFormGroupModel.FormGroupId), new FormGroupFormToAssign()
                {
                    FormId = formFormGroupModel.FormId
                });
                // Step 6 end

                ViewBag.h1          = "The form was assigned to the form group successfully";
                ViewBag.message     = $"The form ('{formGroupFormToAssign.FormId}') was assigned to the form group ('{formFormGroupModel.FormGroupId}') successfully";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(formGroupFormToAssign, Formatting.Indented);

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }