/// <summary>
        /// Gets a paginated list of items for the given canned list.
        /// </summary>
        /// <param name="listName">Name of the canned list.</param>
        /// <param name="pageNumber">Page number.</param>
        /// <param name="pageSize">Page size.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Paginated list of canned list items.</returns>
        public static async Task <PagedList <ListItem> > GetListItemsAsync(string listName, int pageNumber = 1, int pageSize = 20, ApiOptions options = null)
        {
            var request = new GetListContentRequest
            {
                Name       = listName,
                PageNumber = pageNumber,
                PageSize   = pageSize
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            var list = new PagedList <ListItem>()
            {
                PageNumber   = response.PagingInfo.PageNumber,
                PageSize     = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage  = async skip => await GetListItemsAsync(listName, pageSize, pageNumber + skip + 1, options)
            };

            list.AddRange(response.Items);
            return(list);
        }
Exemple #2
0
        public static async Task UpdateMembersAsync(string groupNameOrId, IEnumerable <string> userIdsToAdd, IEnumerable <string> userIdsToRemove, ApiOptions options = null)
        {
            var request = new UpdateGroupMembersRequest {
                Group = groupNameOrId
            };

            if (userIdsToAdd != null)
            {
                request.AddedUsers.AddRange(userIdsToAdd);
            }
            if (userIdsToRemove != null)
            {
                request.RemovedUsers.AddRange(userIdsToRemove);
            }
            if (request.AddedUsers.Count == 0 && request.RemovedUsers.Count == 0)
            {
                return;
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
        /// <summary>
        /// Gets a paginated list of APObjects matching the given freetext search expression.
        /// The provided expression is matched with the entire object instead of a particular field.
        /// </summary>
        /// <param name="type">The object type</param>
        /// <param name="freeTextExpression">Freetext expression.</param>
        /// <param name="fields">The specific object fields to be retrieved. </param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The object field on which the results should be sorted.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Paginated list of APObject objects matching the given search criteria.</returns>
        public async static Task <PagedList <APObject> > FreeTextSearchAsync(string type, string freeTextExpression, IEnumerable <string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            var request = new FreeTextSearchObjectsRequest()
            {
                Type = type,
                FreeTextExpression = freeTextExpression,
                PageNumber         = pageNumber,
                PageSize           = pageSize,
                OrderBy            = orderBy,
                SortOrder          = sortOrder
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            var objects = new PagedList <APObject>()
            {
                PageNumber   = response.PagingInfo.PageNumber,
                PageSize     = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage  = async skip => await FreeTextSearchAsync(type, freeTextExpression, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };

            objects.AddRange(response.Objects);
            return(objects);
        }
        /// <summary>
        /// Gets a paginated list of APObjects matching the given search criteria.
        /// </summary>
        /// <param name="type">The object type.</param>
        /// <param name="query">The search query for objects to be found.</param>
        /// <param name="fields">The object fields to be returned for the matching list of objects.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The object field on which the results should be sorted.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Paginated list of APObject objects matching the given search criteria.</returns>
        public async static Task <PagedList <APObject> > FindAllAsync(string type, IQuery query = null, IEnumerable <string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            query = query ?? Query.None;
            var request = new FindAllObjectsRequest()
            {
                Type       = type,
                Query      = query.AsString().Escape(),
                PageNumber = pageNumber,
                PageSize   = pageSize,
                OrderBy    = orderBy,
                SortOrder  = sortOrder
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            var objects = new PagedList <APObject>()
            {
                PageNumber   = response.PagingInfo.PageNumber,
                PageSize     = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage  = async skip => await FindAllAsync(type, query, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };

            objects.AddRange(response.Objects);
            return(objects);
        }
        protected override async Task <Entity> UpdateAsync(IDictionary <string, object> propertyUpdates, IDictionary <string, string> attributeUpdates, IEnumerable <string> addedTags, IEnumerable <string> removedTags, int specificRevision, ApiOptions options, bool forceUpdate)
        {
            var request = new UpdateUserRequest()
            {
                Revision = specificRevision,
                Id       = this.Id
            };

            ApiOptions.Apply(request, options);
            if (propertyUpdates != null && propertyUpdates.Count > 0)
            {
                propertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value);
            }
            if (attributeUpdates != null && attributeUpdates.Count > 0)
            {
                attributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value);
            }

            if (addedTags != null)
            {
                request.AddedTags.AddRange(addedTags);
            }
            if (removedTags != null)
            {
                request.RemovedTags.AddRange(removedTags);
            }

            // Check if acls are to be added
            request.AllowClaims.AddRange(this.Acl.Allowed);
            request.DenyClaims.AddRange(this.Acl.Denied);
            request.ResetClaims.AddRange(this.Acl.Reset);

            // Check if an update is needed.
            if (request.PropertyUpdates.Count == 0 &&
                request.AttributeUpdates.Count == 0 &&
                request.AddedTags.Count == 0 &&
                request.RemovedTags.Count == 0 &&
                request.AllowClaims.Count == 0 &&
                request.DenyClaims.Count == 0 &&
                request.ResetClaims.Count == 0 &&
                forceUpdate == false)
            {
                return(null);
            }

            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }

            // 3. Update the last known state based on the differences
            Debug.Assert(response.User != null, "If status is successful, then updated user should not be null.");
            return(response.User);
        }
Exemple #6
0
        /// <summary>
        /// Returns a limited time validity download url for the file associated with this FileDownload object.
        /// </summary>
        /// <param name="expiryTimeInMinutes">The validity interval for the download url (in minutes)."</param>
        /// <param name="cacheControlMaxAgeInSeconds">The value to be returned in the cache-control header for the file.</param>
        /// <returns>Download url.</returns>
        public async Task <string> GetDownloadUrlAsync(int expiryTimeInMinutes = 5, long cacheControlMaxAgeInSeconds = 2592000)
        {
            var request = new GetDownloadUrlRequest
            {
                FileName           = this.FileName,
                ExpiryInMinutes    = expiryTimeInMinutes,
                CacheControlMaxAge = cacheControlMaxAgeInSeconds
            };

            ApiOptions.Apply(request, this.Options);
            var response = await request.ExecuteAsync();

            return(response.Url);
        }
        /// <summary>
        /// Deletes multiple APConnection objects by id list.
        /// </summary>
        /// <param name="type">The type (relation name) of the connection.</param>
        /// <param name="connectionIds">Array of ids corresponding to the APConnection objects to be deleted.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public async static Task MultiDeleteAsync(string type, ApiOptions options, params string[] connectionIds)
        {
            var request = new BulkDeleteConnectionRequest {
                Type = type, ConnectionIds = new List <string>(connectionIds)
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
Exemple #8
0
        /// <summary>
        /// Gets a limited time valid url on which a file can be uploaded via HTTP.
        /// </summary>
        /// <param name="expiryInMinutes">Expiry duration in minutes for the upload url. The generated url will not allow uploads after this duration is over.</param>
        /// <returns>The generated upload url for this file.</returns>
        public async Task <FileUrl> GetUploadUrlAsync(int expiryInMinutes = 5)
        {
            var request = new GetUploadUrlRequest
            {
                MimeType        = this.MimeType,
                FileName        = this.FileName,
                ExpiryInMinutes = expiryInMinutes
            };

            ApiOptions.Apply(request, this.Options);
            var response = await request.ExecuteAsync();

            return(new FileUrl(response.Filename, response.Url));
        }
        public async Task <string> SendAsync(ApiOptions options = null)
        {
            var request = new SendPushNotificationRequest {
                Push = this
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            return(response.Id);
        }
Exemple #10
0
        /// <summary>
        /// Delets the device with the given id.
        /// </summary>
        /// <param name="id">Device id</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public async static Task DeleteAsync(string id, ApiOptions options = null)
        {
            var request = new DeleteDeviceRequest()
            {
                Id = id
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
Exemple #11
0
        /// <summary>
        /// Delete the user with the specified id
        /// </summary>
        /// <param name="id">Id of the user object to delete</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>Void</returns>
        public static async Task DeleteUserAsync(string id, bool deleteConnections = false, ApiOptions options = null)
        {
            var request = new DeleteUserRequest()
            {
                UserId = id, DeleteConnections = deleteConnections
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
Exemple #12
0
        /// <summary>
        /// Sends the given user an email to reset their account password.
        /// </summary>
        /// <param name="username">Username of the user.</param>
        /// <param name="emailSubject">Subject of the reset password email.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public static async Task InitiateResetPasswordAsync(string username, string emailSubject = null, ApiOptions options = null)
        {
            var request = new InitiateResetPasswordRequest
            {
                Username     = username,
                EmailSubject = emailSubject ?? "Reset your password"
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful != true)
            {
                throw response.Status.ToFault();
            }
        }
Exemple #13
0
        /// <summary>
        /// Executes the given graph query on the Appacitive platform.
        /// </summary>
        /// <param name="query">The name of the graph query</param>
        /// <param name="args">The parameters to be passed to the graph query</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The matching list of object ids returned by the graph query.</returns>
        public static async Task <List <string> > Query(string query, IDictionary <string, string> args = null, ApiOptions options = null)
        {
            var request = new GraphFilterRequest()
            {
                Query        = query,
                Placeholders = args
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            return(response.Ids ?? new List <string>());
        }
        public async Task DecrementAsync(string property, uint decrement, ApiOptions options = null)
        {
            var request = new AtomicCountersRequest {
                Type = this.Type, Id = this.Id, DecrementBy = decrement, Property = property
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            var newValue = response.Object.Get <string>(property);

            this.Set <string>(property, newValue, true);
        }
Exemple #15
0
        /// <summary>
        /// Changes the password for the given user with the new password.
        /// </summary>
        /// <param name="userId">Id for the user account.</param>
        /// <param name="oldPassword">Old password for the account.</param>
        /// <param name="newPassword">New password for the account.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public static async Task ChangePasswordByIdAsync(string userId, string oldPassword, string newPassword, ApiOptions options = null)
        {
            var request = new ChangePasswordRequest
            {
                UserId      = userId,
                OldPassword = oldPassword,
                NewPassword = newPassword,
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
Exemple #16
0
        /// <summary>
        /// Executes the specified graph api.
        /// </summary>
        /// <param name="apiName">The name of the graph api.</param>
        /// <param name="ids">The list of ids to be passed to the graph api.</param>
        /// <param name="args">List of arguments to be passed to the graph api.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The graph response object.</returns>
        public static async Task <List <GraphNode> > Select(string apiName, IEnumerable <string> ids, IDictionary <string, string> args = null, ApiOptions options = null)
        {
            var request = new GraphProjectRequest
            {
                Query        = apiName,
                Ids          = ids.ToList(),
                Placeholders = args
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            return(response.Nodes);
        }
        public async Task RemoveItemsAsync <T>(string property, ApiOptions options, params T[] values)
        {
            var request = new UpdateListItemsRequest {
                Type = this.Type, Id = this.Id, Property = property
            };

            ApiOptions.Apply(request, options);
            request.ItemsToRemove.AddRange(values.Where(x => x != null).Select(x => x.ToString()));
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            var updated = response.Object.GetList <T>(property);

            this.SetList(property, updated, true);
        }
        /// <summary>
        /// Gets an existing APConnection by type and id.
        /// </summary>
        /// <param name="type">The type (relation name) of the connection.</param>
        /// <param name="id">The id of the connection.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The matching APConnection object.</returns>
        public async static Task <APConnection> GetAsync(string relation, string id, ApiOptions options = null)
        {
            var request = new GetConnectionRequest {
                Relation = relation, Id = id
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            else
            {
                return(response.Connection);
            }
        }
        protected override async Task <Entity> CreateNewAsync(ApiOptions options)
        {
            var request = new CreateUserRequest()
            {
                User = this
            };

            ApiOptions.Apply(request, options);
            // Create a new object
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }

            // 3. Update the last known state based on the differences
            Debug.Assert(response.User != null, "If status is successful, then created user should not be null.");
            return(response.User);
        }
Exemple #20
0
        /// <summary>
        /// Gets an existing user by user session token.
        /// </summary>
        /// <param name="token">User session token.</param>
        /// <param name="fields">The user fields to be retrieved.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public static async Task <APUser> GetUserByTokenAsync(string token, IEnumerable <string> fields = null, ApiOptions options = null)
        {
            var request = new GetUserRequest {
                UserIdType = "token", UserToken = token
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            Debug.Assert(response.User != null, "For a successful get call, object should always be returned.");
            return(response.User);
        }
        /// <summary>
        /// Gets a paginated list of APObjects connected to this object via connections of the given type.
        /// </summary>
        /// <param name="connectionType">The type (relation name) of the connection.</param>
        /// <param name="query">Search query to further filter the list of connection objects.</param>
        /// <param name="label">Label of the endpoint to be queried. This is mandatory when the connection type being queried has endpoints with the same type but different labels.</param>
        /// <param name="fields">The fields to be returned for the matching objects.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">The page size.</param>
        /// <param name="orderBy">The field on which to sort the results.</param>
        /// <param name="sortOrder">The sort order - Ascending or Descending.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>A paginated list of APObjects.</returns>
        public async Task <PagedList <APObject> > GetConnectedObjectsAsync(string connectionType, string query = null, string label = null, IEnumerable <string> fields = null, int pageNumber = 1, int pageSize = 20, string orderBy = null, SortOrder sortOrder = SortOrder.Descending, ApiOptions options = null)
        {
            var request = new FindConnectedObjectsRequest
            {
                Relation   = connectionType,
                ObjectId   = this.Id,
                Object     = this,
                Label      = label,
                Query      = query,
                Type       = this.Type,
                ReturnEdge = false,
                PageNumber = pageNumber,
                PageSize   = pageSize,
                SortOrder  = sortOrder,
                OrderBy    = orderBy
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }

            IEnumerable <APObject> objects = response.Nodes.Select(n => n.Object);
            var list = new PagedList <APObject>()
            {
                PageNumber   = response.PagingInfo.PageNumber,
                PageSize     = response.PagingInfo.PageSize,
                TotalRecords = response.PagingInfo.TotalRecords,
                GetNextPage  = async skip => await this.GetConnectedObjectsAsync(connectionType, query, label, fields, pageNumber + skip + 1, pageSize, orderBy, sortOrder, options)
            };

            list.AddRange(objects);
            return(list);
        }
        /// <summary>
        /// Gets an existing APObject by type and id.
        /// </summary>
        /// <param name="type">Object type (schema name).</param>
        /// <param name="id">Object id.</param>
        /// <param name="fields">The object fields to be retrieved.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The matching APObject instance.</returns>
        public async static Task <APObject> GetAsync(string type, string id, IEnumerable <string> fields = null, ApiOptions options = null)
        {
            var request = new GetObjectRequest()
            {
                Id = id, Type = type,
            };

            if (fields != null)
            {
                request.Fields.AddRange(fields);
            }
            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            Debug.Assert(response.Object != null, "For a successful get call, object should always be returned.");
            return(response.Object);
        }
        public async Task <List <FriendInfo> > GetFriendsAsync(string socialNetwork, ApiOptions options = null)
        {
            if (string.IsNullOrWhiteSpace(socialNetwork) == true)
            {
                throw new AppacitiveRuntimeException("Social network cannot be null or empty.");
            }
            var request = new GetFriendsRequest
            {
                UserId        = this.Id,
                SocialNetwork = socialNetwork
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            return(response.Friends);
        }
        /// <summary>
        /// Gets an existing APConnection by its endpoints and type.
        /// </summary>
        /// <param name="type">Type of the connection.</param>
        /// <param name="endpointObjectId1">Id of the object for endpoint 1.</param>
        /// <param name="endpointObjectId2">Id of the object for endpoint 2.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        /// <returns>The matching APConnection object.</returns>
        public async static Task <APConnection> GetAsync(string type, string endpointObjectId1, string endpointObjectId2, ApiOptions options = null)
        {
            var request = new GetConnectionByEndpointRequest
            {
                Relation  = type,
                ObjectId1 = endpointObjectId1,
                ObjectId2 = endpointObjectId2
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            else
            {
                return(response.Connection);
            }
        }
Exemple #25
0
        /// <summary>
        /// Changes the password for the logged in user with the new password.
        /// </summary>
        /// <param name="oldPassword">Old password for the account.</param>
        /// <param name="newPassword">New password for the account.</param>
        /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
        public static async Task ChangePasswordAsync(string oldPassword, string newPassword, ApiOptions options = null)
        {
            if (InternalApp.Current.CurrentUser.IsLoggedIn == false)
            {
                throw new AppacitiveRuntimeException("Cannot change password for current user as no user is logged in.");
            }
            var request = new ChangePasswordRequest
            {
                UserId      = "me",
                OldPassword = oldPassword,
                NewPassword = newPassword,
                IdType      = "token"
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
        }
        protected async override Task <Entity> CreateNewAsync(ApiOptions options)
        {
            // Handling for special case when endpoint contains a new object or device.
            // Since these cannot be created on the fly when creating a new connection.
            var endpoints = this.Endpoints.ToArray();

            for (int i = 0; i < endpoints.Length; i++)
            {
                if (endpoints[i].CreateEndpoint == false)
                {
                    continue;
                }
                if (endpoints[i].Content.Type.Equals("user", StringComparison.OrdinalIgnoreCase) == true ||
                    endpoints[i].Content.Type.Equals("device", StringComparison.OrdinalIgnoreCase) == true)
                {
                    // Create the object
                    await endpoints[i].Content.SaveAsync(options: options);
                    // Update endpoint object ids
                    endpoints[i].ObjectId = endpoints[i].Content.Id;
                }
            }

            // Create a new object
            var request = new CreateConnectionRequest()
            {
                Connection = this
            };

            ApiOptions.Apply(request, options);
            var response = await request.ExecuteAsync();

            if (response.Status.IsSuccessful == false)
            {
                throw response.Status.ToFault();
            }
            Debug.Assert(response.Connection != null, "If status is successful, then created connection should not be null.");
            return(response.Connection);
        }