Skip to content

Commit

Permalink
Added support for Notes
Browse files Browse the repository at this point in the history
  • Loading branch information
petefox committed May 9, 2023
1 parent 07d8ecf commit aa41c04
Show file tree
Hide file tree
Showing 50 changed files with 225 additions and 52 deletions.
6 changes: 5 additions & 1 deletion src/Close/Close.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Polly.Extensions.Http" Version="3.0.0" />
</ItemGroup>
Expand All @@ -37,5 +37,9 @@
<None Include="../../icon.png" Pack="true" PackagePath="\" />
<None Include="../../README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\Activities\" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/Close/CloseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface ICloseClient
Opportunities Opportunities { get; }
OpportunityStatuses OpportunityStatuses { get; }
Pipelines Pipelines { get; }
Activity Activity { get; }
}

public class CloseClient : ICloseClient
Expand All @@ -25,4 +26,5 @@ public CloseClient(HttpClient httpClient)
public Opportunities Opportunities => new(this, "opportunity");
public OpportunityStatuses OpportunityStatuses => new(this, "status/opportunity");
public Pipelines Pipelines => new(this, "pipeline");
public Activity Activity => new(this, "activity");
}
2 changes: 1 addition & 1 deletion src/Close/Extensions/ParameterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Common;
using Close.Services.Interfaces;

namespace Close.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Extensions/UriExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Web;
using Close.Interfaces;
using Close.Models.Common;
using Close.Services.Interfaces;

namespace Close.Extensions;

Expand Down
13 changes: 13 additions & 0 deletions src/Close/Helpers/ActivityService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Close.Interfaces;

namespace Close.Helpers;

public abstract class ActivityService<TEntity> where TEntity : ICloseEntity
{
protected Request<TEntity> _request;

public ActivityService(CloseClient closeClient, string endpoint)
{
_request = new Request<TEntity>(closeClient, endpoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Close.Extensions;
using Close.Helpers;
using Close.Interfaces;
using Close.Models.Common;
using Close.Services.Interfaces;

namespace Close.Services;
namespace Close.Helpers;

public class Request<TEntity> where TEntity : ICloseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Services;
namespace Close.Helpers;

public abstract class Service<TEntity> where TEntity : ICloseEntity
{
Expand All @@ -10,5 +10,4 @@ public Service(CloseClient closeClient, string endpoint)
{
_request = new Request<TEntity>(closeClient, endpoint);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface ICloseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Close.Models.Common;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface ICreatable<TEntity, TCreateOptions> where TEntity : ICloseEntity where TCreateOptions : ICreateOptions, new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface ICreateOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Close.Services.Interfaces;
namespace Close.Interfaces;

internal interface IDeletable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IHasCreatedBy
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IHasUpdatedBy
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Close.Models.Common;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IListable<TEntity> where TEntity : ICloseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IRequestOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Close.Models.Common;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IRetrievable<TEntity> where TEntity : ICloseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Close.Models.Common;

namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IUpdatable<TEntity, TUpdateOptions> where TEntity : ICloseEntity where TUpdateOptions : IUpdateOptions, new()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Close.Services.Interfaces;
namespace Close.Interfaces;

public interface IUpdateOptions
{
Expand Down
46 changes: 46 additions & 0 deletions src/Close/Models/Activities/Notes/Note.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Text.Json.Serialization;
using Close.Interfaces;

namespace Close.Models.Activities.Notes;

public class Note : ICloseEntity, IHasCreatedBy, IHasUpdatedBy
{
[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("lead_id")]
public string LeadId { get; set; }

[JsonPropertyName("user_id")]
public string UserId { get; set; }

[JsonPropertyName("user_name")]
public string UserName { get; set; }

[JsonPropertyName("organization_id")]
public string OrganizationId { get; set; }

[JsonPropertyName("contact_id")]
public string ContactId { get; set; }

[JsonPropertyName("note_html")]
public string NoteHtml { get; set; }

[JsonPropertyName("created_by_name")]
public string CreatedByName { get; set; }

[JsonPropertyName("date_created")]
public DateTimeOffset DateCreated { get; set; }

[JsonPropertyName("created_by")]
public string CreatedBy { get; set; }

[JsonPropertyName("updated_by_name")]
public string UpdatedByName { get; set; }

[JsonPropertyName("date_updated")]
public DateTimeOffset? DateUpdated { get; set; }

[JsonPropertyName("updated_by")]
public string UpdatedBy { get; set; }
}
16 changes: 16 additions & 0 deletions src/Close/Models/Activities/Notes/NoteCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
using Close.Interfaces;

namespace Close.Models.Activities.Notes;

public class NoteCreateOptions : ICreateOptions
{
[JsonPropertyName("lead_id")]
public string LeadId { get; set; }

[JsonPropertyName("note")]
public string Note { get; set; }

[JsonPropertyName("note_html")]
public string NoteHtml { get; set; }
}
22 changes: 22 additions & 0 deletions src/Close/Models/Activities/Notes/NoteListOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
using Close.Models.Common;

namespace Close.Models.Activities.Notes;

public class NoteListOptions : IListOptions
{
[JsonPropertyName("_skip")]
public int? Skip { get; set; }

[JsonPropertyName("_limit")]
public int? Limit { get; set; }

[JsonPropertyName("_fields")]
public string[] Fields { get; set; }

[JsonPropertyName("query")]
public string Query { get; set; }

[JsonPropertyName("lead_saved_search_id")]
public string LeadSavedSearchId { get; set; }
}
13 changes: 13 additions & 0 deletions src/Close/Models/Activities/Notes/NoteUpdateOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
using Close.Interfaces;

namespace Close.Models.Activities.Notes;

public class NoteUpdateOptions : IUpdateOptions
{
[JsonPropertyName("note")]
public string Note { get; set; }

[JsonPropertyName("note_html")]
public string NoteHtml { get; set; }
}
2 changes: 1 addition & 1 deletion src/Close/Models/Common/CloseList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Common;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Common/IListOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Common;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Contacts/Contact.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Common;
using Close.Services.Interfaces;

namespace Close.Models.Contacts;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Events/Event.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Common;
using Close.Services.Interfaces;

namespace Close.Models.Events;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Leads/Lead.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Common;
using Close.Models.Contacts;
using Close.Models.Opportunities;
using Close.Services.Interfaces;

namespace Close.Models.Leads;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Leads/LeadCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Contacts;
using Close.Services.Interfaces;

namespace Close.Models.Leads;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Leads/LeadUpdateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Contacts;
using Close.Services.Interfaces;

namespace Close.Models.Leads;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Opportunities/Opportunity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Common;
using Close.Models.Statuses;
using Close.Services.Interfaces;

namespace Close.Models.Opportunities;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Opportunities/OpportunityCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Opportunities;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Opportunities/OpportunityUpdateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Opportunities;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Pipelines/Pipeline.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;
using Close.Interfaces;
using Close.Models.Statuses;
using Close.Services.Interfaces;

namespace Close.Models.Pipelines;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Pipelines/PipelineCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Pipelines;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Pipelines/PipelineUpdateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Pipelines;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Statuses/LeadStatus.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Statuses;

Expand Down
2 changes: 1 addition & 1 deletion src/Close/Models/Statuses/LeadStatusCreateOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text.Json.Serialization;
using Close.Services.Interfaces;
using Close.Interfaces;

namespace Close.Models.Statuses;

Expand Down
Loading

0 comments on commit aa41c04

Please sign in to comment.