Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meetings in GetCalendarTasks response #163

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
40 changes: 40 additions & 0 deletions Entities/Meeting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using Newtonsoft.Json;
using Pyrus.ApiClient.JsonConverters;

namespace PyrusApiClient
{
public class Meeting
{
[JsonProperty("id")]
public int Id { get; set; }

[JsonProperty("type")]
public MeetingType Type { get; set; }

[JsonProperty("start_time")]
[JsonConverter(typeof(DateTimeJsonConverter), Constants.DateTimeFormat)]
public DateTime? StartTime { get; set; }

[JsonProperty("duration")]
public int? Duration { get; set; }

[JsonProperty("join_parameters")]
public MeetingJoinParameters JoinParameters { get; set; }

[JsonProperty("creator_id")]
public int CreatorId { get; set; }

[JsonProperty("task_id")]
public int TaskId { get; set; }

[JsonProperty("shared_calendar_event_id")]
public string SharedCalendarEventId { get; set; }

[JsonProperty("shared_to_email")]
public bool SharedToEmail { get; set; }

[JsonProperty("deleted")]
public bool Deleted { get; set; }
}
}
16 changes: 16 additions & 0 deletions Entities/MeetingJoinParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace PyrusApiClient
{
public class MeetingJoinParameters
{
[JsonProperty("url")]
public string Url { get; }

[JsonProperty("external_id")]
public string ExternalId { get; set; }

[JsonProperty("password")]
public string Password { get; set; }
}
}
25 changes: 25 additions & 0 deletions Enums/MeetingType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace PyrusApiClient
{
[JsonConverter(typeof(StringEnumConverter))]
public enum MeetingType
{
[EnumMember(Value = "none")]
None,

[EnumMember(Value = "zoom")]
Zoom,

[EnumMember(Value = "offline")]
Offline,

[EnumMember(Value = "google_meet")]
GoogleMeet,

[EnumMember(Value = "yandex_telemost")]
YandexTelemost,
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.9.0.0")]
[assembly: AssemblyFileVersion("4.9.0.0")]
[assembly: AssemblyVersion("4.10.0.0")]
[assembly: AssemblyFileVersion("4.10.0.0")]
2 changes: 1 addition & 1 deletion Pyrus.ApiClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</PropertyGroup>
<PropertyGroup>
<PackageId>Pyrus.ApiClient</PackageId>
<Version>4.9.0.0</Version>
<Version>4.10.0.0</Version>
<Title>Pyrus API Client</Title>
<Authors>Pyrus</Authors>
<Owners>Pyrus</Owners>
Expand Down
2 changes: 1 addition & 1 deletion Pyrus.ApiClient.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>Pyrus.ApiClient</id>
<version>4.9.0.0</version>
<version>4.10.0.0</version>
<title>Pyrus API Client</title>
<authors>Pyrus</authors>
<owners>Pyrus</owners>
Expand Down
29 changes: 20 additions & 9 deletions PyrusClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,20 +698,31 @@ public async Task<InboxResponse> GetInbox(int tasksCount = 50, string accessToke
return response;
}

public async Task<CalendarResponse> GetCalendarTasks(DateTime startDateTime, DateTime endDateTime,
int? tasksCount = 50, bool allAccessedTasks = false, int filterMask = 0b0111, string accessToken = null)
public async Task<CalendarResponse> GetCalendarTasks(
DateTime startDateTime,
DateTime endDateTime,
int? tasksCount = 50,
bool allAccessedTasks = false,
int filterMask = 0b0111,
bool includeMeetings = false,
string accessToken = null)
{
var path = $"{CalendarEndpoint}?" +
$"start_date_utc={startDateTime}" +
$"&end_date_utc={endDateTime}" +
$"&item_count={tasksCount}" +
$"&all_accessed_tasks={allAccessedTasks}" +
$"&filter_mask={filterMask}";
var startDateTimeStr = startDateTime.ToString(Constants.DateTimeFormat);
var endDateTimeStr = endDateTime.ToString(Constants.DateTimeFormat);

var query = string.Join(
"&",
$"start_date_utc={startDateTimeStr}",
$"end_date_utc={endDateTimeStr}",
$"item_count={tasksCount}",
$"all_accessed_tasks={allAccessedTasks}",
$"filter_mask={filterMask}",
$"include_meetings={includeMeetings}");

if (accessToken != null)
Token = accessToken;

var response = await this.RunQuery<CalendarResponse>(() => RequestHelper.GetRequest(this, $"{ClientSettings.Origin}{path}", Token));
var response = await this.RunQuery<CalendarResponse>(() => RequestHelper.GetRequest(this, $"{ClientSettings.Origin}{CalendarEndpoint}?{query}", Token));
return response;
}

Expand Down
8 changes: 7 additions & 1 deletion Requests/Builders/GetCalendarTasksBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public GetCalendarTasksBuilder WithReminded(bool withReminded)
return this;
}

public static implicit operator CalendarTasksRequest(GetCalendarTasksBuilder builder)
public GetCalendarTasksBuilder IncludeMeetings(bool includeMeetings)
{
_calendarTasksRequest.IncludeMeetings = includeMeetings;
return this;
}

public static implicit operator CalendarTasksRequest(GetCalendarTasksBuilder builder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поехало форматирование немного

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пофиксил

{
return builder._calendarTasksRequest;
}
Expand Down
6 changes: 5 additions & 1 deletion Requests/Builders/RequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public static GetBotsRequestBuilder GetBots()
public static OnePropertyBuilder<int, InboxResponse> GetInbox(int tasksCount = 50)
=> new OnePropertyBuilder<int, InboxResponse>(tasksCount);

public static GetCalendarTasksBuilder GetCalendarTasks(DateTime startDateTimeUtc, DateTime endDateTimeUtc)
=> new GetCalendarTasksBuilder(startDateTimeUtc, endDateTimeUtc);

public static CallBuilder RegisterCall() => new CallBuilder();

public static AttachCallRecordBuilder AttachCallRecord(string recordFile)
Expand Down Expand Up @@ -316,7 +319,8 @@ public static async Task<CalendarResponse> Process(this GetCalendarTasksBuilder
CalendarTasksRequest request = builder;
return await client.GetCalendarTasks(
request.StartDateUtc, request.EndDateUtc,
request.ItemCount, request.AllAccessedTasks, request.FilterMask ?? 0b0111);
request.ItemCount, request.AllAccessedTasks,
request.FilterMask ?? 0b0111, request.IncludeMeetings);
}

public static async Task<ResponseBase> Process(this CallBuilder builder, PyrusClient client)
Expand Down
5 changes: 4 additions & 1 deletion Requests/CalendarTasksRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ public class CalendarTasksRequest

[JsonProperty(PropertyName = "filter_mask")]
public int? FilterMask { get; set; }
}

[JsonProperty(PropertyName = "include_meetings")]
public bool IncludeMeetings { get; set; }
}
}
3 changes: 3 additions & 0 deletions Responses/CalendarResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ public class CalendarResponse : ResponseBase

[JsonProperty("has_more")]
public bool HasMore { get; set; }

[JsonProperty("meetings")]
public List<Meeting> Meetings { get; set; }
}
}