static async Task Main(string[] args) { //var report = await Surf.Wave(args?.FirstOrDefault() ?? "https://private-ac89c-surfdude.apiary-mock.com/") // .FromRoot() // .ThenSubmit("registration-finder", new { status = "active", email = "*****@*****.**" }) // .GoAsync(); var context = new SurfContext(args?.FirstOrDefault() ?? "https://private-ac89c-surfdude.apiary-mock.com/", loggerFactory); var report = await Surf.Wave(context) .FromRoot() .Then("registrations") .ThenItem(0) .ThenSubmit("update-contact-details", new { email = "*****@*****.**" }) .ThenRead(out Func <ResourceModel> getContactDetails) .Then("registration") //.ThenSubmit("add-processing-instruction", new { message = "Put NO-SPAM in the email subject." }) .GoAsync(); Console.WriteLine(String.Join(Environment.NewLine, loggerFactory.Messages)); Console.WriteLine(getContactDetails()?.Email); foreach (var line in report.Lines) { Console.WriteLine(line.Message); } report.EnsureSuccess(); }
public static IWaveStart Wave(SurfContext journeyContext) { if (journeyContext == null) { throw new ArgumentNullException(nameof(journeyContext)); } return(new Surf(journeyContext)); }
public Surf(SurfContext journeyContext) : base(journeyContext, new SimpleJsonResourceReaderWriter(journeyContext)) { }
internal ReadStep <TModel> GetReadStep <TModel>(SurfContext context, TModel[] models) where TModel : class { return(new ReadStep <TModel>(this.CreateStepContext(context), models)); }
private HttpStepContext CreateStepContext(SurfContext context) { return(new HttpStepContext(this.HttpClient, context, this.ResourceFormatter)); }
protected internal virtual IStep GetToItemStep(int index, SurfContext context) { return(new ToItemStep(this.CreateStepContext(context), index)); }
protected internal virtual IStep GetSubmitStep(string rel, object transferObject, SurfContext context) { return(new SubmitStep(this.CreateStepContext(context), rel, transferObject)); }
protected internal virtual IStep GetToStep(string rel, SurfContext context) { return(new ToStep(this.CreateStepContext(context), rel)); }
// protected internal virtual IStep GetFromStep(string uri, SurfContext context) { return(new FromStep(this.CreateStepContext(context), uri ?? context.RootUri.ToString())); }
public StepFactory(SurfContext context, IHypertextResourceFormatter resourceFormatter) { this.SurfContext = context ?? throw new ArgumentNullException(nameof(context)); this.ResourceFormatter = resourceFormatter ?? throw new ArgumentNullException(nameof(resourceFormatter)); }
protected WaveBuilder(SurfContext context, StepFactory stepFactory) { this.SurfContext = context ?? throw new ArgumentNullException(nameof(context)); this.StepFactory = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory)); }
protected WaveBuilder(SurfContext context, IHypertextResourceFormatter resourceFormatter) { this.SurfContext = context ?? throw new ArgumentNullException(nameof(context)); this.StepFactory = new StepFactory(context, resourceFormatter); }