/// <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 ExportData(RoomsListModel model) { // 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: Call the Rooms API to get room field data FieldData fieldData = roomsApi.GetRoomFieldData(accountId, model.RoomId); ViewBag.h1 = "The room data was successfully exported"; ViewBag.message = $"Results from the Rooms::GetRoomFieldData method RoomId: {model.RoomId} :"; ViewBag.Locals.Json = JsonConvert.SerializeObject(fieldData, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
public SmartThingsClient(string accessToken) { var configuration = new Configuration(); configuration.AccessToken = accessToken ?? throw new ArgumentNullException(accessToken); _accessToken = accessToken; _devicesApi = new DevicesApi(configuration); _locationsApi = new LocationsApi(configuration); _roomsApi = new RoomsApi(configuration); _scenesApi = new ScenesApi(configuration); _rulesApi = new RulesApi(configuration); _schedulesApi = new SchedulesApi(configuration); _appsApi = new AppsApi(configuration); _subscriptionsApi = new SubscriptionsApi(configuration); _installedAppsApi = new InstalledappsApi(configuration); _deviceProfilesApi = new ProfilesApi(configuration); _capabilitiesApi = new CapabilitiesApi(configuration); _presentationApi = new PresentationsApi(configuration); //_accessToken = accessToken; //_devicesApi = new DevicesApi(); //_locationsApi = new LocationsApi(); //_roomsApi = new RoomsApi(); //_scenesApi = new ScenesApi(); //_rulesApi = new RulesApi(); //_schedulesApi = new SchedulesApi(); //_appsApi = new AppsApi(); //_subscriptionsApi = new SubscriptionsApi(); //_installedAppsApi = new InstalledappsApi(); //_deviceProfilesApi = new ProfilesApi(); //_capabilitiesApi = new CapabilitiesApi(); //_presentationApi = new PresentationsApi(); }
protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { _allDevices = null; _allLocations = null; _allRooms = null; _allScenes = null; _allRules = null; _allSchedules = null; _allApps = null; _allSubscriptions = null; _allInstalledApps = null; _allDeviceProfiles = null; _devicesApi = null; _locationsApi = null; _roomsApi = null; _scenesApi = null; _rulesApi = null; _schedulesApi = null; _appsApi = null; _subscriptionsApi = null; _installedAppsApi = null; _deviceProfilesApi = null; } _disposedValue = true; } }
public IActionResult SelectRoom(RoomDocumentModel roomDocumentModel) { // 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: Get Room Documents RoomDocumentList documents = roomsApi.GetDocuments(accountId, roomDocumentModel.RoomId); RoomDocumentModel.Documents = documents.Documents; 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 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); string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID} try { //Step 3: Get Rooms RoomSummaryList rooms = roomsApi.GetRooms(accountId); RoomsListModel = new RoomsListModel { Rooms = rooms.Rooms.ToList() }; return(View("Eg03", this)); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
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")); } }
/// <summary> /// Gets the list of rooms /// </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 list of rooms</returns> public static RoomSummaryList GetRooms( 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); // Call the Rooms API to create a room return(roomsApi.GetRooms(accountId)); }
/// <summary> /// Gets the specified room's field data /// </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="roomId">The Id of a specified room</param> /// <returns>The specified room's field data</returns> public static FieldData Export( string basePath, string accessToken, string accountId, int roomId) { // Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}"); var roomsApi = new RoomsApi(apiClient); // Call the Rooms API to get room field data return(roomsApi.GetRoomFieldData(accountId, roomId)); }
/// <summary> /// Gets the list of Room Documents /// </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="roomId">The Id of a specified room</param> /// <returns>The list of Room Documents</returns> public static RoomDocumentList GetDocuments( string basePath, string accessToken, string accountId, int?roomId) { // Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken); var roomsApi = new RoomsApi(apiClient); // Call the Rooms API to get Room Documents return(roomsApi.GetDocuments(accountId, roomId)); }
/// <summary> /// Adds form to specified room /// </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="roomId">The Id of a specified room</param> /// <param name="formId">The Id of a specified form</param> /// <returns>RoomDocument</returns> public static RoomDocument AddForm( string basePath, string accessToken, string accountId, int roomId, Guid formId) { // Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}"); var roomsApi = new RoomsApi(apiClient); // Call the Rooms API to get room field data return(roomsApi.AddFormToRoom(accountId, roomId, new FormForAdd(formId))); }
public SmartThingsClient(string accessToken) { var configuration = new Configuration(); configuration.AccessToken = accessToken ?? throw new ArgumentNullException(accessToken); //configuration.BasePath = "https://graph-eu01-euwest1.api.smartthings.com/v1"; _devicesApi = new DevicesApi(configuration); _locationsApi = new LocationsApi(configuration); _roomsApi = new RoomsApi(configuration); _scenesApi = new ScenesApi(configuration); _rulesApi = new RulesApi(configuration); _schedulesApi = new SchedulesApi(configuration); _appsApi = new AppsApi(configuration); _subscriptionsApi = new SubscriptionsApi(configuration); _installedAppsApi = new InstalledAppsApi(configuration); _deviceProfilesApi = new DeviceProfilesApi(configuration); }
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")); } }
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")); } }
/// <summary> /// Gets the list of rooms by filter /// </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="fieldDataChangedStartDate">The start date</param> /// <param name="fieldDataChangedEndDate">The end date</param> /// <returns>The filtered room summary list</returns> public static RoomSummaryList GetRooms( string basePath, string accessToken, string accountId, string fieldDataChangedStartDate, string fieldDataChangedEndDate) { // Construct your API headers var apiClient = new ApiClient(basePath); apiClient.Configuration.DefaultHeader.Add("Authorization", $"Bearer {accessToken}"); var roomsApi = new RoomsApi(apiClient); // Call the Rooms API to get room field data var rooms = roomsApi.GetRooms(accountId, new RoomsApi.GetRoomsOptions { fieldDataChangedStartDate = fieldDataChangedStartDate, fieldDataChangedEndDate = fieldDataChangedEndDate }); return(rooms); }
public ActionResult ExportData(RoomDocumentModel roomDocumentModel) { // 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 externalFormFillSessionsApi = new ExternalFormFillSessionsApi(apiClient); string accountId = RequestItemsService.Session.AccountId; // Represents your {ACCOUNT_ID} try { // Step 3: Call the Rooms API to create external form fill session ExternalFormFillSession url = externalFormFillSessionsApi.CreateExternalFormFillSession( accountId, new ExternalFormFillSessionForCreate(roomDocumentModel.DocumentId.ToString(), roomDocumentModel.RoomId)); ViewBag.h1 = "External form fill sessions was successfully created"; ViewBag.message = $"To fill the form, navigate following URL: <a href='{url.Url}' target='_blank'>Fill the form</a>"; ViewBag.Locals.Json = JsonConvert.SerializeObject(url, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }
public ActionResult ExportData(RoomFormModel roomFormModel) { // 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: Call the Rooms API to add form to a room RoomDocument roomDocument = roomsApi.AddFormToRoom( accountId, roomFormModel.RoomId, new FormForAdd(roomFormModel.FormId)); ViewBag.h1 = "The form was successfully added to a room"; ViewBag.message = $"Results from the Rooms: AddFormToRoom method. RoomId: {roomFormModel.RoomId}, FormId: {roomFormModel.FormId} :"; ViewBag.Locals.Json = JsonConvert.SerializeObject(roomDocument, Formatting.Indented); return(View("example_done")); } catch (ApiException apiException) { ViewBag.errorCode = apiException.ErrorCode; ViewBag.errorMessage = apiException.Message; return(View("Error")); } }