public async Task <FileResponse> CreateFileAsync(string container, string filepath, string content, bool checkExists = true) { if (container == null) { throw new ArgumentNullException("container"); } if (filepath == null) { throw new ArgumentNullException("filepath"); } if (content == null) { throw new ArgumentNullException("content"); } IHttpAddress address = baseAddress.WithResource(container, filepath).WithParameter("check_exist", checkExists); IHttpRequest request = new HttpRequest(HttpMethod.Post, address.Build(), baseHeaders.Exclude(HttpHeaders.ContentTypeHeader), content); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var data = new { file = new List <FileResponse>() }; return(contentSerializer.Deserialize(response.Body, data).file.First()); }
public async Task <IEnumerable <string> > GetCustomSettingsAsync() { var address = baseAddress.WithResource(CustomResource); IHttpRequest request = new HttpRequest(HttpMethod.Get, address.Build(), baseHeaders); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); Dictionary <string, object> settings = new Dictionary <string, object>(); return(contentSerializer.Deserialize(response.Body, settings).Keys); }
public async Task <byte[]> DownloadApplicationPackageAsync(int applicationId, bool includeFiles, bool includeServices, bool includeSchema) { IHttpAddress address = baseAddress .WithResource("app", applicationId.ToString(CultureInfo.InvariantCulture)) .WithParameter("pkg", true) .WithParameter("include_files", includeFiles) .WithParameter("include_services", includeServices) .WithParameter("include_schema", includeSchema); IHttpRequest request = new HttpRequest(HttpMethod.Get, address.Build(), baseHeaders); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); return(response.RawBody); }
public async Task <bool> RegisterAsync(Register register, bool login = false) { if (register == null) { throw new ArgumentNullException("register"); } var address = baseAddress.WithResource("register"); if (login) { address = address.WithParameter("login", true); } string content = contentSerializer.Serialize(register); IHttpRequest request = new HttpRequest(HttpMethod.Post, address.Build(), baseHeaders, content); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var success = new { success = false }; success = contentSerializer.Deserialize(response.Body, success); if (success.success && login) { Session session = await GetSessionAsync(); baseHeaders.AddOrUpdate(HttpHeaders.DreamFactorySessionTokenHeader, session.session_id); } return(success.success); }
public async Task <IEnumerable <TableInfo> > GetAccessComponentsAsync() { IHttpRequest request = new HttpRequest(HttpMethod.Get, baseAddress.Build(), baseHeaders); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var resource = new { resource = new List <TableInfo>() }; return(contentSerializer.Deserialize(response.Body, resource).resource); }
public async Task <int> SendEmailAsync(EmailRequest emailRequest) { if (emailRequest == null) { throw new ArgumentNullException("emailRequest"); } string content = contentSerializer.Serialize(emailRequest); IHttpRequest request = new HttpRequest(HttpMethod.Post, baseAddress.Build(), baseHeaders, content); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var emailsSent = new { count = 0 }; return(contentSerializer.Deserialize(response.Body, emailsSent).count); }