/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> public void Get(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, Action<HttpStatusCode, AccountBudget> onComplete, Action<Uri, Exception> onError, string eTag = null) { MakeApiGetRequestDelegate(BuildUri(cf, financialYear), credentials, onComplete, onError, eTag); }
public ApiStreamRequestHandler(IApiConfiguration configuration, ICompanyFileCredentials credentials, OAuthTokens oauth = null) { _oauth = oauth; _configuration = configuration; _credentials = credentials; _helper = new ApiRequestHelper(); }
public void SetStandardHeaders(WebRequest request, IApiConfiguration configuration, ICompanyFileCredentials credentials, OAuthTokens oauth = null) { request.Headers[HttpRequestHeader.Authorization] = string.Format("Bearer {0}", oauth.Maybe(_ => _.AccessToken, string.Empty)); request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip"; request.Headers["x-myobapi-key"] = configuration.ClientId; request.Headers["x-myobapi-version"] = "v2"; request.Headers["x-myobapi-cftoken"] = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", credentials.Maybe(_ => _.Username).Maybe(_ => _, string.Empty), credentials.Maybe(_ => _.Password).Maybe(_ => _, string.Empty)))); }
public void Initialise(IApiConfiguration configuration, CompanyFile companyFile, ICompanyFileCredentials credentials, IOAuthKeyService oAuthKeyService) { // Add any initialization after the InitializeComponent() call. MyConfiguration = configuration; MyCompanyFile = companyFile; MyCredentials = credentials; MyOAuthKeyService = oAuthKeyService; Text = string.Format("{0} - {1}", companyFile.Name, companyFile.Uri); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <returns></returns> public string Update(CompanyFile cf, AccountBudget entity, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); return MakeApiPutRequestSync( BuildUri(cf, entity.FinancialYear, extraQueryString: queryString), entity, credentials); }
/// <summary> /// Delete a Spend Money Attachment /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="spendMoneyUid">UID of the Spend Money</param> /// <param name="attachmentUid">UID of the Attachment to Delete</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel">Treat warnings as errors</param> public void Delete(CompanyFile cf, Guid spendMoneyUid, Guid attachmentUid, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = GenerateQueryString(errorLevel); MakeApiDeleteRequestSync(BuildUri(cf, spendMoneyUid, attachmentUid, queryString), credentials); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task<AccountBudget> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, CancellationToken cancellationToken, string eTag = null) { return this.MakeApiGetRequestAsync<AccountBudget>(ValidateUri(cf, uri), credentials, cancellationToken, eTag); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void GetRange(CompanyFile cf, string queryString, ICompanyFileCredentials credentials, Action<HttpStatusCode, PagedCollection<Timesheet>> onComplete, Action<Uri, Exception> onError) { MakeApiGetRequestDelegate(BuildUri(cf, null, queryString == null ? null : "?" + queryString.TrimStart(new[] { '?' })), credentials, onComplete, onError, null); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <returns></returns> public string Update(CompanyFile cf, Timesheet entity, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); return MakeApiPutRequestSync(BuildUri(cf, entity.Employee == null ? (Guid?)null : entity.Employee.UID, extraQueryString:queryString), entity, credentials); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<AccountBudget> GetAsync(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, CancellationToken cancellationToken, string eTag = null) { return this.MakeApiGetRequestAsync<AccountBudget>( this.BuildUri(cf, financialYear), credentials, cancellationToken, eTag); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> public void Get(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, Action <HttpStatusCode, AccountBudget> onComplete, Action <Uri, Exception> onError, string eTag = null) { MakeApiGetRequestDelegate(ValidateUri(cf, uri), credentials, onComplete, onError, eTag); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public AccountBudget Get(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, string eTag = null) { return(MakeApiGetRequestSync <AccountBudget>(BuildUri(cf, financialYear), credentials, null, eTag)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task <AccountBudget> GetAsync(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, string eTag = null) { return(this.GetAsync(cf, financialYear, credentials, CancellationToken.None)); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task <PagedCollection <AccountBudget> > GetRangeAsync(CompanyFile cf, string queryString, ICompanyFileCredentials credentials, string eTag = null) { return(this.GetRangeAsync(cf, queryString, credentials, CancellationToken.None)); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <returns></returns> public Task <string> UpdateAsync(CompanyFile cf, AccountBudget entity, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { return(this.UpdateAsync(cf, entity, credentials, CancellationToken.None, errorLevel)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task <AccountBudget> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, CancellationToken cancellationToken, string eTag = null) { return(this.MakeApiGetRequestAsync <AccountBudget>(ValidateUri(cf, uri), credentials, cancellationToken, eTag)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task <AccountBudget> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, string eTag = null) { return(this.GetAsync(cf, uri, credentials, CancellationToken.None, eTag)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public AccountBudget Get(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, string eTag = null) { return(MakeApiGetRequestSync <AccountBudget>(ValidateUri(cf, uri), credentials, null, eTag)); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> /// <param name="errorLevel"></param> public void Update(CompanyFile cf, AccountBudget entity, ICompanyFileCredentials credentials, Action<HttpStatusCode, string> onComplete, Action<Uri, Exception> onError, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); MakeApiPutRequestDelegate( BuildUri(cf, entity.FinancialYear, extraQueryString: queryString), entity, credentials, onComplete, onError); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task <AccountBudget> GetAsync(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, CancellationToken cancellationToken, string eTag = null) { return(this.MakeApiGetRequestAsync <AccountBudget>( this.BuildUri(cf, financialYear), credentials, cancellationToken, eTag)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public AccountBudget Get(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, string eTag = null) { return MakeApiGetRequestSync<AccountBudget>(BuildUri(cf, financialYear), credentials, null, eTag); }
/// <summary> /// Get a company file entry with the list of available resources /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void Get(CompanyFile cf, ICompanyFileCredentials credentials, Action <HttpStatusCode, CompanyFileWithResources> onComplete, Action <Uri, Exception> onError) { MakeApiGetRequestDelegate(cf.Uri, credentials, onComplete, onError, null); }
public CompanyFileWithResources Get(CompanyFile cf, ICompanyFileCredentials credentials) { return MakeApiGetRequestSync<CompanyFileWithResources>(cf.Uri, credentials); }
/// <summary> /// Get a company file entry with the list of available resources /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public CompanyFileWithResources Get(CompanyFile cf, ICompanyFileCredentials credentials) { return(MakeApiGetRequestSync <CompanyFileWithResources>(cf.Uri, credentials, null)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task<Timesheet> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials) { return this.GetAsync(cf, uri, credentials, CancellationToken.None); }
/// <summary> /// Get a company file entry with the list of available resources /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task <CompanyFileWithResources> GetAsync(CompanyFile cf, ICompanyFileCredentials credentials) { return(this.GetAsync(cf, credentials, CancellationToken.None)); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task<PagedCollection<Timesheet>> GetRangeAsync(CompanyFile cf, string queryString, ICompanyFileCredentials credentials) { return this.GetRangeAsync(cf, queryString, credentials, CancellationToken.None); }
/// <summary> /// Get a company file entry with the list of available resources /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task <CompanyFileWithResources> GetAsync(CompanyFile cf, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return(this.MakeApiGetRequestAsync <CompanyFileWithResources>(cf.Uri, credentials, cancellationToken, null)); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<string> UpdateAsync(CompanyFile cf, Timesheet entity, ICompanyFileCredentials credentials, CancellationToken cancellationToken, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); return this.MakeApiPutRequestAsync(this.BuildUri(cf, entity.Employee == null ? (Guid?)null : entity.Employee.UID, extraQueryString: queryString), entity, credentials, cancellationToken); }
/// <summary> /// Get the photo of a <see cref="Contact"/> resource /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void GetPhoto(CompanyFile cf, Guid uid, ICompanyFileCredentials credentials, Action<HttpStatusCode, byte[]> onComplete, Action<Uri, Exception> onError) { MakeApiGetRequestDelegate<Photo>(BuildUri(cf, uid, "/Photo"), credentials, (code, photo) => onComplete(code, photo.Maybe(_ => _.Data)), onError); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file reference that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public override CategoryRegister Get(Contracts.CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, string eTag = null) { throw new NotSupportedException(); }
/// <summary> /// Get the photo of a <see cref="Contact"/> resource /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public byte[] GetPhoto(CompanyFile cf, Guid uid, ICompanyFileCredentials credentials) { return MakeApiGetRequestSync<Photo>(BuildUri(cf, uid, "/Photo"), credentials).Maybe(_ => _.Data); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task<PagedCollection<AccountBudget>> GetRangeAsync(CompanyFile cf, string queryString, ICompanyFileCredentials credentials, string eTag = null) { return this.GetRangeAsync(cf, queryString, credentials, CancellationToken.None); }
/// <summary> /// Get the photo of a <see cref="Contact"/> resource /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task<byte[]> GetPhotoAsync(CompanyFile cf, Guid uid, ICompanyFileCredentials credentials) { return this.GetPhotoAsync(cf, uid, credentials, CancellationToken.None); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<string> UpdateAsync(CompanyFile cf, AccountBudget entity, ICompanyFileCredentials credentials, CancellationToken cancellationToken, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); return this.MakeApiPutRequestAsync( this.BuildUri(cf, entity.FinancialYear, extraQueryString: queryString), entity, credentials, cancellationToken); }
/// <summary> /// Get the photo of a <see cref="Contact"/> resource /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task<byte[]> GetPhotoAsync(CompanyFile cf, Guid uid, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { var res = await this.MakeApiGetRequestAsync<Photo>(this.BuildUri(cf, uid, "/Photo"), credentials, cancellationToken); return res.Maybe(_ => _.Data); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file reference that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public override Task <CategoryRegister> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, CancellationToken cancellationToken, string eTag = null) { return(Task.Factory.StartNew <CategoryRegister>(() => { throw new NotSupportedException(); })); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void Get(CompanyFile cf, Guid uid, DateTime? startDate, DateTime? endDate, ICompanyFileCredentials credentials, Action<HttpStatusCode, Timesheet> onComplete, Action<Uri, Exception> onError) { MakeApiGetRequestDelegate(BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials, onComplete, onError, null); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="financialYear">The requested financial year</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> /// <returns></returns> public Task<AccountBudget> GetAsync(CompanyFile cf, int financialYear, ICompanyFileCredentials credentials, string eTag = null) { return this.GetAsync(cf, financialYear, credentials, CancellationToken.None); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task<Timesheet> GetAsync(CompanyFile cf, Guid uid, DateTime? startDate, DateTime? endDate, ICompanyFileCredentials credentials) { return this.GetAsync(cf, uid, startDate, endDate, credentials, CancellationToken.None); }
public void Get(CompanyFile cf, ICompanyFileCredentials credentials, Action<HttpStatusCode, CompanyFileWithResources> onComplete, Action<Uri, Exception> onError) { MakeApiGetRequestAsync(cf.Uri, credentials, onComplete, onError); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void Get(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, Action<HttpStatusCode, Timesheet> onComplete, Action<Uri, Exception> onError) { MakeApiGetRequestDelegate(ValidateUri(cf, uri), credentials, onComplete, onError, null); }
/// <summary> /// Perform an operation and wait for the response /// </summary> /// <param name="cf">A reference to a company file</param> /// <param name="entity">The data to send</param> /// <param name="credentials">The company file credentials</param> /// <returns>The operation response</returns> public SaleEmailResponse Execute(CompanyFile cf, SaleEmail entity, ICompanyFileCredentials credentials) { return(MakeApiPostRequestSync <SaleEmail, SaleEmailResponse>(BuildUri(cf, entity), entity, credentials).Value); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file reference that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> /// <param name="eTag">The <see cref="BaseEntity.ETag" /> from a previously fetched entity</param> public override void Get(Contracts.CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, Action <System.Net.HttpStatusCode, CategoryRegister> onComplete, Action <Uri, Exception> onError, string eTag = null) { throw new NotSupportedException(); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Timesheet Get(CompanyFile cf, Guid uid, DateTime? startDate, DateTime? endDate, ICompanyFileCredentials credentials) { return MakeApiGetRequestSync<Timesheet>(BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials, null, null); }
/// <summary> /// Perform an operation and receive the response via an action /// </summary> /// <param name="cf">A reference to a company file</param> /// <param name="entity">The data to send</param> /// <param name="credentials">The company file credentials</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void Execute(CompanyFile cf, SaleEmail entity, ICompanyFileCredentials credentials, Action <HttpStatusCode, string, SaleEmailResponse> onComplete, Action <Uri, Exception> onError) { MakeApiPostRequestDelegate(BuildUri(cf, entity), entity, credentials, onComplete, onError); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<Timesheet> GetAsync(CompanyFile cf, Guid uid, DateTime? startDate, DateTime? endDate, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return this.MakeApiGetRequestAsync<Timesheet>(this.BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials, cancellationToken, null); }
/// <summary> /// Perform an asynchronous operation and await the response /// </summary> /// <param name="cf">A reference to a company file</param> /// <param name="entity">The data to send</param> /// <param name="credentials">The company file credentials</param> /// <returns>The operation response</returns> public Task <SaleEmailResponse> ExecuteAsync(CompanyFile cf, SaleEmail entity, ICompanyFileCredentials credentials) { return(this.ExecuteAsync(cf, entity, credentials, CancellationToken.None)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Timesheet Get(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials) { return MakeApiGetRequestSync<Timesheet>(ValidateUri(cf, uri), credentials, null, null); }
/// <summary> /// Perform an asynchronous operation and await the response /// </summary> /// <param name="cf">A reference to a company file</param> /// <param name="entity">The data to send</param> /// <param name="credentials">The company file credentials</param> /// <param name="cancellationToken"></param> /// <returns>The operation response</returns> public Task <SaleEmailResponse> ExecuteAsync(CompanyFile cf, SaleEmail entity, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return(this.MakeApiPostRequestAsync <SaleEmail, SaleEmailResponse>(this.BuildUri(cf, entity), entity, credentials, cancellationToken)); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uri">The uri of the entity to retrieve</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<Timesheet> GetAsync(CompanyFile cf, Uri uri, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return this.MakeApiGetRequestAsync<Timesheet>(ValidateUri(cf, uri), credentials, cancellationToken, null); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> public void Get(CompanyFile cf, Guid uid, DateTime?startDate, DateTime?endDate, ICompanyFileCredentials credentials, Action <HttpStatusCode, Timesheet> onComplete, Action <Uri, Exception> onError) { MakeApiGetRequestDelegate(BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials, onComplete, onError); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public PagedCollection<Timesheet> GetRange(CompanyFile cf, string queryString, ICompanyFileCredentials credentials) { return MakeApiGetRequestSync<PagedCollection<Timesheet>>(BuildUri(cf, null, queryString == null ? null : "?" + queryString.TrimStart(new[] { '?' })), credentials, null, null); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Timesheet Get(CompanyFile cf, Guid uid, DateTime?startDate, DateTime?endDate, ICompanyFileCredentials credentials) { return(MakeApiGetRequestSync <Timesheet>(BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials)); }
/// <summary> /// Retrieve a paged list of entities /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="queryString">An odata filter</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task<PagedCollection<Timesheet>> GetRangeAsync(CompanyFile cf, string queryString, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return this.MakeApiGetRequestAsync<PagedCollection<Timesheet>>(this.BuildUri(cf, null, queryString.Maybe(_ => "?" + _.TrimStart(new[] { '?' }))), credentials, cancellationToken, null); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <returns></returns> public Task <Timesheet> GetAsync(CompanyFile cf, Guid uid, DateTime?startDate, DateTime?endDate, ICompanyFileCredentials credentials) { return(this.GetAsync(cf, uid, startDate, endDate, credentials, CancellationToken.None)); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel"></param> /// <returns></returns> public Task<string> UpdateAsync(CompanyFile cf, Timesheet entity, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { return this.UpdateAsync(cf, entity, credentials, CancellationToken.None, errorLevel); }
/// <summary> /// Retrieve an entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="uid">The identifier of the entity to retrieve</param> /// <param name="startDate">Timesheet start date</param> /// <param name="endDate">Timesheet end date</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="cancellationToken"></param> /// <returns></returns> public Task <Timesheet> GetAsync(CompanyFile cf, Guid uid, DateTime?startDate, DateTime?endDate, ICompanyFileCredentials credentials, CancellationToken cancellationToken) { return(this.MakeApiGetRequestAsync <Timesheet>(this.BuildUri(cf, uid, startDate: startDate, endDate: endDate), credentials, cancellationToken)); }
/// <summary> /// Update an existing entity /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="entity">The entity to update</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="onComplete">The action to call when the operation is complete</param> /// <param name="onError">The action to call when the operation has an error</param> /// <param name="errorLevel"></param> public void Update(CompanyFile cf, Timesheet entity, ICompanyFileCredentials credentials, Action<HttpStatusCode, string> onComplete, Action<Uri, Exception> onError, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = QueryStringFromErrorLevel(errorLevel); MakeApiPutRequestDelegate(BuildUri(cf, entity.Employee == null ? (Guid?)null : entity.Employee.UID, extraQueryString: queryString), entity, credentials, onComplete, onError); }
/// <summary> /// Adds an Attachment to a Spend Money asynchronously /// </summary> /// <param name="cf">A company file that has been retrieved</param> /// <param name="spendMoneyUid">Guid of the Spend Money we're adding an Attachment to</param> /// <param name="entity">The request Object</param> /// <param name="credentials">The credentials to access the company file</param> /// <param name="errorLevel">Treat warnings as errors</param> /// <returns></returns> public Task <SpendMoneyAttachmentWrapper> InsertExAsync(CompanyFile cf, SpendMoneyAttachmentWrapper entity, Guid spendMoneyUid, ICompanyFileCredentials credentials, ErrorLevel errorLevel = ErrorLevel.IgnoreWarnings) { var queryString = GenerateQueryString(errorLevel, true); return(MakeApiPostRequestAsync <SpendMoneyAttachmentWrapper, SpendMoneyAttachmentWrapper>(BuildUri(cf, spendMoneyUid, null, queryString), entity, credentials)); }