public static CommandBuilder <InStoreCommand <SignInResult <T> >, SignInResult <T> > SignUp <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     CustomerDraft draft)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <SignInResult <T> >, SignInResult <T> >(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand = new SignUpCustomerCommand(draft) as SignUpCommand <T>;
         var newInStoreCommand = new InStoreCommand <SignInResult <T> >(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
 public static CommandBuilder <InStoreCommand <SignInResult <T> >, SignInResult <T> > Login <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     string email,
     string password)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <SignInResult <T> >, SignInResult <T> >(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand = new LoginCustomerCommand(email, password) as LoginCommand <T>;
         var newInStoreCommand = new InStoreCommand <SignInResult <T> >(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
 public static CommandBuilder <InStoreCommand <T>, T> ChangePassword <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     IVersioned <T> resource,
     string currentPassword,
     string newPassword)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <T>, T>(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand = new ChangeCustomerPasswordCommand(resource.Id, resource.Version, currentPassword, newPassword) as ChangePasswordCommand <T>;
         var newInStoreCommand = new InStoreCommand <T>(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
 CreateTokenForPasswordResetting <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     string email,
     int?timeToLiveMinutes = null)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <Token <T> >, Token <T> >(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand =
             new CreateTokenForCustomerPasswordResetCommand(email, timeToLiveMinutes) as
             CreateTokenForPasswordResetCommand <T>;
         var newInStoreCommand = new InStoreCommand <Token <T> >(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
 CreateTokenForEmailVerification <T>(
     this CommandBuilder <InStoreCommand <T>, T> builder,
     string id,
     int timeToLiveMinutes,
     int?version = null)
     where T : Resource <T>
 {
     return(new CommandBuilder <InStoreCommand <Token <T> >, Token <T> >(
                builder.Client, () =>
     {
         var inStoreCommand = builder.Build();
         var innerCommand =
             new CreateTokenForCustomerEmailVerificationCommand(id, timeToLiveMinutes, version) as
             CreateTokenForEmailVerificationCommand <T>;
         var newInStoreCommand = new InStoreCommand <Token <T> >(inStoreCommand.StoreKey, innerCommand);
         return newInStoreCommand;
     }));
 }
        public async Task GetCustomerInStoreById()
        {
            //Get customer in specific store
            await WithStore(client, async store1 =>
            {
                await WithStore(client, async store2 =>
                {
                    var stores = new List <IReferenceable <Store> >
                    {
                        store1.ToKeyResourceIdentifier(),
                        store2.ToKeyResourceIdentifier()
                    };

                    await WithCustomer(
                        client, customerDraft => DefaultCustomerDraftInStores(customerDraft, stores),
                        async customer =>
                    {
                        Assert.NotNull(customer);
                        Assert.Equal(2, customer.Stores.Count);

                        //using extension method
                        var retrievedCustomer =
                            await client.ExecuteAsync(customer.ToIdResourceIdentifier().GetById()
                                                      .InStore(store1.Key));

                        Assert.NotNull(retrievedCustomer);
                        Assert.Equal(customer.Id, retrievedCustomer.Id);

                        //create InStoreCommand
                        var getCustomerByIdCommand        = new GetByIdCommand <Customer>(customer.Id);
                        var getCustomerInStoreByIdCommand =
                            new InStoreCommand <Customer>(store2.ToKeyResourceIdentifier(), getCustomerByIdCommand);
                        var customerInStore = await client.ExecuteAsync(getCustomerInStoreByIdCommand);
                        Assert.NotNull(customerInStore);
                        Assert.Equal(customer.Id, customerInStore.Id);
                    });
                });
            });
        }
 public InStoreHttpApiCommand(InStoreCommand <T> inStoreDecoratorCommand, IHttpApiCommandFactory factory)
 {
     this.storeKey = inStoreDecoratorCommand.StoreKey;
     this.command  = factory.Create(inStoreDecoratorCommand.InnerCommand);
 }