Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 238
openapi_spec_hash: fa67b808ca579e929aea7dd917b18cf9
config_hash: 2ae0d8aaecf01b38cbf9f9e112822c23
configured_endpoints: 239
openapi_spec_hash: 202e0c39463e4ad1b25a72b0da68a6ce
config_hash: 1ca082e374ef7000e2a5971e8da740e0
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,34 @@ To send a request to the Increase API, build an instance of some `Params` class

For example, `client.Accounts.Create` should be called with an instance of `AccountCreateParams`, and it will return an instance of `Task<Account>`.

## Binary responses

The SDK defines methods that return binary responses, which are used for API responses that shouldn't necessarily be parsed, like non-JSON data.

These methods return `HttpResponse`:

```csharp
using System;
using Increase.Api.Models.Files;

FileContentsParams parameters = new() { FileID = "file_makxrc67oh9l6sg7w9yc" };

var response = await client.Files.Contents(parameters);

Console.WriteLine(response);
```

To save the response content to a file, or any [`Stream`](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream?view=net-9.0), use the [`CopyToAsync`](<https://learn.microsoft.com/en-us/dotnet/api/system.io.stream.copytoasync?view=net-9.0#system-io-stream-copytoasync(system-io-stream)>) method:

```csharp
using System.IO;

using var response = await client.Files.Contents(parameters);
using var contentStream = await response.ReadAsStream();
using var fileStream = File.Open(path, FileMode.OpenOrCreate);
await contentStream.CopyToAsync(fileStream); // Or any other Stream
```

## Raw responses

The SDK defines methods that deserialize responses into instances of C# classes. However, these methods don't provide access to the response headers, status code, or the raw response body.
Expand Down
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public void FieldRoundtrip_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -66,8 +66,8 @@ public void FieldRoundtrip_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -126,8 +126,8 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -180,8 +180,8 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -237,8 +237,8 @@ public void Url_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -294,8 +294,8 @@ public void CopyConstructor_Works()
Address = new()
{
City = "New York",
Line1 = "33 Liberty Street",
Country = "US",
Line1 = "33 Liberty Street",
Line2 = "x",
State = "NY",
Zip = "10045",
Expand Down Expand Up @@ -350,8 +350,8 @@ public void FieldRoundtrip_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -390,8 +390,8 @@ public void FieldRoundtrip_Works()
Address expectedAddress = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -441,8 +441,8 @@ public void SerializationRoundtrip_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -495,8 +495,8 @@ public void FieldRoundtripThroughSerialization_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -542,8 +542,8 @@ public void FieldRoundtripThroughSerialization_Works()
Address expectedAddress = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -593,8 +593,8 @@ public void Validation_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -641,8 +641,8 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -689,8 +689,8 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -736,8 +736,8 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -787,8 +787,8 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -837,8 +837,8 @@ public void CopyConstructor_Works()
Address = new()
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down Expand Up @@ -888,23 +888,23 @@ public void FieldRoundtrip_Works()
var model = new Address
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
};

string expectedCity = "x";
string expectedLine1 = "x";
string expectedCountry = "x";
string expectedLine1 = "x";
string expectedLine2 = "x";
string expectedState = "x";
string expectedZip = "x";

Assert.Equal(expectedCity, model.City);
Assert.Equal(expectedLine1, model.Line1);
Assert.Equal(expectedCountry, model.Country);
Assert.Equal(expectedLine1, model.Line1);
Assert.Equal(expectedLine2, model.Line2);
Assert.Equal(expectedState, model.State);
Assert.Equal(expectedZip, model.Zip);
Expand All @@ -916,8 +916,8 @@ public void SerializationRoundtrip_Works()
var model = new Address
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand All @@ -935,8 +935,8 @@ public void FieldRoundtripThroughSerialization_Works()
var model = new Address
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand All @@ -950,15 +950,15 @@ public void FieldRoundtripThroughSerialization_Works()
Assert.NotNull(deserialized);

string expectedCity = "x";
string expectedLine1 = "x";
string expectedCountry = "x";
string expectedLine1 = "x";
string expectedLine2 = "x";
string expectedState = "x";
string expectedZip = "x";

Assert.Equal(expectedCity, deserialized.City);
Assert.Equal(expectedLine1, deserialized.Line1);
Assert.Equal(expectedCountry, deserialized.Country);
Assert.Equal(expectedLine1, deserialized.Line1);
Assert.Equal(expectedLine2, deserialized.Line2);
Assert.Equal(expectedState, deserialized.State);
Assert.Equal(expectedZip, deserialized.Zip);
Expand All @@ -970,8 +970,8 @@ public void Validation_Works()
var model = new Address
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand All @@ -983,10 +983,13 @@ public void Validation_Works()
[Fact]
public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
{
var model = new Address { City = "x", Line1 = "x" };
var model = new Address
{
City = "x",
Country = "x",
Line1 = "x",
};

Assert.Null(model.Country);
Assert.False(model.RawData.ContainsKey("country"));
Assert.Null(model.Line2);
Assert.False(model.RawData.ContainsKey("line2"));
Assert.Null(model.State);
Expand All @@ -998,7 +1001,12 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
[Fact]
public void OptionalNonNullablePropertiesUnsetValidation_Works()
{
var model = new Address { City = "x", Line1 = "x" };
var model = new Address
{
City = "x",
Country = "x",
Line1 = "x",
};

model.Validate();
}
Expand All @@ -1009,17 +1017,15 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works()
var model = new Address
{
City = "x",
Country = "x",
Line1 = "x",

// Null should be interpreted as omitted for these properties
Country = null,
Line2 = null,
State = null,
Zip = null,
};

Assert.Null(model.Country);
Assert.False(model.RawData.ContainsKey("country"));
Assert.Null(model.Line2);
Assert.False(model.RawData.ContainsKey("line2"));
Assert.Null(model.State);
Expand All @@ -1034,10 +1040,10 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works()
var model = new Address
{
City = "x",
Country = "x",
Line1 = "x",

// Null should be interpreted as omitted for these properties
Country = null,
Line2 = null,
State = null,
Zip = null,
Expand All @@ -1052,8 +1058,8 @@ public void CopyConstructor_Works()
var model = new Address
{
City = "x",
Line1 = "x",
Country = "x",
Line1 = "x",
Line2 = "x",
State = "x",
Zip = "x",
Expand Down
Loading