Exemplo n.º 1
0
        public List <User> GetListOfUsers()
        {
            client.Authenticator = new JwtAuthenticator(token);
            RestRequest request = new RestRequest(API_USERS_URL);
            IRestResponse <List <User> > response = client.Get <List <User> >(request);
            List <User> listOfUsers = new List <User>();

            if (response.ResponseStatus != ResponseStatus.Completed || !response.IsSuccessful)
            {
                MainMenuMethods.ProcessErrorResponse(response);
            }
            else
            {
                listOfUsers = response.Data;
            }
            return(listOfUsers);
        }
Exemplo n.º 2
0
        public Transfer GetTransferFromTransferId(int transferId)
        {
            client.Authenticator = new JwtAuthenticator(token);
            RestRequest request = new RestRequest(API_TRANSFER_URL + "lookup/" + transferId);
            IRestResponse <Transfer> response = client.Get <Transfer>(request);
            Transfer transfer = new Transfer();

            if (response.ResponseStatus != ResponseStatus.Completed || !response.IsSuccessful)
            {
                MainMenuMethods.ProcessErrorResponse(response);
            }
            else
            {
                transfer = response.Data;
            }
            return(transfer);
        }
Exemplo n.º 3
0
        public Account GetUserAccount(int userId)
        {
            client.Authenticator = new JwtAuthenticator(token);

            RestRequest             request  = new RestRequest(API_ACCOUNT_URL + userId);
            IRestResponse <Account> response = client.Get <Account>(request);
            Account account = null;

            if (response.ResponseStatus != ResponseStatus.Completed || !response.IsSuccessful)
            {
                MainMenuMethods.ProcessErrorResponse(response);
            }
            else
            {
                account = response.Data;
            }
            return(account);
        }
Exemplo n.º 4
0
        public User GetUser(int accountId)
        {
            client.Authenticator = new JwtAuthenticator(token);
            User                 user     = new User();
            RestRequest          request  = new RestRequest(API_USERS_URL + "account/" + accountId);
            IRestResponse <User> response = client.Get <User>(request);

            user = response.Data;

            if (response.ResponseStatus != ResponseStatus.Completed || !response.IsSuccessful)
            {
                MainMenuMethods.ProcessErrorResponse(response);
            }
            else
            {
                user = response.Data;
            }
            return(user);
        }
Exemplo n.º 5
0
        public Transfer CreateTransfer(Transfer transfer)
        {
            client.Authenticator = new JwtAuthenticator(token);
            RestRequest request = new RestRequest(API_TRANSFER_URL);

            request.AddJsonBody(transfer);
            IRestResponse <Transfer> response = client.Post <Transfer>(request);
            Transfer returnTransfer           = new Transfer();

            if (response.ResponseStatus != ResponseStatus.Completed || !response.IsSuccessful)
            {
                MainMenuMethods.ProcessErrorResponse(response);
            }
            else
            {
                returnTransfer = response.Data;
            }
            return(returnTransfer);
        }