Table of Contents

Class VonageRequestBuilder

Namespace
Vonage.Common.Client
Assembly
Vonage.dll

Fluent builder for constructing HttpRequestMessage instances for Vonage API requests.

public class VonageRequestBuilder
Inheritance
VonageRequestBuilder
Inherited Members

Examples

var request = VonageRequestBuilder
    .Initialize(HttpMethod.Post, "/v1/messages")
    .WithContent(new StringContent(json, Encoding.UTF8, "application/json"))
    .Build();

Remarks

This builder simplifies the creation of HTTP requests with proper method, URI, and content configuration.

Methods

Build()

Builds and returns the configured HttpRequestMessage.

public HttpRequestMessage Build()

Returns

HttpRequestMessage

The configured HTTP request message ready to be sent.

Initialize(HttpMethod, string)

Initializes a new request builder with the specified HTTP method and relative endpoint URI.

public static VonageRequestBuilder Initialize(HttpMethod method, string endpointUri)

Parameters

method HttpMethod

The HTTP method (GET, POST, PUT, DELETE, etc.).

endpointUri string

The relative URI path for the API endpoint.

Returns

VonageRequestBuilder

A new VonageRequestBuilder instance.

Examples

var builder = VonageRequestBuilder.Initialize(HttpMethod.Get, "/v1/accounts");

Initialize(HttpMethod, Uri)

Initializes a new request builder with the specified HTTP method and URI.

public static VonageRequestBuilder Initialize(HttpMethod method, Uri uri)

Parameters

method HttpMethod

The HTTP method (GET, POST, PUT, DELETE, etc.).

uri Uri

The URI for the API endpoint.

Returns

VonageRequestBuilder

A new VonageRequestBuilder instance.

WithContent(HttpContent)

Sets the HTTP content (body) for the request.

public VonageRequestBuilder WithContent(HttpContent content)

Parameters

content HttpContent

The HTTP content to include in the request. If null, no content is set.

Returns

VonageRequestBuilder

This builder instance for method chaining.

Examples

builder.WithContent(new StringContent("{\"text\":\"Hello\"}", Encoding.UTF8, "application/json"));