/// <summary> /// Creates a room using specified template /// </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="model">The model of room</param> /// <param name="templateId">The Id of room template</param> /// <returns>The instance of created room</returns> public static Room CreateRoom( string basePath, string accessToken, string accountId, RoomModel model, int templateId) { // Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}"); var roomsApi = new RoomsApi(apiClient); var rolesApi = new RolesApi(apiClient); // Obtain Role var clientRole = rolesApi.GetRoles(accountId, new RolesApi.GetRolesOptions { filter = "Default Admin" }).Roles.First(); // Construct the request body for your room var newRoom = BuildRoom(model, clientRole, templateId); // Call the Rooms API to create a room return(roomsApi.CreateRoom(accountId, newRoom)); }
public ActionResult Create(RoomModel model) { // Step 1. Obtain your OAuth token var 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 rolesApi = new RolesApi(apiClient); var accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID} try { // Step 3: Obtain Role RoleSummary clientRole = rolesApi.GetRoles(accountId, new RolesApi.GetRolesOptions { filter = "Default Admin" }).Roles.First(); // Step 4: Construct the request body for your room RoomForCreate newRoom = BuildRoom(model, clientRole); // Step 5: Call the Rooms API to create a room Room room = roomsApi.CreateRoom(accountId, newRoom); ViewBag.h1 = "The room was successfully created"; ViewBag.message = $"The room was created! Room ID: {room.RoomId}, Name: {room.Name}."; ViewBag.Locals.Json = JsonConvert.SerializeObject(room, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
public Room CreateRoom(string locationId, CreateRoomRequest roomRequest) { return(_roomsApi.CreateRoom(_accessToken, locationId, roomRequest)); }