/// <summary>
        /// Creates a VaultApi helper object which will make HTTP API calls using the provided client application/developer credentials.
        /// (OAuth2 protocol Client Credentials Grant Type), allows a user to provide an existing token
        /// </summary>m>
        public VaultApi(IClientSecrets clientSecrets, Tokens tokens)
        {
            if (!string.IsNullOrEmpty(tokens.AccessToken))
            {
                this.ApiTokens = tokens;
                this.ClientSecrets = clientSecrets;

                this.REST = new RestManager(this);
                this.DocumentViewer = new DocumentViewerManager(this);
                this.Sites = new SitesManager(this);
                this.ScheduledProcess = new ScheduledProcessManager(this);
                this.CurrentUser = new CurrentUserManager(this);
                this.Users = new UsersManager(this);
                this.Groups = new GroupsManager(this);
                this.Folders = new FoldersManager(this);
                this.Files = new FilesManager(this);
                this.FormInstances = new FormInstancesManager(this);
                this.FormTemplates = new FormTemplatesManager(this);
                this.Documents = new DocumentsManager(this);
                this.IndexFields = new IndexFieldManager(this);
                this.Files = new FilesManager(this);
                this.CustomQueryManager = new CustomQueryManager(this);
                this.DocumentShares = new DocumentShareManager(this);

                this.Meta = new MetaManager(this);
                this.PersistedData = new PersistedData.PersistedDataManager(this);
                this.Customer = new CustomerManager(this);
                this.Version = new VersionManager(this);
            }
        }
        internal void Populate(JToken meta, JToken data, ClientSecrets clientSecrets, Tokens apiTokens)
        {
            this.Populate(clientSecrets, apiTokens);

            //Now populate the meta
            try
            {
                this.Meta = meta.ToObject<ApiMetaData>();
            }
            catch (Exception ex)
            {
                LogEventManager.Error("Error deserializing the Meta node.", ex);
                this.Meta = new ApiMetaData();
                this.Meta.ErrorMessages.Add(new ApiErrorMessage { DeveloperMessage = ex.Message });
                this.Meta.StatusCode = HttpStatusCode.BadRequest;
            }

            if (data != null)
            {
                this.PopulateData(data);
            }
        }
        internal void PopulateAccessToken(ClientSecrets clientSecrets, Tokens apiTokens)
        {
            base.Populate(clientSecrets, apiTokens);

            this.SessionPopulated();
        }
 /// <summary>
 /// Populates the token
 /// </summary>
 /// <param name="clientSecrets"></param>
 /// <param name="apiTokens"> </param>
 internal void Populate(ClientSecrets clientSecrets, Tokens apiTokens)
 {
     this.ClientSecrets = clientSecrets;
     this.ApiTokens = apiTokens;
 }