public override IActionResult Get()
        {
            base.Get();
            // Step 1. Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

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

            string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            try
            {
                //Step 3: Get Rooms
                RoomSummaryList rooms = roomsApi.GetRooms(accountId);

                RoomDocumentModel = new RoomDocumentModel {
                    Rooms = rooms.Rooms
                };

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

                return(View("Error"));
            }
        }
        /// <summary>
        /// Gets the list of rooms and forms
        /// </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 with lists of rooms and forms</returns>
        public static (FormSummaryList forms, RoomSummaryList rooms) GetFormsAndRooms(
            string basePath,
            string accessToken,
            string accountId)
        {
            // Construct your API headers
            var apiClient = new ApiClient(basePath);

            apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}");
            var roomsApi         = new RoomsApi(apiClient);
            var formLibrariesApi = new FormLibrariesApi(apiClient);

            // Get Forms Libraries
            FormLibrarySummaryList formLibraries = formLibrariesApi.GetFormLibraries(accountId);

            // Get Forms
            FormSummaryList forms = new FormSummaryList(new List <FormSummary>());

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

            // Get Rooms
            RoomSummaryList rooms = roomsApi.GetRooms(accountId);

            // Call the Rooms API to create a room
            return(forms, rooms);
        }
        public void JwtGetRoomsTest()
        {
            // |EnvelopesApi| contains methods related to creating and sending Envelopes (aka signature requests)
            RoomsApi        roomsApi = new RoomsApi(testConfig.ApiClient);
            RoomSummaryList rooms    = roomsApi.GetRooms(testConfig.AccountId, new RoomsApi.GetRoomsOptions());

            Assert.IsNotNull(rooms);
            Assert.IsNotNull(rooms.Rooms);
        }
        public override IActionResult Get()
        {
            base.Get();
            // Step 1. Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

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

            string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            try
            {
                //Step 3: Get Forms Libraries
                FormLibrarySummaryList formLibraries = formLibrariesApi.GetFormLibraries(accountId);

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

                //Step 5: Get Rooms
                RoomSummaryList rooms = roomsApi.GetRooms(accountId);

                RoomFormModel = new RoomFormModel {
                    Forms = forms.Forms, Rooms = rooms.Rooms
                };

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

                ApiError error = JsonConvert.DeserializeObject <ApiError>(apiException.ErrorContent);
                if (error.ErrorCode.Equals("FORMS_INTEGRATION_NOT_ENABLED", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(View("ExampleNotAvailable"));
                }
                return(View("Error"));
            }
        }
Exemplo n.º 5
0
        public ActionResult ExportData(RoomFilterModel roomFilterModel)
        {
            // Step 1. Obtain your OAuth token
            string accessToken = RequestItemsService.User.AccessToken;                      // Represents your {ACCESS_TOKEN}
            var    basePath    = $"{RequestItemsService.Session.RoomsApiBasePath}/restapi"; // Base API path

            // Step 2: Construct your API headers
            var apiClient = new ApiClient(basePath);

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

            string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID}

            try
            {
                // Step 3: Prepare your request parameters
                var fieldDataChangedStartDate = roomFilterModel.FieldDataChangedStartDate.ToString(CultureInfo.InvariantCulture);
                var fieldDataChangedEndDate   = roomFilterModel.FieldDataChangedEndDate.ToString(CultureInfo.InvariantCulture);

                // Step 4: Call the Rooms API to get rooms with filters
                RoomSummaryList rooms = roomsApi.GetRooms(accountId, new RoomsApi.GetRoomsOptions
                {
                    fieldDataChangedStartDate = fieldDataChangedStartDate,
                    fieldDataChangedEndDate   = fieldDataChangedEndDate
                });

                ViewBag.h1      = "The rooms with filters was loaded";
                ViewBag.message = $"Results from the Rooms: GetRooms method. FieldDataChangedStartDate: " +
                                  $"{ roomFilterModel.FieldDataChangedStartDate.Date.ToShortDateString() }, " +
                                  $"FieldDataChangedEndDate: { roomFilterModel.FieldDataChangedEndDate.Date.ToShortDateString() } :";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(rooms, Formatting.Indented);

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

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