/// <summary> /// API User sign up. Use for the identification of the mobile applications users. The request can contain all, some or none of the optional parameters. /// Login, email, facebook ID, twitter ID and the external user ID should not be taken previously. /// If you want to create a user with a some content (f.e. with a photo) you have to create a blob firstly. /// The same tags can be used for any number of users. /// </summary> /// <returns></returns> public async Task <HttpResponse <UserResponse> > SignUpUserAsync(UserSignUpRequest userSignUpRequest) { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.PostAsync <UserResponse, UserSignUpRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.UsersMethod, userSignUpRequest, headers)); }
/// <summary> /// Updates the user by Id (generic). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="userId">The user identifier.</param> /// <param name="userRequest">The user request.</param> /// <returns></returns> public async Task <HttpResponse <UserResponse> > UpdateUserAsync <T>(Int32 userId, UpdateUserRequest <T> userRequest) where T : UserRequest { var uriMethod = string.Format(QuickbloxMethods.UpdateUserMethod, userId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.PutAsync <UserResponse, UpdateUserRequest <T> >(this.quickbloxClient.ApiEndPoint, uriMethod, userRequest, headers)); }
/// <summary> /// Delete API User by external user id /// </summary> /// <param name="userId">The user identifier.</param> /// <returns></returns> public async Task <HttpResponse> DeleteUserByExternalUserIdAsync(Int32 userId) { var uriMethod = String.Format(QuickbloxMethods.DeleteUserByExternalUserMethod, userId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.DeleteAsync <Object>(this.quickbloxClient.ApiEndPoint, uriMethod, headers)); }
/// <summary> /// Returns all dialogs associated with current user /// </summary> /// <param name="retrieveDialogsRequest">Retrieve dialogs request info</param> /// <returns></returns> public async Task <HttpResponse <RetrieveDialogsResponse> > GetDialogsAsync(RetrieveDialogsRequest retrieveDialogsRequest = null) { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <RetrieveDialogsResponse, RetrieveDialogsRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetDialogsMethod, retrieveDialogsRequest, headers)); }
/// <summary> /// Show API User by identifier (generic) /// </summary> /// <param name="userId">The user identifier.</param> /// <returns></returns> public async Task <HttpResponse <UserResponse <T> > > GetUserByIdAsync <T>(Int32 userId) where T : User { var uriBuilder = String.Format(QuickbloxMethods.GetUserMethod, userId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <UserResponse <T> >(this.quickbloxClient.ApiEndPoint, uriBuilder, headers)); }
/// <summary> /// Download File (Get File as a redirect to the S3 object) by Id. /// </summary> /// <param name="uploadId">UploadId</param> /// <returns>Success HTTP Status Code 301</returns> public async Task <HttpResponse <Byte[]> > DownloadFileById(int uploadId) { var uriMethod = String.Format(QuickbloxMethods.DownloadFileByIdMethod, uploadId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var downloadFileResponse = await HttpService.GetBytesAsync(this.quickbloxClient.ApiEndPoint, uriMethod, headers); return(downloadFileResponse); }
public async Task <HttpResponse <RetriveCustomObjectsResponce <T> > > CreateMultiCustomObjectsAsync <T>( String className, List <T> items) where T : BaseCustomObject { if (className == null) { throw new ArgumentNullException("className"); } if (items == null) { throw new ArgumentNullException("items"); } var requestUri = String.Format(QuickbloxMethods.CreateMultiCustomObjectMethod, className); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var nameValueCollection = new List <KeyValuePair <String, String> >(); for (int itemIndex = 0; itemIndex < items.Count; itemIndex++) { var properties = items[itemIndex].GetType().GetRuntimeProperties(); foreach (var property in properties.Where(p => p.GetCustomAttribute <JsonPropertyAttribute>() != null)) { var jsonProperty = property.GetCustomAttribute <JsonPropertyAttribute>(); var propertyValue = property.GetValue(items[itemIndex]); if (propertyValue != null) { if (property.PropertyType.GetTypeInfo().ImplementedInterfaces.Contains(typeof(IList))) { var propertyFields = propertyValue as IEnumerable; var enumerator = propertyFields.GetEnumerator(); StringBuilder stringBuilder = new StringBuilder(); while (enumerator.MoveNext()) { stringBuilder.Append(enumerator.Current + ","); } var pair = new KeyValuePair <string, string>(String.Format("record[{0}][{1}", itemIndex, jsonProperty.PropertyName), stringBuilder.ToString()); nameValueCollection.Add(pair); } else { var pair = new KeyValuePair <string, string>(String.Format("record[{0}][{1}", itemIndex, jsonProperty.PropertyName), property.GetValue(items[itemIndex]).ToString()); nameValueCollection.Add(pair); } } } } var createMultiCustomObjects = await HttpService.PostAsync <RetriveCustomObjectsResponce <T> >(this.quickbloxClient.ApiEndPoint, requestUri, nameValueCollection, headers); return(createMultiCustomObjects); }
/// <summary> /// Returns current session. /// </summary> /// <returns></returns> public async Task <HttpResponse <SessionResponse> > GetSessionAsync() { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var result = await HttpService.GetAsync <SessionResponse>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.SessionMethod, headers); return(result); }
/// <summary> /// Retrieve subscriptions for the device which is specified in the authorization token. /// </summary> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <GetSubscriptionResponse[]> > GetSubscriptionsAsync() { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var resultSubscriptionResponse = await HttpService.GetAsync <GetSubscriptionResponse[]>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.SubscriptionsMethod, headers); return(resultSubscriptionResponse); }
/// <summary> /// Deletes the event. /// </summary> /// <param name="eventId">The event identifier.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse> DeleteEventAsync(UInt32 eventId) { var uriMethod = String.Format(QuickbloxMethods.DeleteEventMethod, eventId); var resultSubscriptionResponse = await HttpService.DeleteAsync <Object>(this.quickbloxClient.ApiEndPoint, uriMethod, RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token)); return(resultSubscriptionResponse); }
/// <summary> /// Get list of files for the current user. The ID of the user is taken from the token specified in the request. /// </summary> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <FilesPagedResponse> > GetFilesAsync() { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var getFilesResponse = await HttpService.GetAsync <FilesPagedResponse>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetFilesMethod, headers); return(getFilesResponse); }
/// <summary> /// Retrieve all (by default) geodata for current application. The ID of the application is taken from the token which is specified in the request /// </summary> /// <param name="findGeoDataRequest"> /// Filters /// The request can contain all, some or none of these parameters.If this option is set, its value - the object to validate. /// Filters require an exact match property values with an instance of the corresponding parameter value. /// </param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <PagedResponse <GeoDatumWithUserResponse> > > FindGeoDataAsync(FindGeoDataRequest findGeoDataRequest) { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var getGeoDataResponse = await HttpService.GetAsync <PagedResponse <GeoDatumWithUserResponse>, FindGeoDataRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.FindGeoDataMethod, findGeoDataRequest, headers); return(getGeoDataResponse); }
/// <summary> /// Creates a new dialog. /// </summary> /// <param name="dialogName">Dialog name. Is ignored for Private dialogs.</param> /// <param name="dialogType">Dialog type</param> /// <param name="occupantsIds">Occupants IDs (in a string separated by comma)</param> /// <param name="photoId">Photo upload ID.</param> /// <returns></returns> public async Task <HttpResponse <Dialog> > CreateDialogAsync(string dialogName, DialogType dialogType, string occupantsIds, string photoId = null) { var createDialogRequest = new CreateDialogRequest { Type = (int)dialogType, Name = dialogName, OccupantsIds = occupantsIds, Photo = photoId }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.PostAsync <Dialog, CreateDialogRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.CreateDialogMethod, createDialogRequest, headers)); }
/// <summary> /// Get information about file by ID. /// </summary> /// <param name="fileId">The file identifier.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <FileInfoResponse> > GetFileInfoByIdAsync(Int32 fileId) { var uriMethod = String.Format(QuickbloxMethods.GetFileByIdMethod, fileId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var getFilesByIdResponse = await HttpService.GetAsync <FileInfoResponse>(this.quickbloxClient.ApiEndPoint, uriMethod, headers); return(getFilesByIdResponse); }
/// <summary> /// Сreate device based subscriptions. The authorization token should contain the device parameters. If the subscription is creating for the windows phone pushes make sure that Microsoft Push Notifications have a status "enabled" in the Web Administration Panel. /// </summary> /// <param name="createSubscriptionsRequest">Parameter for subscription request</param> /// <returns>Success HTTP Status Code 201</returns> public async Task <HttpResponse <CreateSubscriptionResponseItem[]> > CreateSubscriptionsAsync(CreateSubscriptionsRequest createSubscriptionsRequest) { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var resultSubscriptionResponse = await HttpService.PostAsync <CreateSubscriptionResponseItem[], CreateSubscriptionsRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.SubscriptionsMethod, createSubscriptionsRequest, headers); return(resultSubscriptionResponse); }
/// <summary> /// Maximum age of data that should remain in the database after a query. /// </summary> /// <param name="days">The days.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse> DeleteGeoDataByDays(Int32 days) { var uri = String.Format(QuickbloxMethods.DeleteGeoWithDaysDataMethod, days); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var getGeoDataResponse = await HttpService.DeleteAsync <Object>(this.quickbloxClient.ApiEndPoint, uri, headers); return(getGeoDataResponse); }
/// <summary> /// You can create or update geodata with sending a push notification to all users who is located in your radius. /// </summary> /// <param name="createGeoDataWithPushRequest">The create geo data with push request.</param> /// <returns>Success HTTP Status Code 201</returns> public async Task <HttpResponse <GeoDataResponse> > CreatePushGeoDataAsync(CreateGeoDataWithPushRequest createGeoDataWithPushRequest) { var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var createGeodataResponse = await HttpService.PostAsync <GeoDataResponse, CreateGeoDataWithPushRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.CreateGeoDataMethod, createGeoDataWithPushRequest, headers); return(createGeodataResponse); }
/// <summary> /// Delete file by ID. If there are some referents to the file the number of links will be reduced by 1 after deleting. A file will be deleted in fact when the number of links will be equal to 0. /// </summary> /// <param name="fileId">The file identifier.</param> /// <returns>HttpResponse</returns> public async Task <HttpResponse> DeleteFileAsync(Int32 fileId) { var uriMethod = String.Format(QuickbloxMethods.DeleteFileMethod, fileId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var deleteFileById = await HttpService.DeleteAsync <Object>(this.quickbloxClient.ApiEndPoint, uriMethod, headers); return(deleteFileById); }
/// <summary> /// Retrieve API User by Twitter identifier /// </summary> /// <param name="twitterId">API User Twitter ID</param> /// <returns></returns> public async Task <HttpResponse <UserResponse> > GetUserByTwitterIdAsync(Int32 twitterId) { var byTwitter = new UserRequest() { TwitterId = twitterId }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <UserResponse, UserRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetUserByTwitterIdMethod, byTwitter, headers)); }
/// <summary> /// Retrieve API User by email. /// </summary> /// <param name="email">API User email</param> /// <returns></returns> public async Task <HttpResponse <UserResponse> > GetUserByEmailAsync(String email) { var byEmail = new UserRequest() { Email = email }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <UserResponse, UserRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetUserByEmailMethod, byEmail, headers)); }
/// <summary> /// Gets the user by login. /// </summary> /// <param name="login">The login.</param> /// <returns></returns> public async Task <HttpResponse <UserResponse> > GetUserByLogin(String login) { var byLogin = new UserRequest() { Login = login }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <UserResponse, UserRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetUserByLoginMethod, byLogin, headers)); }
/// <summary> /// Retrieve geodata by the identifier /// </summary> /// <param name="geoDataId">The geo data identifier.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <GeoDatumWithUserResponse> > GetGeoDataByIdAsync(Int32 geoDataId) { var uri = String.Format(QuickbloxMethods.GetByIdGeoDataMethod, geoDataId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var getGeoDataResponse = await HttpService.GetAsync <GeoDatumWithUserResponse>(this.quickbloxClient.ApiEndPoint, uri, headers); return(getGeoDataResponse); }
/// <summary> /// Reset API User password by e-mail. /// </summary> /// <param name="email">API User e-mail.</param> /// <returns></returns> public async Task <HttpResponse> ResetUserPasswordByEmailAsync(String email) { var userRequest = new UserRequest() { Email = email }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <Object, UserRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.UserPasswordResetMethod, userRequest, headers)); }
/// <summary> /// Declaring file uploaded. Set file status to 'Complete'. If the specified file size does not match to the actual, the actual will be set. /// </summary> /// <param name="fileId">The file identifier.</param> /// <param name="blobUploadCompleteRequest">The BLOB upload complete request.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse> FileUploadCompleteAsync(Int32 fileId, BlobUploadCompleteRequest blobUploadCompleteRequest) { var uriMethod = String.Format(QuickbloxMethods.CompleteUploadByFileIdMethod, fileId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var fileUploadResponse = await HttpService.PutAsync <Object, BlobUploadCompleteRequest>(this.quickbloxClient.ApiEndPoint, uriMethod, blobUploadCompleteRequest, headers); return(fileUploadResponse); }
/// <summary> ///Update geodata /// </summary> /// <param name="geoDataId">The geo data identifier.</param> /// <param name="updateGeoDataRequest">The update geo data with push request.</param> /// <returns>Success HTTP Status Code 200</returns> public async Task <HttpResponse <GeoDatumResponse> > UpdateGeoDataAsync(Int32 geoDataId, UpdateGeoDataRequest updateGeoDataRequest) { var uri = String.Format(QuickbloxMethods.UpdateByIdGeoDataMethod, geoDataId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var updateGeoDataResponse = await HttpService.PutAsync <GeoDatumResponse, UpdateGeoDataRequest>(this.quickbloxClient.ApiEndPoint, uri, updateGeoDataRequest, headers); return(updateGeoDataResponse); }
/// <summary> /// Edit a file by ID. /// </summary> /// <param name="fileId">The file identifier.</param> /// <param name="updateFileByIdRequest">The update file request parameter.</param> /// <returns>FileInfoResponse</returns> public async Task <HttpResponse <FileInfoResponse> > EditFileByIdAsync(Int32 fileId, UpdateFileByIdRequest updateFileByIdRequest) { var uriMethod = String.Format(QuickbloxMethods.EditFileMethod, fileId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); var editFileById = await HttpService.PutAsync <FileInfoResponse, UpdateFileByIdRequest>(this.quickbloxClient.ApiEndPoint, uriMethod, updateFileByIdRequest, headers); return(editFileById); }
/// <summary> /// Updates a dialog. Works only if type=1(PUBLIC_GROUP) or 2(GROUP). /// Users who are in occupants_ids can update a dialog with type=2(GROUP). If type=1(PUBLIC_GROUP) - only dialog’s owner can update it. /// </summary> /// <param name="updateDialogRequest">Update dialog request info</param> /// <returns></returns> public async Task <HttpResponse <Dialog> > UpdateDialogAsync(UpdateDialogRequest updateDialogRequest) { if (updateDialogRequest == null) { throw new ArgumentNullException("updateDialogRequest"); } var uriMethod = String.Format(QuickbloxMethods.UpdateDialogMethod, updateDialogRequest.DialogId); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.PutAsync <Dialog, UpdateDialogRequest>(this.quickbloxClient.ApiEndPoint, uriMethod, updateDialogRequest, headers)); }
/// <summary> /// Gets the full name of the user by. /// </summary> /// <param name="fullName">API User full name</param> /// <param name="page">Page number of the book of the results that you want to get. By default: 1</param> /// <param name="perPage">The maximum number of results per page. Min: 1. Max: 100. By default: 10</param> /// <returns></returns> public async Task <HttpResponse <PagedResponse <UserResponse> > > GetUserByFullNameAsync(String fullName, UInt32?page, UInt32?perPage, CancellationToken token = default(CancellationToken)) { var byFullname = new UserRequest() { FullName = fullName, Page = page, PerPage = perPage }; var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.GetAsync <PagedResponse <UserResponse>, UserRequest>(this.quickbloxClient.ApiEndPoint, QuickbloxMethods.GetUserByFullMethod, byFullname, headers, token : token)); }
/// <summary> /// Returns account settings (account ID, endpoints, etc.) /// </summary> /// <param name="accountKey">Account key from admin panel</param> /// <returns>AccountResponse</returns> public async Task <HttpResponse <AccountResponse> > GetAccountSettingsAsync(string accountKey) { if (accountKey == null) { throw new ArgumentNullException("accountKey"); } var accountResponse = await HttpService.GetAsync <AccountResponse>(ApiEndPoint, QuickbloxMethods.AccountMethod, RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbAccountKey(accountKey)); return(accountResponse); }
/// <summary> /// Any user in the dialog’s occupant_ids is able to remove a Message from the dialog. The Message will only be removed for the current user - the Message will still be viewable and in the chat history for all other users in the dialog. /// </summary> /// <param name="messageIds"></param> /// <returns></returns> public async Task <HttpResponse <Object> > DeleteMessageAsync(String[] messageIds) { if (messageIds == null) { throw new ArgumentNullException("occupantIds"); } var uriMethod = String.Format(QuickbloxMethods.DeleteMessageMethod, String.Join(",", messageIds)); var headers = RequestHeadersBuilder.GetDefaultHeaders().GetHeaderWithQbToken(this.quickbloxClient.Token); return(await HttpService.DeleteAsync <Object>(this.quickbloxClient.ApiEndPoint, uriMethod, headers)); }