public void UsersListShouldCallCorrectEndpoint() { var requestHandlerMock = ExecRequestMock<UsersResponse>("/users.list"); var subject = new UsersApi(requestHandlerMock.Object); var result = subject.List(); requestHandlerMock.Verify(); Assert.NotNull(result); }
public void UsersSetActiveShouldCallCorrectEndpoint() { var requestHandlerMock = ExecRequestMock<ResponseBase>("/users.setActive"); var subject = new UsersApi(requestHandlerMock.Object); var result = subject.SetActive(); requestHandlerMock.Verify(); Assert.NotNull(result); }
public void UsersGetPresenceShouldCallCorrectEndpoint() { var requestHandlerMock = PathAndExecRequestMock<PresenceResponse>("/users.getPresence?user=UID"); var subject = new UsersApi(requestHandlerMock.Object); var result = subject.GetPresence("UID"); requestHandlerMock.Verify(); Assert.NotNull(result); }
public void UsersInfoShouldCallCorrectEndpoint() { var requestHandlerMock = PathAndExecRequestMock<UserResponse>("/users.info?user=UID"); var subject = new UsersApi(requestHandlerMock.Object); var result = subject.Info("UID"); requestHandlerMock.Verify(); Assert.NotNull(result); }
public void UsersSetPresenceShouldCallCorrectEndpoint() { var requestHandlerMock = PathAndExecRequestMock<ResponseBase>("/users.setPresence?presence=away"); var subject = new UsersApi(requestHandlerMock.Object); var result = subject.SetPresence("away"); requestHandlerMock.Verify(); Assert.NotNull(result); }
static void Main(string[] args) { var accessTokenInfo = Configuration.Default.ApiClient.PostToken( "clientId", "clientSecret"); Configuration.Default.AccessToken = accessTokenInfo.AccessToken; PureCloudRegionHosts region = PureCloudRegionHosts.us_east_1; Configuration.Default.ApiClient.setBasePath(region); var usersApi = new UsersApi(); var userId = "<REPLACE_WITH_TEST_USER_ID>"; var handler = new NotificationHandler(); var topic = $"v2.users.{userId}.conversations"; handler.AddSubscription(topic, typeof(ConversationEventTopicConversation)); Console.WriteLine($"Subscribed to {topic} topic"); handler.NotificationReceived += (data) => { if (data.GetType() == typeof(NotificationData <ConversationEventTopicConversation>)) { var conversation = (NotificationData <ConversationEventTopicConversation>)data; var conversationId = conversation.EventBody.Id; var eventRawJson = JsonConvert.SerializeObject(data, Formatting.Indented); var eventJsonAsDict = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(eventRawJson); Console.WriteLine("\n-----------------------------------------------"); Console.WriteLine($"Notification for Conversation ID: {conversation.EventBody.Id}"); var eventBodyJsonAsDict = eventJsonAsDict["EventBody"]; var participants = conversation.EventBody.Participants.ToArray(); for (var i = 0; i < participants.Length; i++) { var participant = participants[i]; var participantJsonAsDict = eventBodyJsonAsDict["participants"][i]; if (participant.Purpose == "agent") { Console.WriteLine($"Participant ID: {participant.UserId}"); Console.WriteLine($"Calls:"); var participantCalls = participant.Calls.ToArray(); for (var j = 0; j < participantCalls.Length; j++) { var call = participantCalls[j]; var participantCallJson = participantJsonAsDict["calls"][j]; var stateJson = participantCallJson["state"]; Console.WriteLine($" -Call Id: {call.Id}, State (as Deserialized): {(int)call.State}, State (in JSON): {stateJson}"); } var participantRawJson = JsonConvert.SerializeObject(participantJsonAsDict, Formatting.Indented); Console.WriteLine($"Participant RawJSON (from Event):\n{participantRawJson}"); } } Console.WriteLine("-----------------------------------------------"); } }; Console.WriteLine("Websocket connected, awaiting messages..."); Console.WriteLine("Press any key to stop and remove all subscriptions"); Console.ReadKey(true); handler.RemoveAllSubscriptions(); Console.WriteLine("All subscriptions removed, exiting..."); }
public UsersController(UsersApi usersApi, TokensStorage tokensStorage) { this.usersApi = usersApi; this.tokensStorage = tokensStorage; }
public void DeleteUser(int id, string name) { UsersApi userApi = new UsersApi(); userApi.DeleteUser(id, name); }
public void UpdateUser(Users user) //int id, [FromBody]string value { UsersApi userApi = new UsersApi(); userApi.UpdateUser(user); }
public UsersApiTests() { instance = new UsersApi(); }
public void Init() { client = new ApiClient(subdomain, clientId, clientSecret: clientSecret); instance = client.Users; }
public UserStore(UsersApi usersApi) { this.usersApi = usersApi; }
public void Init() { _instance = new RolesApi(NprintingApiClient); _userApiInstance = new UsersApi(NprintingApiClient); }
public LoginController() { _usersApi = new UsersApi(); }
public static async void ShowOrderDetails(Order order) { Log.Write($"SHOW ORDER DETAILS FOR {order.Id}"); var ordersApi = new OrdersApi(); var orderCommands = ordersApi.GetOwnedCommands(order.Id); var currentCommand = orderCommands.LastOrDefault(command => command.CommandType == Command.CommandTypeEnum.New || command.CommandType == Command.CommandTypeEnum.Modify && (command.CommandStatus == Command.CommandStatusEnum.AtExecution || command.CommandStatus == Command.CommandStatusEnum.OnHold || command.CommandStatus == Command.CommandStatusEnum.ExecutionSuspended)); if (currentCommand != null) { var currentOrderVersion = ordersApi.GetOrderVersion(currentCommand.Id); var fills = ordersApi.GetOwnedFills(order.Id); var commandIds = orderCommands.Select(command => command.Id).ToList(); var executionReports = ordersApi.GetOwnedExecutionReportsBatch(commandIds); var commandReports = ordersApi.GetOwnedCommandReportsBatch(commandIds); var contractLibraryApi = new ContractLibraryApi(); var contract = await contractLibraryApi.GetContractAsync(order.ContractId); var contractMaturity = await contractLibraryApi.GetContractMaturityAsync(contract.ContractMaturityId); var product = await contractLibraryApi.GetProductAsync(contractMaturity.ProductId); var lines = orderCommands.Select(command => new { Id = command.Id, Timestamp = command.Timestamp, Text = GetCommandDescription(order, contract, command) }) .Concat( fills.Select(fill => new { Id = fill.Id, Timestamp = fill.Timestamp, Text = GetFillDescription(fill) })) .Concat( commandReports.Select(commandReport => new { Id = commandReport.Id, Timestamp = commandReport.Timestamp, Text = GetCommandReportDescription(commandReport) })) .Concat( executionReports.Select(executionReport => new { Id = executionReport.Id, Timestamp = executionReport.Timestamp, Text = GetExecutionReportDescription(executionReport) })); string orderStatus; switch (order.OrdStatus) { case Order.OrdStatusEnum.Working: var totalFilled = fills.Where(fill => fill.Active == true).Sum(fill => fill.Qty); if (totalFilled > 0) { orderStatus = "Partially Filled"; } else { orderStatus = order.OrdStatus.ToString(); } break; default: orderStatus = order.OrdStatus.ToString(); break; } string accountHolderEmail; var accountingApi = new AccountingApi(); var account = await accountingApi.GetAccountAsync(order.AccountId); try { // CTA should look through trading permissions var allTradingPermissions = await accountingApi.GetAllTradingPermissionsAsync(); var tradingPermission = allTradingPermissions.First(x => x.AccountId == account.Id && x.Status == TradingPermission.StatusEnum.Approved); accountHolderEmail = tradingPermission.AccountHolderEmail; } catch { // Organization Admin or actual owner of the account has access to User entity var userApi = new UsersApi(); var user = await userApi.GetUserAsync(account.UserId); accountHolderEmail = user.Email; } Log.Write($"Order #{order.Id} {GetOrderVersionDescription(order, contract, currentOrderVersion)} - {orderStatus}, Acc: #{account.Name}, Email: #{accountHolderEmail}"); foreach (var line in lines.OrderBy(x => x.Id).ThenBy(x => x.Timestamp)) { Console.WriteLine($"{line.Timestamp} #{line.Id}: {line.Text}"); } Console.WriteLine(); } }
/// <summary> /// Gets an instance of users API. /// </summary> /// <returns>UsersApi object.</returns> public UsersApi GetUsersApi() { var usersApi = new UsersApi(authToken, organisationId); return(usersApi); }
public void Init() { instance = new UsersApi(); }
public void TestInitialize() { _testConfig = new TestConfig(); JwtLoginMethod.RequestJWTUserToken_CorrectInputParameters_ReturnsOAuthToken(ref _testConfig); _usersApi = new UsersApi(_testConfig.ApiClient); }