-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
- Loading branch information
1 parent
217bb47
commit f7f8932
Showing
51 changed files
with
1,413 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/SchematicHQ.Client/Companies/Requests/GetActiveDealsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace SchematicHQ.Client; | ||
|
||
public class GetActiveDealsRequest | ||
{ | ||
public string CompanyId { get; init; } | ||
|
||
public string DealStage { get; init; } | ||
|
||
/// <summary> | ||
/// Page limit (default 100) | ||
/// </summary> | ||
public int? Limit { get; init; } | ||
|
||
/// <summary> | ||
/// Page offset (default 0) | ||
/// </summary> | ||
public int? Offset { get; init; } | ||
} |
20 changes: 20 additions & 0 deletions
20
src/SchematicHQ.Client/Companies/Types/GetActiveDealsParams.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class GetActiveDealsParams | ||
{ | ||
[JsonPropertyName("company_id")] | ||
public string? CompanyId { get; init; } | ||
|
||
[JsonPropertyName("deal_stage")] | ||
public string? DealStage { get; init; } | ||
|
||
[JsonPropertyName("limit")] | ||
public int? Limit { get; init; } | ||
|
||
[JsonPropertyName("offset")] | ||
public int? Offset { get; init; } | ||
} |
21 changes: 21 additions & 0 deletions
21
src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
using SchematicHQ.Client; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class GetActiveDealsResponse | ||
{ | ||
/// <summary> | ||
/// The returned resources | ||
/// </summary> | ||
[JsonPropertyName("data")] | ||
public List<CompanyCrmDealsResponseData> Data { get; init; } | ||
|
||
/// <summary> | ||
/// Input parameters | ||
/// </summary> | ||
[JsonPropertyName("params")] | ||
public GetActiveDealsParams Params { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System.Text.Json; | ||
using SchematicHQ.Client; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class CrmClient | ||
{ | ||
private RawClient _client; | ||
|
||
public CrmClient(RawClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
public async Task<UpsertDealLineItemAssociationResponse> UpsertDealLineItemAssociationAsync( | ||
CreateCrmDealLineItemAssociationRequestBody request | ||
) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/crm/associations/deal-line-item", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<UpsertDealLineItemAssociationResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
|
||
public async Task<UpsertLineItemResponse> UpsertLineItemAsync( | ||
CreateCrmLineItemRequestBody request | ||
) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/crm/deal-line-item/upsert", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<UpsertLineItemResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
|
||
public async Task<UpsertCrmDealResponse> UpsertCrmDealAsync(CreateCrmDealRequestBody request) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/crm/deals/upsert", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<UpsertCrmDealResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
|
||
public async Task<ListCrmProductsResponse> ListCrmProductsAsync(ListCrmProductsRequest request) | ||
{ | ||
var _query = new Dictionary<string, object>() { }; | ||
if (request.Ids != null) | ||
{ | ||
_query["ids"] = request.Ids; | ||
} | ||
if (request.Name != null) | ||
{ | ||
_query["name"] = request.Name; | ||
} | ||
if (request.Limit != null) | ||
{ | ||
_query["limit"] = request.Limit; | ||
} | ||
if (request.Offset != null) | ||
{ | ||
_query["offset"] = request.Offset; | ||
} | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Get, | ||
Path = "/crm/products", | ||
Query = _query | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<ListCrmProductsResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
|
||
public async Task<UpsertCrmProductResponse> UpsertCrmProductAsync( | ||
CreateCrmProductRequestBody request | ||
) | ||
{ | ||
var response = await _client.MakeRequestAsync( | ||
new RawClient.ApiRequest | ||
{ | ||
Method = HttpMethod.Post, | ||
Path = "/crm/products/upsert", | ||
Body = request | ||
} | ||
); | ||
string responseBody = await response.Raw.Content.ReadAsStringAsync(); | ||
if (response.StatusCode >= 200 && response.StatusCode < 400) | ||
{ | ||
return JsonSerializer.Deserialize<UpsertCrmProductResponse>(responseBody); | ||
} | ||
throw new Exception(responseBody); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/SchematicHQ.Client/Crm/Requests/CreateCrmDealLineItemAssociationRequestBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class CreateCrmDealLineItemAssociationRequestBody | ||
{ | ||
[JsonPropertyName("deal_external_id")] | ||
public string DealExternalId { get; init; } | ||
|
||
[JsonPropertyName("line_item_external_id")] | ||
public string LineItemExternalId { get; init; } | ||
} |
35 changes: 35 additions & 0 deletions
35
src/SchematicHQ.Client/Crm/Requests/CreateCrmDealRequestBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class CreateCrmDealRequestBody | ||
{ | ||
[JsonPropertyName("arr")] | ||
public string? Arr { get; init; } | ||
|
||
[JsonPropertyName("crm_company_id")] | ||
public string? CrmCompanyId { get; init; } | ||
|
||
[JsonPropertyName("crm_company_key")] | ||
public string CrmCompanyKey { get; init; } | ||
|
||
[JsonPropertyName("crm_product_id")] | ||
public string? CrmProductId { get; init; } | ||
|
||
[JsonPropertyName("crm_type")] | ||
public string CrmType { get; init; } | ||
|
||
[JsonPropertyName("deal_external_id")] | ||
public string DealExternalId { get; init; } | ||
|
||
[JsonPropertyName("deal_name")] | ||
public string? DealName { get; init; } | ||
|
||
[JsonPropertyName("deal_stage")] | ||
public string? DealStage { get; init; } | ||
|
||
[JsonPropertyName("mrr")] | ||
public string? Mrr { get; init; } | ||
} |
32 changes: 32 additions & 0 deletions
32
src/SchematicHQ.Client/Crm/Requests/CreateCrmLineItemRequestBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class CreateCrmLineItemRequestBody | ||
{ | ||
[JsonPropertyName("TermMonth")] | ||
public int? TermMonth { get; init; } | ||
|
||
[JsonPropertyName("amount")] | ||
public string Amount { get; init; } | ||
|
||
[JsonPropertyName("discount_percentage")] | ||
public string? DiscountPercentage { get; init; } | ||
|
||
[JsonPropertyName("interval")] | ||
public string Interval { get; init; } | ||
|
||
[JsonPropertyName("line_item_external_id")] | ||
public string LineItemExternalId { get; init; } | ||
|
||
[JsonPropertyName("product_external_id")] | ||
public string ProductExternalId { get; init; } | ||
|
||
[JsonPropertyName("quantity")] | ||
public int Quantity { get; init; } | ||
|
||
[JsonPropertyName("total_discount")] | ||
public string? TotalDiscount { get; init; } | ||
} |
32 changes: 32 additions & 0 deletions
32
src/SchematicHQ.Client/Crm/Requests/CreateCrmProductRequestBody.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
#nullable enable | ||
|
||
namespace SchematicHQ.Client; | ||
|
||
public class CreateCrmProductRequestBody | ||
{ | ||
[JsonPropertyName("currency")] | ||
public string Currency { get; init; } | ||
|
||
[JsonPropertyName("description")] | ||
public string Description { get; init; } | ||
|
||
[JsonPropertyName("external_id")] | ||
public string ExternalId { get; init; } | ||
|
||
[JsonPropertyName("interval")] | ||
public string Interval { get; init; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; init; } | ||
|
||
[JsonPropertyName("price")] | ||
public string Price { get; init; } | ||
|
||
[JsonPropertyName("quantity")] | ||
public int Quantity { get; init; } | ||
|
||
[JsonPropertyName("sku")] | ||
public string Sku { get; init; } | ||
} |
18 changes: 18 additions & 0 deletions
18
src/SchematicHQ.Client/Crm/Requests/ListCrmProductsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace SchematicHQ.Client; | ||
|
||
public class ListCrmProductsRequest | ||
{ | ||
public string? Ids { get; init; } | ||
|
||
public string? Name { get; init; } | ||
|
||
/// <summary> | ||
/// Page limit (default 100) | ||
/// </summary> | ||
public int? Limit { get; init; } | ||
|
||
/// <summary> | ||
/// Page offset (default 0) | ||
/// </summary> | ||
public int? Offset { get; init; } | ||
} |
Oops, something went wrong.