From 918fa4b76014c89836fe9b0e7f54a4744f65d65b Mon Sep 17 00:00:00 2001 From: Peter Rank Schroeder Date: Fri, 12 May 2023 00:17:42 -0700 Subject: [PATCH] Implemented call activity --- src/Close/Close.csproj | 6 +- src/Close/Models/Activities/Calls/Call.cs | 160 ++++++++++++++++++ .../Activities/Calls/CallCreateOptions.cs | 46 +++++ src/Close/Services/Activities/Calls.cs | 22 +++ src/Close/Services/Activity.cs | 2 + 5 files changed, 231 insertions(+), 5 deletions(-) create mode 100644 src/Close/Models/Activities/Calls/Call.cs create mode 100644 src/Close/Models/Activities/Calls/CallCreateOptions.cs create mode 100644 src/Close/Services/Activities/Calls.cs diff --git a/src/Close/Close.csproj b/src/Close/Close.csproj index 545c2e8..55fc1fb 100644 --- a/src/Close/Close.csproj +++ b/src/Close/Close.csproj @@ -5,7 +5,7 @@ disable Close Close - 0.1.4 + 0.1.5 Peter Schroeder Telzio, Inc. © 2013-2023 Telzio, Inc. @@ -37,9 +37,5 @@ - - - - diff --git a/src/Close/Models/Activities/Calls/Call.cs b/src/Close/Models/Activities/Calls/Call.cs new file mode 100644 index 0000000..1619bb6 --- /dev/null +++ b/src/Close/Models/Activities/Calls/Call.cs @@ -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 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; } +} \ No newline at end of file diff --git a/src/Close/Models/Activities/Calls/CallCreateOptions.cs b/src/Close/Models/Activities/Calls/CallCreateOptions.cs new file mode 100644 index 0000000..e6b9f60 --- /dev/null +++ b/src/Close/Models/Activities/Calls/CallCreateOptions.cs @@ -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; } +} \ No newline at end of file diff --git a/src/Close/Services/Activities/Calls.cs b/src/Close/Services/Activities/Calls.cs new file mode 100644 index 0000000..ffe494c --- /dev/null +++ b/src/Close/Services/Activities/Calls.cs @@ -0,0 +1,22 @@ +using Close.Helpers; +using Close.Interfaces; +using Close.Models.Activities.Calls; + +namespace Close.Services.Activities; + +public class Calls : ActivityService, ICreatable, IDeletable +{ + public Calls(CloseClient closeClient, string endpoint) : base(closeClient, endpoint) + { + } + + public async Task 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); + } +} \ No newline at end of file diff --git a/src/Close/Services/Activity.cs b/src/Close/Services/Activity.cs index 42eeaff..829ebec 100644 --- a/src/Close/Services/Activity.cs +++ b/src/Close/Services/Activity.cs @@ -5,6 +5,7 @@ namespace Close.Services; public interface IActivity { Notes Notes { get; } + Calls Calls { get; } } public class Activity : IActivity @@ -19,4 +20,5 @@ public Activity(CloseClient closeClient, string endpoint) } public Notes Notes => new(_closeClient, $"{_endpoint}/note"); + public Calls Calls => new(_closeClient, $"{_endpoint}/call"); } \ No newline at end of file