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: 1 addition & 5 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
"namespace": "SchematicHQ.Client",
"client-class-name": "SchematicApi",
"exported-client-class-name": "Schematic",
"extra-dependencies": {
"moq": "4.20.70",
"Moq.Contrib.HttpClient": "1.4.0"
},
"generate-mock-server-tests": false
},
"originGitCommit": "efe71642022d9d3303fd78c648e5b2539192230e",
"originGitCommit": "470e0f433ab9bb0e88784674fa2e1efce62ebd9b",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "1.4.6",
Expand Down
10 changes: 10 additions & 0 deletions .fern/replay.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ src/SchematicHQ.Client/SchematicHQ.Client.Custom.props
src/SchematicHQ.Client/Webhooks/WebhookUtils/
src/SchematicHQ.Client/OpenFeature/
src/SchematicHQ.Client/generate-schema-hash.sh
.fern/replay.lock
.fern/replay.yml
.gitattributes
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.fern/replay.lock linguist-generated=true
189 changes: 189 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,46 @@ await client.Billing.UpsertPaymentMethodAsync(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.Billing.<a href="/src/SchematicHQ.Client/Billing/BillingClient.cs">DeletePaymentMethodByExternalIdAsync</a>(billingId) -> WithRawResponseTask&lt;DeletePaymentMethodByExternalIdResponse&gt;</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```csharp
await client.Billing.DeletePaymentMethodByExternalIdAsync("billing_id");
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**billingId:** `string` — billing_id

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down Expand Up @@ -2672,6 +2712,155 @@ await client.Credits.ListGrantsForCreditAsync(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.Credits.<a href="/src/SchematicHQ.Client/Credits/CreditsClient.cs">AcquireCreditLeaseAsync</a>(AcquireCreditLeaseRequestBody { ... }) -> WithRawResponseTask&lt;AcquireCreditLeaseResponse&gt;</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```csharp
await client.Credits.AcquireCreditLeaseAsync(
new AcquireCreditLeaseRequestBody
{
CompanyId = "company_id",
CreditTypeId = "credit_type_id",
RequestedAmount = 1.1,
}
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**request:** `AcquireCreditLeaseRequestBody`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.Credits.<a href="/src/SchematicHQ.Client/Credits/CreditsClient.cs">ExtendCreditLeaseAsync</a>(leaseId, ExtendCreditLeaseRequestBody { ... }) -> WithRawResponseTask&lt;ExtendCreditLeaseResponse&gt;</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```csharp
await client.Credits.ExtendCreditLeaseAsync(
"lease_id",
new ExtendCreditLeaseRequestBody { AdditionalAmount = 1.1 }
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**leaseId:** `string` — lease_id

</dd>
</dl>

<dl>
<dd>

**request:** `ExtendCreditLeaseRequestBody`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.Credits.<a href="/src/SchematicHQ.Client/Credits/CreditsClient.cs">ReleaseCreditLeaseAsync</a>(leaseId, Dictionary&lt;string, object?&gt; { ... }) -> WithRawResponseTask&lt;ReleaseCreditLeaseResponse&gt;</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```csharp
await client.Credits.ReleaseCreditLeaseAsync(
"lease_id",
new Dictionary<string, object?>() { { "key", "value" } }
);
```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**leaseId:** `string` — lease_id

</dd>
</dl>

<dl>
<dd>

**request:** `Dictionary<string, object?>`

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
108 changes: 108 additions & 0 deletions src/SchematicHQ.Client/Billing/BillingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,100 @@ private async Task<WithRawResponse<UpsertPaymentMethodResponse>> UpsertPaymentMe
}
}

private async Task<
WithRawResponse<DeletePaymentMethodByExternalIdResponse>
> DeletePaymentMethodByExternalIdAsyncCore(
string billingId,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder()
.Add(_client.Options.Headers)
.Add(_client.Options.AdditionalHeaders)
.Add(options?.AdditionalHeaders)
.BuildAsync()
.ConfigureAwait(false);
var response = await _client
.SendRequestAsync(
new JsonRequest
{
Method = HttpMethod.Delete,
Path = string.Format(
"billing/payment-methods/{0}",
ValueConvert.ToPathParameterString(billingId)
),
Headers = _headers,
Options = options,
},
cancellationToken
)
.ConfigureAwait(false);
if (response.StatusCode is >= 200 and < 400)
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
var responseData = JsonUtils.Deserialize<DeletePaymentMethodByExternalIdResponse>(
responseBody
)!;
return new WithRawResponse<DeletePaymentMethodByExternalIdResponse>()
{
Data = responseData,
RawResponse = new RawResponse()
{
StatusCode = response.Raw.StatusCode,
Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"),
Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw),
},
};
}
catch (JsonException e)
{
throw new SchematicApiException(
"Failed to deserialize response",
response.StatusCode,
responseBody,
e
);
}
}
{
var responseBody = await response
.Raw.Content.ReadAsStringAsync(cancellationToken)
.ConfigureAwait(false);
try
{
switch (response.StatusCode)
{
case 400:
throw new BadRequestError(JsonUtils.Deserialize<ApiError>(responseBody));
case 401:
throw new UnauthorizedError(JsonUtils.Deserialize<ApiError>(responseBody));
case 403:
throw new ForbiddenError(JsonUtils.Deserialize<ApiError>(responseBody));
case 404:
throw new NotFoundError(JsonUtils.Deserialize<ApiError>(responseBody));
case 500:
throw new InternalServerError(
JsonUtils.Deserialize<ApiError>(responseBody)
);
}
}
catch (JsonException)
{
// unable to map error response, throwing generic error
}
throw new SchematicApiException(
$"Error with status code {response.StatusCode}",
response.StatusCode,
responseBody
);
}
}

private async Task<WithRawResponse<ListBillingPricesResponse>> ListBillingPricesAsyncCore(
ListBillingPricesRequest request,
RequestOptions? options = null,
Expand Down Expand Up @@ -2180,6 +2274,20 @@ public WithRawResponseTask<UpsertPaymentMethodResponse> UpsertPaymentMethodAsync
);
}

/// <example><code>
/// await client.Billing.DeletePaymentMethodByExternalIdAsync("billing_id");
/// </code></example>
public WithRawResponseTask<DeletePaymentMethodByExternalIdResponse> DeletePaymentMethodByExternalIdAsync(
string billingId,
RequestOptions? options = null,
CancellationToken cancellationToken = default
)
{
return new WithRawResponseTask<DeletePaymentMethodByExternalIdResponse>(
DeletePaymentMethodByExternalIdAsyncCore(billingId, options, cancellationToken)
);
}

/// <example><code>
/// await client.Billing.ListBillingPricesAsync(
/// new ListBillingPricesRequest
Expand Down
6 changes: 6 additions & 0 deletions src/SchematicHQ.Client/Billing/IBillingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ WithRawResponseTask<UpsertPaymentMethodResponse> UpsertPaymentMethodAsync(
CancellationToken cancellationToken = default
);

WithRawResponseTask<DeletePaymentMethodByExternalIdResponse> DeletePaymentMethodByExternalIdAsync(
string billingId,
RequestOptions? options = null,
CancellationToken cancellationToken = default
);

WithRawResponseTask<ListBillingPricesResponse> ListBillingPricesAsync(
ListBillingPricesRequest request,
RequestOptions? options = null,
Expand Down
Loading
Loading