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

Added Calling Endpoint #24

Merged
merged 5 commits into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion APIPartials/SparkEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public partial class Spark
if (resource != null) queryParams.Add("resource", resource);
if (type != null) queryParams.Add("type", type);
if (actorId != null) queryParams.Add("actorId", actorId);
if (max > 0) queryParams.Add("max", max.ToString());
if (max > 0) queryParams.Add("max", System.Math.Max(max, 1000).ToString());
if (from != null) queryParams.Add("from", ((DateTime)from).ToString("o"));
if (to != null) queryParams.Add("to", ((DateTime)to).ToString("o"));

Expand Down
50 changes: 50 additions & 0 deletions APIPartials/SparkLocations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SparkDotNet
{

public partial class Spark
{
private string locationsBase = "/v1/locations";

/// <summary>
/// List locations for an organization.
/// Use query parameters to filter the response.
/// Long result sets will be split into pages.
/// </summary>
/// <param name="name">List locations whose name contains this string (case-insensitive).</param>
/// <param name="id">List locations by ID.</param>
/// <param name="orgId">List locations in this organization. Only admin users of another organization (such as partners) may use this parameter.</param>
/// <param name="max">Limit the maximum number of location in the response. Default: 100</param>
/// <returns>A list of matching Location objects</returns>
public async Task<List<Location>> GetLocationsAsync(string name = null, string id = null, string orgId = null, int max = 0)
{
var queryParams = new Dictionary<string, string>();

if (name != null) queryParams.Add("name", name);
if (id != null) queryParams.Add("id", id);
if (orgId != null) queryParams.Add("orgId", orgId);
if (max > 0) queryParams.Add("max", max.ToString());

var path = getURL(locationsBase, queryParams);
return await GetItemsAsync<Location>(path);
}

/// <summary>
/// Shows details for a location, by ID.
/// Specify the location ID in the locationId parameter in the URI.
/// Partner administrators should use the List Locations endpoint to retrieve information about locations.
/// </summary>
/// <param name="locationId">A unique identifier for the location.</param>
/// <returns>A location object</returns>
public async Task<Location> GetLocationAsync(string locationId)
{
var queryParams = new Dictionary<string, string>();
var path = getURL($"{locationsBase}/{locationId}", queryParams);
return await GetItemAsync<Location>(path);
}
}

}
14 changes: 13 additions & 1 deletion APIPartials/SparkMemberships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,25 @@ public async Task<bool> DeleteMembershipAsync(Membership membership)
/// </summary>
/// <param name="membershipId">The unique identifier for the membership.</param>
/// <param name="isModerator">Whether or not the participant is a room moderator.</param>
/// <param name="isRoomHidden">Whether or not the room is hidden in the Webex Teams clients.</param>
/// <returns>Membership object.</returns>
public async Task<Membership> UpdateMembershipAsync(string membershipId, bool isModerator)
public async Task<Membership> UpdateMembershipAsync(string membershipId, bool isModerator, bool isRoomHidden)
{
var putBody = new Dictionary<string, object>();
putBody.Add("isModerator",isModerator);
putBody.Add("isRoomHidden", isRoomHidden);
var path = $"{membershipsBase}/{membershipId}";
return await UpdateItemAsync<Membership>(path, putBody);
}

/// <summary>
/// Updates properties for a membership by object.
/// </summary>
/// <param name="membership">The membership object to be updatad.</param>
/// <returns>Membership object.</returns>
public async Task<Membership> UpdateMembershipAsync(Membership membership)
{
return await UpdateMembershipAsync(membership.id, membership.isModerator, membership.isRoomHidden);
}
}
}
90 changes: 64 additions & 26 deletions APIPartials/SparkPeople.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ public partial class Spark
/// <param name="id">List people by ID. Accepts up to 85 person IDs separated by commas. If this parameter is provided then presence information (such as the lastActivity or status properties) will not be included in the response.</param>
/// <param name="orgId">List people in this organization. Only admin users of another organization (such as partners) may use this parameter.</param>
/// <param name="max">Limit the maximum number of people in the response. Default: 100</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <param name="locationId">List people present in this location.</param>
/// <returns>List of People objects.</returns>
public async Task<List<Person>> GetPeopleAsync(string email = null, string displayName = null, string id = null, string orgId = null, int max = 0)
public async Task<List<Person>> GetPeopleAsync(string email = null, string displayName = null, string id = null, string orgId = null, int max = 0, bool? callingData = null, string locationId = null)
{
var queryParams = new Dictionary<string, string>();
if (email != null) queryParams.Add("email",email);
if (displayName != null) queryParams.Add("displayName",displayName);
if (id != null) queryParams.Add("id", id);
if (orgId != null) queryParams.Add("orgId", orgId);
if (max > 0) queryParams.Add("max",max.ToString());
if (callingData != null) queryParams.Add("callingData", callingData.ToString());
if (locationId != null) queryParams.Add("locationId", locationId);
var path = getURL(peopleBase, queryParams);
return await GetItemsAsync<Person>(path);
}

/// <summary>
/// Show the profile for the authenticated user.
/// </summary>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <returns>A person object representing the querying user.</returns>
public async Task<Person> GetMeAsync() {
public async Task<Person> GetMeAsync(bool? callingData = false) {
var queryParams = new Dictionary<string, string>();
if (callingData != null) queryParams.Add("callingData", callingData.ToString());
var path = getURL($"{peopleBase}/me", queryParams);
return await GetItemAsync<Person>(path);
}
Expand All @@ -44,9 +50,11 @@ public async Task<List<Person>> GetPeopleAsync(string email = null, string displ
/// Specify the person ID in the personId parameter in the URI.
/// </summary>
/// <param name="personId">A unique identifier for the person.</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <returns>Person object.</returns>
public async Task<Person> GetPersonAsync(string personId) {
public async Task<Person> GetPersonAsync(string personId, bool? callingData = null) {
var queryParams = new Dictionary<string, string>();
if (callingData != null) queryParams.Add("callingData", callingData.ToString());
var path = getURL($"{peopleBase}/{personId}", queryParams);
return await GetItemAsync<Person>(path);
}
Expand All @@ -62,30 +70,47 @@ public async Task<List<Person>> GetPeopleAsync(string email = null, string displ
/// <param name="orgId">The ID of the organization to which this person belongs.</param>
/// <param name="roles">An array of role strings representing the roles to which this person belongs.</param>
/// <param name="licenses">An array of license strings allocated to this person.</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <param name="phoneNumbers">Phone numbers for the person.</param>
/// <param name="extension">The extension of the person retrieved from BroadCloud.</param>
/// <param name="locationId">The ID of the location for this person retrieved from BroadCloud.</param>
/// <returns>Person object.</returns>
public async Task<Person> CreatePersonAsync(string[] emails, string displayName = null, string firstName = null, string lastName = null, string avatar = null, string orgId = null, string[] roles = null, string[] licenses = null )
public async Task<Person> CreatePersonAsync(string[] emails, string displayName = null, string firstName = null, string lastName = null,
string avatar = null, string orgId = null, string[] roles = null, string[] licenses = null,
bool? callingData = null, PhoneNumber[] phoneNumbers = null, string extension = null,
string locationId = null)
{
var queryParams = new Dictionary<string, string>();
if (callingData != null) queryParams.Add("callingData", callingData.ToString());
var path = getURL(peopleBase, queryParams);

var postBody = new Dictionary<string, object>();
postBody.Add("emails", emails);
if (displayName != null) { postBody.Add("displayName", displayName); }
if (firstName != null) { postBody.Add("firstName", firstName); }
if (lastName != null) { postBody.Add("lastName", lastName); }
if (avatar != null) { postBody.Add("avatar", avatar); }
if (orgId != null) { postBody.Add("orgId", orgId); }
if (roles != null) { postBody.Add("roles", roles); }
if (licenses != null) { postBody.Add("licenses", licenses); }

return await PostItemAsync<Person>(peopleBase, postBody);
if (displayName != null) postBody.Add("displayName", displayName);
if (firstName != null) postBody.Add("firstName", firstName);
if (lastName != null) postBody.Add("lastName", lastName);
if (avatar != null) postBody.Add("avatar", avatar);
if (orgId != null) postBody.Add("orgId", orgId);
if (roles != null) postBody.Add("roles", roles);
if (licenses != null) postBody.Add("licenses", licenses);
if (phoneNumbers != null) postBody.Add("phoneNumbers", phoneNumbers);
if (extension != null) postBody.Add("extension", extension);
if (locationId != null) postBody.Add("locationId", locationId);


return await PostItemAsync<Person>(path, postBody);
}

/// <summary>
/// Create a new user account for a given organization. Only an admin can create a new user account.
/// </summary>
/// <param name="person">A person object representing the person to be created</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <returns>The newly created person</returns>
public async Task<Person> CreatePersonAsync(Person person)
public async Task<Person> CreatePersonAsync(Person person, bool? callingData = false)
{
return await CreatePersonAsync(person.emails, person.displayName, person.firstName, person.lastName, person.avatar, person.orgId, person.roles, person.licenses);
return await CreatePersonAsync(person.emails, person.displayName, person.firstName, person.lastName, person.avatar, person.orgId,
person.roles, person.licenses, callingData, person.PhoneNumbers, person.Extension, person.LocationId);
}

/// <summary>
Expand Down Expand Up @@ -125,20 +150,31 @@ public async Task<bool> DeletePersonAsync(Person person)
/// <param name="lastName">The last name of the person.</param>
/// <param name="avatar">The URL to the person's avatar in PNG format.</param>
/// <param name="licenses">An array of license strings allocated to this person.</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <param name="extension">The extension of the person retrieved from BroadCloud.</param>
/// <returns>Person object.</returns>
public async Task<Person> UpdatePersonAsync(string personId, string[] emails = null, string orgId = null, string[] roles = null, string displayName = null, string firstName = null, string lastName = null, string avatar = null, string[] licenses = null )
public async Task<Person> UpdatePersonAsync(string personId, string[] emails = null, string orgId = null, string[] roles = null,
string displayName = null, string firstName = null, string lastName = null, string avatar = null,
string[] licenses = null, bool? callingData = null, PhoneNumber[] phoneNumbers = null,
string extension = null)
{
var queryParams = new Dictionary<string, string>();
if (callingData != null) queryParams.Add("callingData", callingData.ToString());
var path = getURL($"{peopleBase}/{personId}", queryParams);

var putBody = new Dictionary<string, object>();
putBody.Add("personId",personId);
if (emails != null) putBody.Add("emails", emails);
if (displayName != null) { putBody.Add("displayName", displayName); }
if (firstName != null) { putBody.Add("firstName", firstName); }
if (lastName != null) { putBody.Add("lastName", lastName); }
if (avatar != null) { putBody.Add("avatar", avatar); }
if (orgId != null) { putBody.Add("orgId", orgId); }
if (roles != null) { putBody.Add("roles", roles); }
if (licenses != null) { putBody.Add("licenses", licenses); }
var path = $"{peopleBase}/{personId}";
if (displayName != null) putBody.Add("displayName", displayName);
if (firstName != null) putBody.Add("firstName", firstName);
if (lastName != null) putBody.Add("lastName", lastName);
if (avatar != null) putBody.Add("avatar", avatar);
if (orgId != null) putBody.Add("orgId", orgId);
if (roles != null) putBody.Add("roles", roles);
if (licenses != null) putBody.Add("licenses", licenses);
if (phoneNumbers != null) putBody.Add("phoneNumbers", phoneNumbers);
if (extension != null) putBody.Add("extension", extension);

return await UpdateItemAsync<Person>(path, putBody);
}

Expand All @@ -147,10 +183,12 @@ public async Task<Person> UpdatePersonAsync(string personId, string[] emails = n
/// Specify the person ID in the personId parameter in the URI. Only an admin can update a person details.
/// </summary>
/// <param name="person">The person object to update</param>
/// <param name="callingData">Include BroadCloud user details in the response. Default: false</param>
/// <returns>Person object.</returns>
public async Task<Person> UpdatePersonAsync(Person person)
public async Task<Person> UpdatePersonAsync(Person person, bool? callingData = null)
{
return await UpdatePersonAsync(person.id, person.emails, person.orgId, person.roles, person.displayName, person.firstName, person.lastName, person.avatar, person.licenses);
return await UpdatePersonAsync(person.id, person.emails, person.orgId, person.roles, person.displayName, person.firstName, person.lastName,
person.avatar, person.licenses, callingData, person.PhoneNumbers, person.Extension);
}

}
Expand Down
2 changes: 1 addition & 1 deletion APIPartials/SparkRooms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<List<Room>> GetRoomsAsync(string teamId = null, int max = 0, s
var queryParams = new Dictionary<string, string>();
if (teamId != null) queryParams.Add("teamId",teamId);
if (type != null) queryParams.Add("type",type);
if (max > 0) queryParams.Add("max",max.ToString());
if (max > 0) queryParams.Add("max", System.Math.Max(max, 1000).ToString());
if (sortBy != null) queryParams.Add("sortBy", sortBy);

var path = getURL(roomsBase, queryParams);
Expand Down
6 changes: 6 additions & 0 deletions Models/AttachmentActionInput.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using Newtonsoft.Json;
namespace SparkDotNet
{
public class AttachmentActionInput : WebexObject
{

[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("tel")]
public string Tel { get; set; }
}
}
33 changes: 33 additions & 0 deletions Models/Location.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;

namespace SparkDotNet {

/// <summary>
/// Locations are used to organize Webex Calling (BroadCloud) features within physical locations.
/// Webex Control Hub may be used to define new locations.
/// Searching and viewing locations in your organization requires an administrator auth token
/// with the spark-admin:people_read or spark-admin:device_read scope.
/// </summary>
public class Location : WebexObject
{
/// <summary>
/// A unique identifier for the location.
/// </summary>
public string Id { get; set; }

/// <summary>
/// The name of the location.
/// </summary>
public string Name { get; set; }

/// <summary>
/// The ID of the organization to which this location belongs.
/// </summary>
public string OrgId { get; set; }

/// <summary>
/// The address of the location.
/// </summary>
public LocationAddress Address { get; set; }
}
}
37 changes: 37 additions & 0 deletions Models/LocationAddress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;

namespace SparkDotNet {

public class LocationAddress : WebexObject
{
/// <summary>
/// Address line 1
/// </summary>
public string Address1 { get; set; }

/// <summary>
/// Address line 2
/// </summary>
public string Address2 { get; set; }

/// <summary>
/// City
/// </summary>
public string City { get; set; }

/// <summary>
/// State
/// </summary>
public string State { get; set; }

/// <summary>
/// ZIP/Postal Code
/// </summary>
public string PostalCode { get; set; }

/// <summary>
/// Country
/// </summary>
public string Country { get; set; }
}
}
6 changes: 6 additions & 0 deletions Models/MeetingInvetees.cs → Models/MeetingInvitees.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using Newtonsoft.Json;

namespace SparkDotNet
{
public class MeetingInvitee : WebexObject
{
[JsonProperty("email")]
public string Email { get; set; }
[JsonProperty("displayName")]
public string DisplayName { get; set; }
[JsonProperty("coHost")]
public bool CoHost { get; set; }
[JsonProperty("meetingId")]
public string MeetingId { get; set; }
}

Expand Down
Loading