Skip to content

Commit

Permalink
Renamed to "page properties" added support for OmitBackground and Gen…
Browse files Browse the repository at this point in the history
…erateDocumentOutline.
  • Loading branch information
Jaben committed Feb 7, 2025
1 parent a2a9a8c commit e0d6289
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 245 deletions.
32 changes: 27 additions & 5 deletions lib/Domain/Builders/BaseChromiumBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,44 @@ public abstract class BaseChromiumBuilder<TRequest, TBuilder>(TRequest request)
where TRequest : ChromeRequest
where TBuilder : BaseChromiumBuilder<TRequest, TBuilder>
{
public TBuilder WithDimensions(Action<DimensionBuilder> action)
[Obsolete("Use WithPageProperties")]
public TBuilder WithDimensions(Action<PagePropertyBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));

var builder = new DimensionBuilder(this.Request.Dimensions);
var builder = new PagePropertyBuilder(this.Request.PageProperties);

action(builder);

this.Request.Dimensions = builder.GetDimensions();
this.Request.PageProperties = builder.GetPageProperties();

return (TBuilder)this;
}

public TBuilder WithDimensions(Dimensions dimensions)
[Obsolete("Use WithPageProperties")]
public TBuilder WithDimensions(PageProperties pageProperties)
{
this.Request.Dimensions = dimensions ?? throw new ArgumentNullException(nameof(dimensions));
this.Request.PageProperties = pageProperties ?? throw new ArgumentNullException(nameof(pageProperties));
return (TBuilder)this;
}

public TBuilder WithPageProperties(Action<PagePropertyBuilder> action)
{
if (action == null) throw new ArgumentNullException(nameof(action));

var builder = new PagePropertyBuilder(this.Request.PageProperties);

action(builder);

this.Request.PageProperties = builder.GetPageProperties();

return (TBuilder)this;
}

public TBuilder WithPageProperties(PageProperties pageProperties)
{
this.Request.PageProperties = pageProperties ?? throw new ArgumentNullException(nameof(pageProperties));

return (TBuilder)this;
}

Expand Down
147 changes: 0 additions & 147 deletions lib/Domain/Builders/Faceted/DimensionBuilder.cs

This file was deleted.

17 changes: 1 addition & 16 deletions lib/Domain/Builders/Faceted/DocumentBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2024 Chris Mohan, Jaben Cargman
// Copyright 2019-2025 Chris Mohan, Jaben Cargman
// and GotenbergSharpApiClient Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,8 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.



namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;

/// <summary>
Expand All @@ -36,33 +34,28 @@ public DocumentBuilder(FullDocument content, Action<bool> setContainsMarkdown)

#region body


public DocumentBuilder ContainsMarkdown(bool containsMarkdown = true)
{
this._setContainsMarkdown(containsMarkdown);
return this;
}


public DocumentBuilder SetBody(ContentItem body)
{
this._content.Body = body ?? throw new ArgumentNullException(nameof(body));
return this;
}


public DocumentBuilder SetBody(string body)
{
return this.SetBody(new ContentItem(body));
}


public DocumentBuilder SetBody(byte[] body)
{
return this.SetBody(new ContentItem(body));
}


public DocumentBuilder SetBody(Stream body)
{
return this.SetBody(new ContentItem(body));
Expand All @@ -72,26 +65,22 @@ public DocumentBuilder SetBody(Stream body)

#region header


public DocumentBuilder SetHeader(ContentItem header)
{
this._content.Header = header ?? throw new ArgumentNullException(nameof(header));
return this;
}


public DocumentBuilder SetHeader(string header)
{
return this.SetHeader(new ContentItem(header));
}


public DocumentBuilder SetHeader(byte[] header)
{
return this.SetHeader(new ContentItem(header));
}


public DocumentBuilder SetHeader(Stream header)
{
return this.SetHeader(new ContentItem(header));
Expand All @@ -101,26 +90,22 @@ public DocumentBuilder SetHeader(Stream header)

#region footer


public DocumentBuilder SetFooter(ContentItem footer)
{
this._content.Footer = footer ?? throw new ArgumentNullException(nameof(footer));
return this;
}


public DocumentBuilder SetFooter(string footer)
{
return this.SetFooter(new ContentItem(footer));
}


public DocumentBuilder SetFooter(byte[] footer)
{
return this.SetFooter(new ContentItem(footer));
}


public DocumentBuilder SetFooter(Stream footer)
{
return this.SetFooter(new ContentItem(footer));
Expand Down
Loading

0 comments on commit e0d6289

Please sign in to comment.