public async Task ReturnsAUser()
            {
                var user = await UsersEndpoint.GetByUserId(UserId);

                Assert.NotNull(user);
                Assert.Equal(user.Id, UserId);
            }
            public async Task ReturnsNullIfNotFound()
            {
                var username = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var user     = await UsersEndpoint.GetByUsername(username);

                Assert.Null(user);
            }
Ejemplo n.º 3
0
        public async Task UploadActivityThenDelete()
        {
            var users = new UsersEndpoint(_client);
            var user  = await users.GetUser();

            var activities = new FitnessActivitiesEndpoint(_client, user);

            var newActivity = new FitnessActivitiesNewModel
            {
                //Type = FitnessActivityType.Cycling
            };

            // upload
            var uri = await activities.CreateActivity(newActivity);

            Assert.IsTrue(!string.IsNullOrEmpty(uri));

            //Read from Feed
            //var activities = await ActivitiesRequest.GetFeedPage();
            //var activitiesItem = activities.Items.FirstOrDefault();
            //Assert.IsNotNull(activitiesItem);
            //Assert.AreEqual(newActivity.Type, activitiesItem.Type);
            //Assert.AreEqual(newActivity.StartTime.ToString(), activitiesItem.StartTime.ToString());
            //Assert.AreEqual(newActivity.TotalDistance, activitiesItem.TotalDistance);
            //Assert.AreEqual(newActivity.Duration, activitiesItem.Duration);
            //Assert.AreEqual(uri, activitiesItem.Uri);


            //Delete
            await activities.DeleteActivity(uri);
        }
Ejemplo n.º 4
0
        private void Connect()
        {
            OrganisationEndpoint = new OrganisationEndpoint(Client);

            Accounts           = new AccountsEndpoint(Client);
            Allocations        = new AllocationsEndpoint(Client);
            Attachments        = new AttachmentsEndpoint(Client);
            BankTransactions   = new BankTransactionsEndpoint(Client);
            BankTransfers      = new BankTransfersEndpoint(Client);
            BrandingThemes     = new BrandingThemesEndpoint(Client);
            Contacts           = new ContactsEndpoint(Client);
            ContactGroups      = new ContactGroupsEndpoint(Client);
            CreditNotes        = new CreditNotesEndpoint(Client);
            Currencies         = new CurrenciesEndpoint(Client);
            Employees          = new EmployeesEndpoint(Client);
            ExpenseClaims      = new ExpenseClaimsEndpoint(Client);
            Invoices           = new InvoicesEndpoint(Client);
            Items              = new ItemsEndpoint(Client);
            Journals           = new JournalsEndpoint(Client);
            ManualJournals     = new ManualJournalsEndpoint(Client);
            Payments           = new PaymentsEndpoint(Client);
            PdfFiles           = new PdfEndpoint(Client);
            Receipts           = new ReceiptsEndpoint(Client);
            RepeatingInvoices  = new RepeatingInvoicesEndpoint(Client);
            Reports            = new ReportsEndpoint(Client);
            Setup              = new SetupEndpoint(Client);
            TaxRates           = new TaxRatesEndpoint(Client);
            TrackingCategories = new TrackingCategoriesEndpoint(Client);
            Users              = new UsersEndpoint(Client);
        }
Ejemplo n.º 5
0
        public async Task Obtain_one_user_from_app()
        {
            var response = await Given
                           .Server
                           .CreateRequest(AccountEndpoint.Register)
                           .WithJsonBody(new RegisterModel()
            {
                Username = $"{Guid.NewGuid()}@domain.com",
                Password = Guid.NewGuid().ToString(),
            })
                           .PostAsync();

            await response.ShouldBe(StatusCodes.Status200OK);

            var created = await response.ReadJsonResponse <UserViewModel>();

            response = await Given
                       .Server
                       .CreateRequest(UsersEndpoint.GetById(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .GetAsync();

            await response.ShouldBe(StatusCodes.Status200OK);

            var searched = await response.ReadJsonResponse <UserViewModel>();

            searched.Should().BeEquivalentTo(created);
        }
Ejemplo n.º 6
0
        public void Init()
        {
            UserRequest = new UsersEndpoint(TokenManager);
            var user = UserRequest.GetUser();

            ProfileRequest = new ProfileEndpoint(TokenManager, user);
        }
Ejemplo n.º 7
0
        public void Init()
        {
            UserRequest = new UsersEndpoint(TokenManager);
            var user = UserRequest.GetUser();

            ActivitiesRequest = new FitnessActivitiesEndpoint(TokenManager, user);
        }
Ejemplo n.º 8
0
        public async Task Delete_existing_user_from_app()
        {
            var response = await Given
                           .Server
                           .CreateRequest(AccountEndpoint.Register)
                           .WithJsonBody(new RegisterModel()
            {
                Username = $"{Guid.NewGuid()}@domain.com",
                Password = Guid.NewGuid().ToString(),
            })
                           .PostAsync();

            await response.ShouldBe(StatusCodes.Status200OK);

            var created = await response.ReadJsonResponse <UserViewModel>();

            response = await Given
                       .Server
                       .CreateRequest(UsersEndpoint.Delete(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .DeleteAsync();

            await response.ShouldBe(StatusCodes.Status204NoContent);

            response = await Given
                       .Server
                       .CreateRequest(UsersEndpoint.GetById(created.Id))
                       .WithIdentity(Identities.Administrator)
                       .GetAsync();

            await response.ShouldBe(StatusCodes.Status404NotFound);
        }
            public async Task ReturnsAUser()
            {
                var username = "******";
                var user     = await UsersEndpoint.GetByUsername(username);

                Assert.NotNull(user);
                Assert.Equal(user.Username, username);
            }
            public async Task ReturnUserFollowing()
            {
                const int userId     = 68628513;
                var       followings = await UsersEndpoint.GetUserFollowing(userId);

                Assert.NotNull(followings);
                Assert.NotEmpty(followings.List);
            }
            public async Task ReturnsFriends()
            {
                var friends = await UsersEndpoint.GetListOfFriends(UserId);

                Assert.NotNull(friends);
                Assert.NotEmpty(friends.List);
                Assert.True(friends.Pagination.TotalItems > 0);
            }
Ejemplo n.º 12
0
        public void GetUsersTest()
        {
            UsersEndpoint usersEndpoint = new UsersEndpoint(this.BASE_URL);
            string        url           = usersEndpoint.GenerateUrl(
                urlParams: UsersEndpoint.UrlParams.SetMembershipId("<MEMBERSHIP_ID>").SetUserId("<USER_ID>"),
                queryString: QueryString.Add("key", "<API_KEY>"));

            Assert.AreEqual($"{this.BASE_URL}/memberships/<MEMBERSHIP_ID>/users/<USER_ID>?key=<API_KEY>", url);
        }
Ejemplo n.º 13
0
        public async Task Fail_to_delete_one_user_because_is_not_authorized()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.Delete(Guid.NewGuid()))
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status401Unauthorized);
        }
Ejemplo n.º 14
0
        public async Task Fail_to_obtain_one_user_when_does_not_exist()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.GetById(Guid.NewGuid()))
                           .WithIdentity(Identities.Administrator)
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status404NotFound);
        }
Ejemplo n.º 15
0
        public async Task Fail_to_delete_one_user_because_is_not_admin()
        {
            var response = await Given
                           .Server
                           .CreateRequest(UsersEndpoint.Delete(Guid.NewGuid()))
                           .WithIdentity(Identities.OneUser)
                           .GetAsync();

            await response.ShouldBe(StatusCodes.Status403Forbidden);
        }
Ejemplo n.º 16
0
        public void GetUsersTest()
        {
            // https://api.tahminmatik.com/api/v1/memberships/<MEMBERSHIP_ID>/users/<USER_ID>
            UsersEndpoint usersEndpoint  = new UsersEndpoint(this.BASE_URL);
            var           responseResult = usersEndpoint.Get(
                urlParams: UsersEndpoint.UrlParams.SetMembershipId("<MEMBERSHIP_ID>").SetUserId("<USER_ID>"),
                body: "<BODY>",
                queryString: QueryString.Add("key", "<API_KEY>"),
                headers: HeaderCollection.Add("Authorization", "<BEARER_TOKEN>"));

            if (responseResult.IsSuccess)
            {
            }
        }
 public UnauthorizedGoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret)
     : base(apiKey, apiSecret, accessToken, accessSecret)
 {
     Authors      = new AuthorsEnpoint(_connection);
     Books        = new BooksEndpoint(_connection);
     Shelves      = new ShelvesEndpoint(_connection);
     Users        = new UsersEndpoint(_connection);
     Reviews      = new ReviewsEndpoint(_connection);
     Series       = new SeriesEndpoint(_connection);
     Events       = new EventsEndpoint(_connection);
     Groups       = new GroupsEndpoint(_connection);
     UserStatuses = new UserStatusesEndpoint(_connection);
     ReadStatuses = new ReadStatusesEndpoint(_connection);
     Comments     = new CommentsEndpoint(_connection);
     Topics       = new TopicsEndpoint(_connection);
 }
Ejemplo n.º 18
0
        public void GetUsersWithQueryTest()
        {
            UsersEndpoint usersEndpoint1 = new UsersEndpoint(this.BASE_URL);
            string        url1           = usersEndpoint1.GenerateUrl(
                urlParams: UsersEndpoint.UrlParams.SetMembershipId("<MEMBERSHIP_ID>").SetUserId("<USER_ID>").UseMongoQuery(),
                queryString: QueryString.Add("key", "<API_KEY>"));

            Assert.AreEqual($"{this.BASE_URL}/memberships/<MEMBERSHIP_ID>/users/<USER_ID>/_query?key=<API_KEY>", url1);

            UsersEndpoint usersEndpoint2 = new UsersEndpoint(this.BASE_URL);
            string        url2           = usersEndpoint2.GenerateUrl(
                urlParams: UsersEndpoint.UrlParams.SetMembershipId("<MEMBERSHIP_ID>").UseMongoQuery(),
                queryString: QueryString.Add("key", "<API_KEY>"));

            Assert.AreEqual($"{this.BASE_URL}/memberships/<MEMBERSHIP_ID>/users/_query?key=<API_KEY>", url2);
        }
Ejemplo n.º 19
0
        protected void AttemptAuth(object sender, EventArgs e)
        {
            _clientIdEntry.FetchValue();
            ClientId = _clientIdEntry.Value;
            _clientSecretEntry.FetchValue();
            ClientSecret = _clientSecretEntry.Value;
            _requestUriEntry.FetchValue();
            RequestUri = _requestUriEntry.Value;

            if ((string.IsNullOrEmpty(ClientId)) || (string.IsNullOrEmpty(ClientSecret)) || (string.IsNullOrEmpty(RequestUri)))
            {
                UIAlertView firstPageValidationAlert = new UIAlertView("Whoops!", "Please provide a Client Id, Client Secret and Request Uri.", null, "Okay");
                firstPageValidationAlert.Show();
            }
            else
            {
                //Elements for Second Page - authorization
                var secondPage = new UIViewController();
                secondPage.Title = "Authorize";
                var authorizeWebView = new UIWebView(secondPage.View.Frame);
                secondPage.View.AddSubview(authorizeWebView);
                viewController.VisibleViewController.NavigationController.PushViewController(secondPage, true);
                authorizeWebView.LoadFinished += delegate(object s, EventArgs ev) {
                    string       currentUrl     = authorizeWebView.Request.Url.AbsoluteString;
                    const string CodeIdentifier = "code=";
                    if (currentUrl.Contains(CodeIdentifier))
                    {
                        //We've received an authorization code - initialize the token manager to get a create a token
                        Code         = currentUrl.Substring(currentUrl.IndexOf(CodeIdentifier) + CodeIdentifier.Length);
                        TokenManager = new AccessTokenManager(ClientId, ClientSecret, RequestUri);
                        InvokeOnMainThread(() => {
                            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                        });
                        TokenManager.InitAccessToken(Code);
                        var userRequest = new UsersEndpoint(TokenManager);
                        User = userRequest.GetUser();
                        var profileRequest = new ProfileEndpoint(TokenManager, User);
                        Profile = profileRequest.GetProfile();
                        InvokeOnMainThread(() => {
                            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                        });
                        ShowUserAndProfile();
                    }
                };
                authorizeWebView.LoadRequest(new NSUrlRequest(new NSUrl(HealthGraphAuthorizeEndpoint + "?client_id=" + ClientId + "&redirect_uri=" + HttpUtility.UrlEncode(RequestUri) + "&response_type=code")));
            }
        }
Ejemplo n.º 20
0
        //in order to support V1 and V2 endpoints, needs both internal and external platform ids
        public IntegrationsWebAppClient(string url, string platformExternalId, string platformInternalId, bool useHttps = false)
        {
            Requester requester = new Requester($"{url}");

            //v1 endpoint
            Addresses          = new AddressesEndpoint(requester, $"/api/v1/{platformInternalId}/addresses", useHttps);
            PublishMerchandise = new PublishMerchandiseEndpoint(requester, $"/api/v1/{platformInternalId}/publishmerchandise", useHttps);
            PublishContent     = new PublishContentEndpoint(requester, $"/api/v1/{platformInternalId}/publishcontent", useHttps);
            Brands             = new BrandsEndpoint(requester, $"/api/v1/{platformInternalId}/brands", useHttps);
            Catalogs           = new CatalogsEndpoint(requester, $"/api/v1/{platformInternalId}/catalogs", useHttps);

            //V2 endpoint
            Products       = new ProductEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/products", useHttps);
            Categories     = new CategoriesEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/categories", useHttps);
            AccountMasters = new AccountMastersEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/accountmasters", useHttps);
            PriceLists     = new PriceListsEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/pricelists", useHttps);
            Offerings      = new OfferingsEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/offerings", useHttps);
            Logins         = new LoginsEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/logins", useHttps);
            Users          = new UsersEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/users", useHttps);
            Contacts       = new ContactsEndpoint(requester, $"/api/v2/platforms/{platformExternalId}/contacts", useHttps);
        }
Ejemplo n.º 21
0
        public void GetUser_NotOptionalProperiesPresent()
        {
            //Arrange
            var userRequest = new UsersEndpoint(TokenManager);
            //Act
            var user = userRequest.GetUser();

            //Assert
            Assert.IsTrue(user.UserID != default(int));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Profile));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Settings));
            Assert.IsTrue(!string.IsNullOrEmpty(user.FitnessActivities));
            Assert.IsTrue(!string.IsNullOrEmpty(user.StrengthTrainingActivities));
            Assert.IsTrue(!string.IsNullOrEmpty(user.BackgroundActivities));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Sleep));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Nutrition));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Weight));
            Assert.IsTrue(!string.IsNullOrEmpty(user.GeneralMeasurements));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Diabetes));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Records));
            Assert.IsTrue(!string.IsNullOrEmpty(user.Team));
        }
Ejemplo n.º 22
0
        public Cin7Api(IUser user)
        {
            client = new Cin7ApiClient(new Cin7ApiSettings(), user, new RateLimiter());

            Contacts          = new ContactsEndpoint(client);
            Branches          = new BranchesEndpoint(client);
            ProductCategories = new ProductCategoriesEndpoint(client);
            Products          = new ProductsEndpoint(client);
            ProductOptions    = new ProductOptionsEndpoint(client);
            SerialNumbers     = new SerialNumbersEndpoint(client);
            SalesOrders       = new SalesOrdersEndpoint(client);
            Payments          = new PaymentsEndpoint(client);
            Quotes            = new QuotesEndpoint(client);
            PurchaseOrders    = new PurchaseOrdersEndpoint(client);
            Stock             = new StockEndpoint(client);
            BranchTransfers   = new BranchTransfersEndpoint(client);
            Adjustments       = new AdjustmentsEndpoint(client);
            Vouchers          = new VouchersEndpoint(client);
            CreditNotes       = new CreditNotesEndpoint(client);
            BomMasters        = new BomMastersEndpoint(client);
            ProductionJobs    = new ProductionJobsEndpoint(client);
            Users             = new UsersEndpoint(client);
        }
 public OAuthGoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret)
     : base(apiKey, apiSecret, accessToken, accessSecret)
 {
     Authors          = new AuthorsEnpoint(_connection);
     AuthorsFollowing = new AuthorsFollowingEndpoint(_connection);
     Books            = new BooksEndpoint(_connection);
     Comments         = new CommentsEndpoint(_connection);
     Events           = new EventsEndpoint(_connection);
     Followers        = new FollowersEndpoint(_connection);
     Friends          = new FriendsEndpoint(_connection);
     Groups           = new GroupsEndpoint(_connection);
     Notifications    = new NotificationsEndpoint(_connection);
     OwnedBooks       = new OwnedBooksEndpoint(_connection);
     Quotes           = new QuotesEndpoint(_connection);
     ReadStatuses     = new ReadStatusesEndpoint(_connection);
     Recommendations  = new RecommendationsEndpoint(_connection);
     Reviews          = new ReviewsEndpoint(_connection);
     Series           = new SeriesEndpoint(_connection);
     Shelves          = new ShelvesEndpoint(_connection);
     Topics           = new TopicsEndpoint(_connection);
     Updates          = new UpdatesEndpoint(_connection);
     Users            = new UsersEndpoint(_connection);
     UserStatuses     = new UserStatusesEndpoint(_connection);
 }
            public async Task ReturnsNullIfNotFound()
            {
                var friends = await UsersEndpoint.GetListOfFriends(userId : -1);

                Assert.Null(friends);
            }
Ejemplo n.º 25
0
 public void Init()
 {
     sharpBucket   = TestHelpers.SharpBucketV2;
     usersEndPoint = sharpBucket.UsersEndPoint(ACCOUNT_NAME);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Sets up the endpoints.
 /// </summary>
 protected virtual void SetupEndpoints()
 {
     Users = new UsersEndpoint(this);
 }
Ejemplo n.º 27
0
        private void Connect()
        {
            OrganisationEndpoint = new OrganisationEndpoint(Client);

            Accounts = new AccountsEndpoint(Client);
            Attachments = new AttachmentsEndpoint(Client);
            BankTransactions = new BankTransactionsEndpoint(Client);
            BankTransfers = new BankTransfersEndpoint(Client);
            BrandingThemes = new BrandingThemesEndpoint(Client);
            Contacts = new ContactsEndpoint(Client);
            CreditNotes = new CreditNotesEndpoint(Client);
            Currencies = new CurrenciesEndpoint(Client);
            Employees = new EmployeesEndpoint(Client);
            ExpenseClaims = new ExpenseClaimsEndpoint(Client);
            Invoices = new InvoicesEndpoint(Client);
            Items = new ItemsEndpoint(Client);
            Journals = new JournalsEndpoint(Client);
            ManualJournals = new ManualJournalsEndpoint(Client);
            Payments = new PaymentsEndpoint(Client);
            Receipts = new ReceiptsEndpoint(Client);
            RepeatingInvoices = new RepeatingInvoicesEndpoint(Client);
            Reports = new ReportsEndpoint(Client);
            TaxRates = new TaxRatesEndpoint(Client);
            TrackingCategories = new TrackingCategoriesEndpoint(Client);
            Users = new UsersEndpoint(Client);
        }
Ejemplo n.º 28
0
        protected void DisplayHealthGraphSamples()
        {
            PnlTokenSamples.Visible = true;
            LblAccessToken.Text     = Token.AccessToken;
            LblAccessType.Text      = Token.TokenType;

            //User Uri example
            var userRequest = new UsersEndpoint(TokenManager);
            var user        = userRequest.GetUser();

            LblUserId.Text = user.UserID.ToString();
            LblUserStrengthTrainingActivities.Text = user.StrengthTrainingActivities;
            LblUserWeight.Text               = user.Weight;
            LblUserSettings.Text             = user.Settings;
            LblUserDiabetes.Text             = user.Diabetes;
            LblUserTeam.Text                 = user.Team;
            LblUserSleep.Text                = user.Sleep;
            LblUserFitnessActivities.Text    = user.FitnessActivities;
            LblUserNutrition.Text            = user.Nutrition;
            LblUserGeneralMeasurements.Text  = user.GeneralMeasurements;
            LblUserBackgroundActivities.Text = user.BackgroundActivities;
            LblUserRecords.Text              = user.Records;
            LblUserProfile.Text              = user.Profile;

            //Get user profile
            var profileRequest = new ProfileEndpoint(TokenManager, user);
            var profile        = profileRequest.GetProfile();

            //Optionally change and update it here
            //profile.AthleteType = "Hiker";
            //profile.AthleteType = "Hiker";
            //profile = profileRequest.UpdateProfile(profile);
            //Display user profile
            LblProfileName.Text          = !string.IsNullOrEmpty(profile.Name) ? profile.Name : "N/A";
            LblProfileLocation.Text      = !string.IsNullOrEmpty(profile.Location) ? profile.Location : "N/A";
            LblProfileAthleteType.Text   = !string.IsNullOrEmpty(profile.AthleteType) ? profile.AthleteType : "N/A";
            LblProfileGender.Text        = !string.IsNullOrEmpty(profile.Gender) ? profile.Gender : "N/A";
            LblProfileBirthday.Text      = profile.Birthday.HasValue ? profile.Birthday.Value.ToShortDateString() : "N/A";
            LblProfileElite.Text         = profile.Elite.ToString();
            LblProfileProfile.Text       = profile.Profile;
            LblProfileSmallPicture.Text  = !string.IsNullOrEmpty(profile.SmallPicture) ? profile.SmallPicture : "N/A";
            LblProfileNormalPicture.Text = !string.IsNullOrEmpty(profile.NormalPicture) ? profile.NormalPicture : "N/A";
            LblProfileMediumPicture.Text = !string.IsNullOrEmpty(profile.MediumPicture) ? profile.MediumPicture : "N/A";
            LblProfileLargePicture.Text  = !string.IsNullOrEmpty(profile.LargePicture) ? profile.LargePicture : "N/A";

            //var measurementNew = new DiabetesMeasurementsNewModel
            //{
            //    Timestamp = DateTime.Now,
            //    Triglyceride = 150,
            //    PostToFacebook = false,
            //    PostToTwitter = false
            //};
            //var measurementRequest = new DiabetesMeasurementsEndpoint(TokenManager, user);
            //var uriOfMeasurement = measurementRequest.CreateMeasurement(measurementNew);
            //var measurementPage = measurementRequest.GetFeedPage();
            //string uriOfMeasurement = measurementPage.Items.First().Uri;
            //var measurementDetail = measurementRequest.GetMeasurement(uriOfMeasurement);
            //measurementDetail.Triglyceride = 40;
            //measurementDetail = measurementRequest.UpdateMeasurement(measurementDetail);
            //measurementRequest.DeleteMeasurement(uriOfMeasurement);

            //var measurementNew = new GeneralMeasurementsNewModel
            //{
            //    Timestamp = DateTime.Now,
            //    Testosterone = 40,
            //    PostToFacebook = false,
            //    PostToTwitter = false
            //};
            //var measurementRequest = new GeneralMeasurementsEndpoint(TokenManager, user);
            //var uriOfMeasurement = measurementRequest.CreateMeasurement(measurementNew);
            //var measurementPage = measurementRequest.GetFeedPage();
            //string uriOfMeasurement = measurementPage.Items.First().Uri;
            //var measurementDetail = measurementRequest.GetMeasurement(uriOfMeasurement);
            //measurementDetail.Testosterone = 100;
            //measurementDetail = measurementRequest.UpdateMeasurement(measurementDetail);
            //measurementRequest.DeleteMeasurement(uriOfMeasurement);

            //var backgroundNew = new BackgroundActivitiesNewModel
            //{
            //    Timestamp = DateTime.Now,
            //    Steps = 1000,
            //    PostToFacebook = false,
            //    PostToTwitter = false
            //};
            //var backgroundActivitiesRequest = new BackgroundActivitiesEndpoint(TokenManager, user);
            //var uriOfBackground = backgroundActivitiesRequest.CreateActivity(backgroundNew);
            //var backgroundPage = backgroundActivitiesRequest.GetFeedPage();
            //string uriOfBackground = backgroundPage.Items.First().Uri;
            //var backgroundDetail = backgroundActivitiesRequest.GetActivity(uriOfBackground);
            //backgroundDetail.CaloriesBurned = 100;
            //backgroundDetail = backgroundActivitiesRequest.UpdateActivity(backgroundDetail);
            //backgroundActivitiesRequest.DeleteActivity(uriOfBackground);

            //var strengthTrainingNew = new StrengthTrainingActivitiesNewModel
            //{
            //    StartTime = DateTime.Now,
            //    Notes = "Good exercise.",
            //    TotalCalories = 100,
            //    Exercises = new List<ExercisesModel>
            //    {
            //        new ExercisesModel
            //        {
            //            PrimaryType = "Barbell Curl",
            //            PrimaryMuscleGroup = "Arms",
            //            Sets = new List<SetsModel>
            //            {
            //                new SetsModel
            //                {
            //                    Weight = 200,
            //                    Repetitions = 4
            //                }
            //            }
            //        }
            //    },
            //    PostToFacebook = false,
            //    PostToTwitter = false
            //};
            //var strengthTrainingRequest = new StrengthTrainingActivitiesEndpoint(TokenManager, user);
            ////var uriOfStrengthTraining = strengthTrainingRequest.CreateActivity(strengthTrainingNew);
            //var activitiesPage = strengthTrainingRequest.GetFeedPage();
            //string uriOfStrengthTraining = activitiesPage.Items.First().Uri;
            //var activitiesDetail = strengthTrainingRequest.GetActivity(uriOfStrengthTraining);
            //activitiesDetail.TotalCalories = 200;
            //activitiesDetail = strengthTrainingRequest.UpdateActivity(activitiesDetail);
            //strengthTrainingRequest.DeleteActivity(uriOfStrengthTraining);


            //var sleepRequest = new SleepEndpoint(TokenManager, user);
            //var sleepNew = new SleepNewModel
            //{
            //    Timestamp = DateTime.Now,
            //    TimesWoken = 3,
            //    PostToTwitter = false,
            //    PostToFacebook = false
            //};
            //var uriOfSleep = sleepRequest.CreateSleep(sleepNew);
            //var sleepPage = sleepRequest.GetFeedPage();
            //var sleepDetail = sleepRequest.GetSleep(uriOfSleep);

            //var uriOfSleep = sleepPage.Items.First().Uri;
            //var sleepDetail = sleepRequest.GetSleep(uriOfSleep);
            //sleepDetail.Rem = 180;
            //sleepDetail = sleepRequest.UpdateSleep(sleepDetail);

            //sleepRequest.DeleteSleep(uriOfSleep);

            //int test = 4;
            //var settingsRequest = new SettingsEndpoint(TokenManager, user);
            //var settings = settingsRequest.GetSettings();
            //settings.FirstDayOfWeek = "Monday";
            //settings = settingsRequest.UpdateSettings(settings);

            //var streetTeamRequest = new StreetTeamEndpoint(TokenManager, user);
            //var streetTeamItems = streetTeamRequest.GetFeedPage(pageIndex: 1, pageSize: 2);
            //var uri = streetTeamRequest.CreateTeamInvitation(new StreetTeamInvitationsModel { UserID = 7072229 });
            //var results = streetTeamRequest.GetStreetTeam(uri);

            //var nutritionNew = new NutritionNewModel
            //{
            //    Timestamp = DateTime.Now,
            //    Fat = 200,
            //    PostToFacebook = false,
            //    PostToTwitter = false
            //};
            //var nutritionRequest = new NutritionEndpoint(TokenManager, user);
            //var uriOfNutrition = nutritionRequest.CreateNutrition(nutritionNew);
            //var uriOfNutrition = nutritionRequest.GetFeedPage().Items.First().Uri;
            //nutritionRequest.DeleteNutrition(uriOfNutrition);

            //var weightRequest = new WeightEndpoint(TokenManager, user);

            /*
             * var weightNew = new WeightNewModel
             * {
             *  Timestamp = DateTime.Now,
             *  Weight = 90,
             *  PostToFacebook = false,
             *  PostToTwitter = false
             * };
             * var test = weightRequest.CreateWeight(weightNew);
             */
            //var weightItems =  weightRequest.GetFeedPage().Items;
            //var weightItem = weightItems.First();

            /*
             * var weightDetail = weightRequest.GetWeight(weightItem.Uri);
             * weightDetail.Bmi = 240;
             * weightDetail = weightRequest.UpdateWeight(weightDetail);
             */
            //weightRequest.DeleteWeight(weightItem.Uri);


            //var activitiesRequest = new FitnessActivitiesEndpoint(TokenManager, user);

            /*
             * var newActivity = new FitnessActivitiesNewModel
             * {
             *  Type = "Running",
             *  StartTime = DateTime.Now,
             *  Duration = 50,
             *  Notes = "blah6!"
             * };
             * var uri = activitiesRequest.CreateActivity(newActivity);
             */
            //var activitiesItem = activitiesRequest.GetFeedPage(pageSize: 2, noLaterThan: new DateTime(2013, 6, 1)).Items.FirstOrDefault();
            //if (activitiesItem != null)
            //{
            //    var activitiesDetail = activitiesRequest.GetActivity(activitiesItem.Uri);

            //Get associated comments
            //    var commentRequest = new CommentThreadsEndpoint(TokenManager);
            //    var commentThread = commentRequest.GetCommentThread(activitiesDetail.Comments);

            //    var newComment = new CommentsNewModel
            //    {
            //        Comment = "Here we go!"
            //    };
            //    commentRequest.CreateComment(newComment, activitiesDetail.Comments);
            //commentRequest.CreateCommentAsync(() => { }, (ex) => { }, newComment, activitiesDetail.Comments);

            //    commentThread = commentRequest.GetCommentThread(activitiesDetail.Comments);

            //Retrieve and update an activity
            //var activitiesDetail = activitiesRequest.GetActivity(activitiesItem.Uri);
            //activitiesDetail.Type = "Running";
            //activitiesDetail.Equipment = "None";
            //activitiesDetail.AverageHeartRate = null;
            //activitiesDetail.Notes = "Testing is fun.";
            //activitiesRequest.UpdateActivity(activitiesDetail);

            //Delete the activity
            //activitiesRequest.DeleteActivity(activitiesDetail.Uri);
            // }


            //var recordsRequest = new RecordsEndpoint(TokenManager, user);
            //var items = recordsRequest.GetRecordsFeed();
            //int test = 4;
        }
Ejemplo n.º 29
0
        private void Connect()
        {
            OrganisationEndpoint = new OrganisationEndpoint(Client);

            Accounts = new AccountsEndpoint(Client);
            Allocations = new AllocationsEndpoint(Client);
            Attachments = new AttachmentsEndpoint(Client);
            BankTransactions = new BankTransactionsEndpoint(Client);
            BankTransfers = new BankTransfersEndpoint(Client);
            BrandingThemes = new BrandingThemesEndpoint(Client);
            Contacts = new ContactsEndpoint(Client);
            ContactGroups = new ContactGroupsEndpoint(Client);
            CreditNotes = new CreditNotesEndpoint(Client);
            Currencies = new CurrenciesEndpoint(Client);
            Employees = new EmployeesEndpoint(Client);
            ExpenseClaims = new ExpenseClaimsEndpoint(Client);
            Files = new FilesEndpoint(Client);
            Folders = new FoldersEndpoint(Client);
            Inbox = new InboxEndpoint(Client);
            Associations = new AssociationsEndpoint(Client);
            Invoices = new InvoicesEndpoint(Client);
            Items = new ItemsEndpoint(Client);
            Journals = new JournalsEndpoint(Client);
            LinkedTransactions = new LinkedTransactionsEndpoint(Client);
            ManualJournals = new ManualJournalsEndpoint(Client);
            Overpayments = new OverpaymentsEndpoint(Client);
            Payments = new PaymentsEndpoint(Client);
            PdfFiles = new PdfEndpoint(Client);
            Prepayments = new PrepaymentsEndpoint(Client);
            PurchaseOrders = new PurchaseOrdersEndpoint(Client);
            Receipts = new ReceiptsEndpoint(Client);
            RepeatingInvoices = new RepeatingInvoicesEndpoint(Client);
            Reports = new ReportsEndpoint(Client);
            Setup = new SetupEndpoint(Client);
            TaxRates = new TaxRatesEndpoint(Client);
            TrackingCategories = new TrackingCategoriesEndpoint(Client);
            Users = new UsersEndpoint(Client);
        }
            public async Task ReturnsNullIfNotFound()
            {
                var user = await UsersEndpoint.GetByUserId(long.MaxValue);

                Assert.Null(user);
            }
Ejemplo n.º 31
0
 public void Init()
 {
     sharpBucket   = TestHelpers.SharpBucketV2;
     usersEndPoint = sharpBucket.UsersEndPoint(SampleRepositories.MERCURIAL_ACCOUNT_UUID);
 }
            public async Task ReturnsUserIdWhenAuthenticated()
            {
                var id = await UsersEndpoint.GetAuthenticatedUserId();

                Assert.Equal(id, Helper.GetUserId());
            }