public void List_Set_And_Create_Transaction_Types() { // first, let's try using the API to see what it already knows about transaction types var @default = _systemConfigurationApi.ListConfigurationTransactionTypes(); // it should know about a single, simple Buy transaction var buy = @default.TransactionConfigs.Single(c => c.Aliases.Any(a => a.Type == "Buy")); // now let's create an alternative Buy, and add it to the default configuration // (for reference -- this isn't a complete, sensible transaction definition) var newBuy = new TransactionConfigurationDataRequest( aliases: new List <TransactionConfigurationTypeAlias> { new TransactionConfigurationTypeAlias("NewBuy", "Description", "Class", "Group", 0) }, movements: new List <TransactionConfigurationMovementDataRequest>() { new TransactionConfigurationMovementDataRequest(MovementTypesEnum.Commitment, SideEnum.Side1, 1, null, null) } ); _systemConfigurationApi.CreateConfigurationTransactionType(newBuy); // there should be one more entry in the updated configuration var updated = _systemConfigurationApi.ListConfigurationTransactionTypes(); Assert.That(updated.TransactionConfigs.Count() - @default.TransactionConfigs.Count(), Is.EqualTo(1)); // now let's use our Buy, and replace the default configuration // REALISE THAT THIS IS A DESTRUCTIVE OPERATION -- you can't trivially recover the original defaults // unless you have them stored down -- we'll restore them afterwards var request = new TransactionSetConfigurationDataRequest(new [] { newBuy }.ToList()); _systemConfigurationApi.SetConfigurationTransactionTypes(request); updated = _systemConfigurationApi.ListConfigurationTransactionTypes(); // there should be one entry in the updated configuration Assert.That(updated.TransactionConfigs.Count(), Is.EqualTo(1)); // finally, let's restore our original default configurations var defaultRequest = @default.ConvertToRequest(); _systemConfigurationApi.SetConfigurationTransactionTypes(defaultRequest); updated = _systemConfigurationApi.ListConfigurationTransactionTypes(); // and confirm that the count of transaction configurations is the same Assert.That(updated.TransactionConfigs.Count(), Is.EqualTo(@default.TransactionConfigs.Count())); }
/// <summary> /// [EARLY ACCESS] CreateConfigurationTransactionType: Create transaction type Create a new transaction type by specifying a definition and mappings to movements. /// </summary> /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="transactionConfigurationDataRequest">A transaction type definition. (optional)</param> /// <param name="cancellationToken">Cancellation Token to cancel the request.</param> /// <returns>Task of ApiResponse (TransactionSetConfigurationData)</returns> public async System.Threading.Tasks.Task <Lusid.Sdk.Client.ApiResponse <TransactionSetConfigurationData> > CreateConfigurationTransactionTypeWithHttpInfoAsync(TransactionConfigurationDataRequest transactionConfigurationDataRequest = default(TransactionConfigurationDataRequest), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Lusid.Sdk.Client.RequestOptions localVarRequestOptions = new Lusid.Sdk.Client.RequestOptions(); String[] _contentTypes = new String[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; // to determine the Accept header String[] _accepts = new String[] { "text/plain", "application/json", "text/json" }; var localVarContentType = Lusid.Sdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); if (localVarContentType != null) { localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); } var localVarAccept = Lusid.Sdk.Client.ClientUtils.SelectHeaderAccept(_accepts); if (localVarAccept != null) { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } localVarRequestOptions.Data = transactionConfigurationDataRequest; // authentication (oauth2) required // oauth required if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) { localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); } // set the LUSID header localVarRequestOptions.HeaderParameters.Add("X-LUSID-Sdk-Language", "C#"); localVarRequestOptions.HeaderParameters.Add("X-LUSID-Sdk-Version", "0.11.4385"); // make the HTTP request var localVarResponse = await this.AsynchronousClient.PostAsync <TransactionSetConfigurationData>("/api/systemconfiguration/transactions/type", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("CreateConfigurationTransactionType", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// [EARLY ACCESS] CreateConfigurationTransactionType: Create transaction type Create a new transaction type by specifying a definition and mappings to movements. /// </summary> /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="transactionConfigurationDataRequest">A transaction type definition. (optional)</param> /// <param name="cancellationToken">Cancellation Token to cancel the request.</param> /// <returns>Task of TransactionSetConfigurationData</returns> public async System.Threading.Tasks.Task <TransactionSetConfigurationData> CreateConfigurationTransactionTypeAsync(TransactionConfigurationDataRequest transactionConfigurationDataRequest = default(TransactionConfigurationDataRequest), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Lusid.Sdk.Client.ApiResponse <TransactionSetConfigurationData> localVarResponse = await CreateConfigurationTransactionTypeWithHttpInfoAsync(transactionConfigurationDataRequest, cancellationToken).ConfigureAwait(false); return(localVarResponse.Data); }
/// <summary> /// [EARLY ACCESS] CreateConfigurationTransactionType: Create transaction type Create a new transaction type by specifying a definition and mappings to movements. /// </summary> /// <exception cref="Lusid.Sdk.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="transactionConfigurationDataRequest">A transaction type definition. (optional)</param> /// <returns>TransactionSetConfigurationData</returns> public TransactionSetConfigurationData CreateConfigurationTransactionType(TransactionConfigurationDataRequest transactionConfigurationDataRequest = default(TransactionConfigurationDataRequest)) { Lusid.Sdk.Client.ApiResponse <TransactionSetConfigurationData> localVarResponse = CreateConfigurationTransactionTypeWithHttpInfo(transactionConfigurationDataRequest); return(localVarResponse.Data); }