/// <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 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"));
            }
        }
Exemplo n.º 3
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"));
            }
        }