Skip to content

Commit

Permalink
Implemented call activity
Browse files Browse the repository at this point in the history
  • Loading branch information
petefox committed May 12, 2023
1 parent 433bcf6 commit 918fa4b
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/Close/Close.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>disable</Nullable>
<AssemblyName>Close</AssemblyName>
<RootNamespace>Close</RootNamespace>
<Version>0.1.4</Version>
<Version>0.1.5</Version>
<Authors>Peter Schroeder</Authors>
<Company>Telzio, Inc.</Company>
<Copyright>© 2013-2023 Telzio, Inc.</Copyright>
Expand Down Expand Up @@ -37,9 +37,5 @@
<None Include="../../icon.png" Pack="true" PackagePath="\" />
<None Include="../../README.md" Pack="true" PackagePath="\" />
</ItemGroup>

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

</Project>
160 changes: 160 additions & 0 deletions src/Close/Models/Activities/Calls/Call.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
using System.Text.Json.Serialization;
using Close.Interfaces;

namespace Close.Models.Activities.Calls;

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

[JsonPropertyName("lead_id")]
public string LeadId { 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; }

[JsonPropertyName("is_to_group_number")]
public bool IsToGroupNumber { get; set; }

[JsonPropertyName("local_phone_formatted")]
public string LocalPhoneFormatted { get; set; }

[JsonPropertyName("transferred_from_user_id")]
public string TransferredFromUserId { get; set; }

[JsonPropertyName("transferred_from")]
public string TransferredFrom { get; set; }

[JsonPropertyName("quality_info")]
public string QualityInfo { get; set; }

[JsonPropertyName("activity_at")]
public DateTimeOffset ActivityAt { get; set; }

[JsonPropertyName("sequence_id")]
public string SequenceId { get; set; }

[JsonPropertyName("disposition")]
public string Disposition { get; set; }

[JsonPropertyName("local_phone")]
public string LocalPhone { get; set; }

[JsonPropertyName("direction")]
public string Direction { get; set; }

[JsonPropertyName("recording_url")]
public string RecordingUrl { get; set; }

[JsonPropertyName("local_country_iso")]
public string LocalCountryIso { get; set; }

[JsonPropertyName("users")]
public List<string> Users { get; set; }

[JsonPropertyName("date_answered")]
public DateTimeOffset? DateAnswered { get; set; }

[JsonPropertyName("transferred_to")]
public string TransferredTo { get; set; }

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

[JsonPropertyName("call_method")]
public string CallMethod { get; set; }

[JsonPropertyName("is_forwarded")]
public bool IsForwarded { get; set; }

[JsonPropertyName("source")]
public string Source { get; set; }

[JsonPropertyName("sequence_subscription_id")]
public string SequenceSubscriptionId { get; set; }

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

[JsonPropertyName("sequence_name")]
public string SequenceName { get; set; }

[JsonPropertyName("remote_phone_formatted")]
public string RemotePhoneFormatted { get; set; }

[JsonPropertyName("voicemail_duration")]
public int VoicemailDuration { get; set; }

[JsonPropertyName("transferred_to_user_id")]
public string TransferredToUserId { get; set; }

[JsonPropertyName("recording_expires_at")]
public DateTimeOffset? RecordingExpiresAt { get; set; }

[JsonPropertyName("has_recording")]
public bool HasRecording { get; set; }

[JsonPropertyName("phone")]
public string Phone { get; set; }

[JsonPropertyName("dialer_saved_search_id")]
public string DialerSavedSearchId { get; set; }

[JsonPropertyName("dialer_id")]
public string DialerId { get; set; }

[JsonPropertyName("is_joinable")]
public bool IsJoinable { get; set; }

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

[JsonPropertyName("remote_phone")]
public string RemotePhone { get; set; }

[JsonPropertyName("remote_country_iso")]
public string RemoteCountryIso { get; set; }

[JsonPropertyName("status")]
public string Status { get; set; }

[JsonPropertyName("cost")]
public decimal? Cost { get; set; }

[JsonPropertyName("forwarded_to")]
public string ForwardedTo { get; set; }

[JsonPropertyName("_type")]
public string Type { get; set; }

[JsonPropertyName("voicemail_url")]
public string VoicemailUrl { get; set; }

[JsonPropertyName("duration")]
public int Duration { get; set; }
}
46 changes: 46 additions & 0 deletions src/Close/Models/Activities/Calls/CallCreateOptions.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.Calls;

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

[JsonPropertyName("status")]
public string Status { get; set; }

[JsonPropertyName("disposition")]
public string Disposition { get; set; }

[JsonPropertyName("phone")]
public string Phone { get; set; }

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

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

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

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

[JsonPropertyName("direction")]
public string Direction { get; set; }

[JsonPropertyName("recording_url")]
public string RecordingUrl { get; set; }

[JsonPropertyName("voicemail_url")]
public string VoicemailUrl { get; set; }

[JsonPropertyName("voicemail_duration")]
public int VoicemailDuration { get; set; }

[JsonPropertyName("duration")]
public int Duration { get; set; }
}
22 changes: 22 additions & 0 deletions src/Close/Services/Activities/Calls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Close.Helpers;
using Close.Interfaces;
using Close.Models.Activities.Calls;

namespace Close.Services.Activities;

public class Calls : ActivityService<Call>, ICreatable<Call, CallCreateOptions>, IDeletable
{
public Calls(CloseClient closeClient, string endpoint) : base(closeClient, endpoint)
{
}

public async Task<Call> CreateAsync(CallCreateOptions createOptions, CancellationToken cancellationToken = default)
{
return await _request.CreateEntityAsync(createOptions, cancellationToken);
}

public async Task DeleteAsync(string id, CancellationToken cancellationToken = default)
{
await _request.DeleteEntityAsync(id, cancellationToken);
}
}
2 changes: 2 additions & 0 deletions src/Close/Services/Activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Close.Services;
public interface IActivity
{
Notes Notes { get; }
Calls Calls { get; }
}

public class Activity : IActivity
Expand All @@ -19,4 +20,5 @@ public Activity(CloseClient closeClient, string endpoint)
}

public Notes Notes => new(_closeClient, $"{_endpoint}/note");
public Calls Calls => new(_closeClient, $"{_endpoint}/call");
}

0 comments on commit 918fa4b

Please sign in to comment.