Skip to content

Commit

Permalink
Merge pull request #3 from DataOne/bugfix
Browse files Browse the repository at this point in the history
Bugfix of long ids, #2
  • Loading branch information
doadmin authored Jan 12, 2022
2 parents 9aabbc1 + d90d9a0 commit 8e4f5db
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions src/YammerShell/CmdLets/GetYmGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ protected override void ProcessRecord()
private YammerGroup GetYammerGroupFromJToken(JToken group)
{
var yammerGroup = new YammerGroup();
yammerGroup.Id = Convert.ToInt32(group["id"]);
yammerGroup.Id = Convert.ToInt64(group["id"]);
yammerGroup.Email = (group["email"] ?? string.Empty).ToString();
yammerGroup.FullName = group["full_name"].ToString();
yammerGroup.Name = group["name"].ToString();
yammerGroup.NetworkId = Convert.ToInt32(group["network_id"]);
yammerGroup.NetworkId = Convert.ToInt64(group["network_id"]);
yammerGroup.Description = (group["description"] ?? string.Empty).ToString();
yammerGroup.Privacy = group["privacy"].ToString();
yammerGroup.Url = (group["web_url"] ?? string.Empty).ToString();
yammerGroup.CreatedAt = (DateTime)(group["created_at"] ?? DateTime.MinValue);
yammerGroup.CreatorId = Convert.ToInt32(group["creator_id"] ?? -1);
yammerGroup.CreatorId = Convert.ToInt64(group["creator_id"] ?? -1);
yammerGroup.Members = Convert.ToInt32(group["stats"]["members"]);
return yammerGroup;
}
Expand Down
20 changes: 10 additions & 10 deletions src/YammerShell/CmdLets/GetYmMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class GetYmMessage : PSCmdlet
HelpMessage = "Id of a message",
ParameterSetName = "Id"
)]
public int? Id { get; set; }
public string Id { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Expand All @@ -62,15 +62,15 @@ public class GetYmMessage : PSCmdlet
ValueFromPipeline = true,
HelpMessage = "Returns messages older than this message ID"
)]
public int? OlderThan { get; set; }
public string OlderThan { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
ValueFromPipeline = true,
HelpMessage = "The feed of messages for a hashtag specified by the numeric string ID",
ParameterSetName = "Topic"
)]
public int? Topic { get; set; }
public string Topic { get; set; }

protected override void ProcessRecord()
{
Expand All @@ -82,7 +82,7 @@ protected override void ProcessRecord()
}
_request = new Request(token.Value.ToString());

if (Id.HasValue)
if (!string.IsNullOrEmpty(Id))
{
try
{
Expand Down Expand Up @@ -162,7 +162,7 @@ public IEnumerable<YammerMessage> GetNetworkMessages()
}
}

if (Topic.HasValue)
if (!string.IsNullOrEmpty(Topic))
{
requestUrl = Properties.Resources.YammerApi + "messages/about_topic/" + Topic + ".json";
return GetMessagesFromApi(requestUrl, parameters);
Expand Down Expand Up @@ -210,13 +210,13 @@ private IEnumerable<YammerMessage> GetMessagesFromApi(string requestUrl, string
private YammerMessage GetYammerMessage(JToken message)
{
var yammerMessage = new YammerMessage();
yammerMessage.Id = Convert.ToInt32(message["id"]);
yammerMessage.SenderId = Convert.ToInt32(message["sender_id"]);
yammerMessage.RepliedToId = message.Value<int?>("replied_to_id");
yammerMessage.Id = message["id"].ToString();
yammerMessage.SenderId = message["sender_id"].ToString();
yammerMessage.RepliedToId = message.Value<string>("replied_to_id");
yammerMessage.CreatedAt = (DateTime)message["created_at"];
yammerMessage.NetworkId = Convert.ToInt32(message["network_id"]);
yammerMessage.NetworkId = message["network_id"].ToString();
yammerMessage.MessageType = message["message_type"].ToString();
yammerMessage.GroupId = message.Value<int?>("group_id");
yammerMessage.GroupId = message.Value<string>("group_id");
yammerMessage.Body = message["body"]["plain"].ToString();
yammerMessage.Url = message["web_url"].ToString();

Expand Down
6 changes: 3 additions & 3 deletions src/YammerShell/CmdLets/GetYmNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GetYmNetwork : PSCmdlet
Position = 0,
HelpMessage = "With this parameter set you request all networks the user has access to but filtered by id."
)]
public int? Id { get; set; }
public long? Id { get; set; }

protected override void ProcessRecord()
{
Expand All @@ -36,7 +36,7 @@ protected override void ProcessRecord()
var yammerNetworks = new List<YammerNetwork>();
foreach (var network in JArray.Parse(result))
{
var networkId = Convert.ToInt32(network["id"]);
var networkId = Convert.ToInt64(network["id"]);
if (!Id.HasValue || Id == networkId)
{
yammerNetworks.Add(GetYammerNetwork(network, networkId));
Expand All @@ -51,7 +51,7 @@ protected override void ProcessRecord()
}
}

private YammerNetwork GetYammerNetwork(JToken network, int id)
private YammerNetwork GetYammerNetwork(JToken network, long id)
{
var yammerNetwork = new YammerNetwork();
yammerNetwork.Id = id;
Expand Down
8 changes: 4 additions & 4 deletions src/YammerShell/CmdLets/GetYmUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GetYmUser : PSCmdlet
HelpMessage = "ID of a user",
ParameterSetName = "Id"
)]
public int? Id { get; set; }
public long? Id { get; set; }

[ValidateRange(1,1000)]
[Parameter(
Expand Down Expand Up @@ -174,7 +174,7 @@ private IEnumerable<YammerUser> GetYammerUsersInGroup(int? groupId)
return allYammerUsers;
}

public YammerUser GetYammerUser(int id)
public YammerUser GetYammerUser(long id)
{
var result = _request.Get(string.Format("{0}users/{1}.json", Properties.Resources.YammerApi, id));
var user = JObject.Parse(result);
Expand Down Expand Up @@ -249,7 +249,7 @@ public IEnumerable<YammerUser> GetYammerUsers()
private YammerUser GetYammerUser(JToken user)
{
var yammerUser = new YammerUser();
yammerUser.Id = Convert.ToInt32(GetToken(user, "id"));
yammerUser.Id = Convert.ToInt64(GetToken(user, "id"));
yammerUser.UserName = GetToken(user, "name");
yammerUser.FirstName = GetToken(user, "first_name");
yammerUser.LastName = GetToken(user, "last_name");
Expand All @@ -258,7 +258,7 @@ private YammerUser GetYammerUser(JToken user)
yammerUser.JobTitle = GetToken(user, "job_title");
yammerUser.Department = GetToken(user, "department");
yammerUser.Timezone = GetToken(user, "timezone");
yammerUser.NetworkId = Convert.ToInt32(GetToken(user, "network_id"));
yammerUser.NetworkId = Convert.ToInt64(GetToken(user, "network_id"));
yammerUser.NetworkName = GetToken(user, "network_name");
yammerUser.Url = GetToken(user, "web_url");
var activatedAt = user["activated_at"];
Expand Down
2 changes: 1 addition & 1 deletion src/YammerShell/CmdLets/NewYmGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override void ProcessRecord()
{
var response = _request.Post(requestUrl, string.Empty);
var newGroup = JObject.Parse(response);
WriteObject(Convert.ToInt32(newGroup["id"]));
WriteObject(Convert.ToInt64(newGroup["id"]));
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/YammerShell/CmdLets/NewYmMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected override void ProcessRecord()
var jObject = JObject.Parse(response);
var messages = JArray.Parse(jObject["messages"].ToString());
var id = messages[0]["id"];
WriteObject(Convert.ToInt32(id));
WriteObject(Convert.ToInt64(id));
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/YammerShell/CmdLets/NewYmUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected override void ProcessRecord()
var url = string.Format("{0}users.json?{1}{2}{3}{4}{5}{6}", Properties.Resources.YammerApi, Email, fullName, jobTitle, departmentName, location, workTelephone);
var response = _request.Post(url, string.Empty);
var newUser = JObject.Parse(response);
WriteObject(Convert.ToInt32(newUser["id"]));
WriteObject(Convert.ToInt64(newUser["id"]));
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/YammerShell/CmdLets/RemoveYmMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class RemoveYmMessage : PSCmdlet
Position = 0,
HelpMessage = "ID of the message to delete"
)]
public int Id { get; set; }
public long Id { get; set; }

protected override void ProcessRecord()
{
Expand Down
28 changes: 14 additions & 14 deletions src/YammerShell/CmdLets/SearchYmItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private YammerSearchResult GetYammerSearchResult(JObject response)
private YammerUser GetYammerUser(JToken user)
{
var yammerUser = new YammerUser();
yammerUser.Id = Convert.ToInt32(GetToken(user, "id"));
yammerUser.Id = Convert.ToInt64(GetToken(user, "id"));
yammerUser.UserName = GetToken(user, "name");
yammerUser.FirstName = GetToken(user, "first_name");
yammerUser.LastName = GetToken(user, "last_name");
Expand All @@ -122,7 +122,7 @@ private YammerUser GetYammerUser(JToken user)
yammerUser.JobTitle = GetToken(user, "job_title");
yammerUser.Department = GetToken(user, "department");
yammerUser.Timezone = GetToken(user, "timezone");
yammerUser.NetworkId = Convert.ToInt32(GetToken(user, "network_id"));
yammerUser.NetworkId = Convert.ToInt64(GetToken(user, "network_id"));
yammerUser.NetworkName = GetToken(user, "network_name");
yammerUser.Url = GetToken(user, "web_url");
var activatedAt = user["activated_at"];
Expand Down Expand Up @@ -152,8 +152,8 @@ private YammerFile GetYammerFile(JToken file)
{
var yammerFile = new YammerFile();

yammerFile.Id = Convert.ToInt32(file["id"]);
yammerFile.NetworkId = Convert.ToInt32(file["network_id"]);
yammerFile.Id = Convert.ToInt64(file["id"]);
yammerFile.NetworkId = Convert.ToInt64(file["network_id"]);
yammerFile.GroupId = file.Value<int?>("group_id");
yammerFile.OwnerId = file.Value<int?>("owner_id");
yammerFile.Url = file["web_url"].ToString();
Expand All @@ -169,40 +169,40 @@ private YammerFile GetYammerFile(JToken file)
private YammerTopic GetYammerTopic(JToken topic)
{
var yammerTopic = new YammerTopic();
yammerTopic.Id = Convert.ToInt32(topic["id"]);
yammerTopic.Id = Convert.ToInt64(topic["id"]);
yammerTopic.Name = topic["name"].ToString();
yammerTopic.NetworkId = Convert.ToInt32(topic["network_id"]);
yammerTopic.NetworkId = Convert.ToInt64(topic["network_id"]);
yammerTopic.Url = topic["web_url"].ToString();
return yammerTopic;
}

private YammerGroup GetYammerGroup(JToken group)
{
var yammerGroup = new YammerGroup();
yammerGroup.Id = Convert.ToInt32(group["id"]);
yammerGroup.Id = Convert.ToInt64(group["id"]);
yammerGroup.Email = group["email"].ToString();
yammerGroup.FullName = group["full_name"].ToString();
yammerGroup.Name = group["name"].ToString();
yammerGroup.NetworkId = Convert.ToInt32(group["network_id"]);
yammerGroup.NetworkId = Convert.ToInt64(group["network_id"]);
yammerGroup.Description = group["description"].ToString();
yammerGroup.Privacy = group["privacy"].ToString();
yammerGroup.Url = group["web_url"].ToString();
yammerGroup.CreatedAt = (DateTime)group["created_at"];
yammerGroup.CreatorId = Convert.ToInt32(group["creator_id"]);
yammerGroup.CreatorId = Convert.ToInt64(group["creator_id"]);
yammerGroup.Members = Convert.ToInt32(group["stats"]["members"]);
return yammerGroup;
}

private YammerMessage GetYammerMessage(JToken message)
{
var yammerMessage = new YammerMessage();
yammerMessage.Id = Convert.ToInt32(message["id"]);
yammerMessage.SenderId = Convert.ToInt32(message["sender_id"]);
yammerMessage.RepliedToId = message.Value<int?>("replied_to_id");
yammerMessage.Id = message["id"].ToString();
yammerMessage.SenderId = message["sender_id"].ToString();
yammerMessage.RepliedToId = message.Value<string>("replied_to_id");
yammerMessage.CreatedAt = (DateTime)message["created_at"];
yammerMessage.NetworkId = Convert.ToInt32(message["network_id"]);
yammerMessage.NetworkId = message["network_id"].ToString();
yammerMessage.MessageType = message["message_type"].ToString();
yammerMessage.GroupId = message.Value<int?>("group_id");
yammerMessage.GroupId = message.Value<string>("group_id");
yammerMessage.Body = message["body"]["plain"].ToString();
yammerMessage.Url = message["web_url"].ToString();

Expand Down
4 changes: 2 additions & 2 deletions src/YammerShell/CmdLets/ShowYmRelationships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ private YammerUser GetYammerUser(JToken user)
{
var yammerUser = new YammerUser();
yammerUser.UserName = GetToken(user, "name");
yammerUser.Id = Convert.ToInt32(GetToken(user, "id"));
yammerUser.Id = Convert.ToInt64(GetToken(user, "id"));
yammerUser.FirstName = GetToken(user, "first_name");
yammerUser.LastName = GetToken(user, "last_name");
yammerUser.FullName = GetToken(user, "full_name");
yammerUser.Email = GetToken(user, "email");
yammerUser.JobTitle = GetToken(user, "job_title");
yammerUser.Department = GetToken(user, "department");
yammerUser.Timezone = GetToken(user, "timezone");
yammerUser.NetworkId = Convert.ToInt32(GetToken(user, "network_id"));
yammerUser.NetworkId = Convert.ToInt64(GetToken(user, "network_id"));
yammerUser.NetworkName = GetToken(user, "network_name");
yammerUser.Url = GetToken(user, "web_url");
var activatedAt = user["activated_at"];
Expand Down
8 changes: 4 additions & 4 deletions src/YammerShell/YammerObjects/YammerFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace YammerShell.YammerObjects
{
public class YammerFile
{
public int Id { get; set; }
public int NetworkId { get; set; }
public int? GroupId { get; set; }
public int? OwnerId { get; set; }
public long Id { get; set; }
public long NetworkId { get; set; }
public long? GroupId { get; set; }
public long? OwnerId { get; set; }
public string Url { get; set; }
public string Name { get; set; }
public string Description { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/YammerShell/YammerObjects/YammerGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ namespace YammerShell.YammerObjects
{
public class YammerGroup
{
public int Id { get; set; }
public long Id { get; set; }
public string Email { get; set; }
public string FullName { get; set; }
public string Name { get; set; }
public int NetworkId { get; set; }
public long NetworkId { get; set; }
public string Description { get; set; }
public string Privacy { get; set; }
public string Url { get; set; }
public DateTime CreatedAt { get; set; }
public int CreatorId { get; set; }
public long CreatorId { get; set; }
public int Members { get; set; }
}
}
10 changes: 5 additions & 5 deletions src/YammerShell/YammerObjects/YammerMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ namespace YammerShell.YammerObjects
{
public class YammerMessage
{
public int Id { get; set; }
public int SenderId { get; set; }
public int? RepliedToId { get; set; }
public string Id { get; set; }
public string SenderId { get; set; }
public string RepliedToId { get; set; }
public DateTime CreatedAt { get; set; }
public int NetworkId { get; set; }
public string NetworkId { get; set; }
public string MessageType { get; set; }
public int? GroupId { get; set; }
public string GroupId { get; set; }
public string Body { get; set; }
public IEnumerable<string> AttachmentUrls { get; set; }
public string Url { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/YammerShell/YammerObjects/YammerNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace YammerShell.YammerObjects
{
public class YammerNetwork
{
public int Id { get; set; }
public long Id { get; set; }
public string Email { get; set; }
public string Name { get; set; }
public string Url { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/YammerShell/YammerObjects/YammerTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
public class YammerTopic
{
public int Id { get; set; }
public int NetworkId { get; set; }
public long Id { get; set; }
public long NetworkId { get; set; }
public string Name { get; set; }
public string Url { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions src/YammerShell/YammerObjects/YammerUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace YammerShell.YammerObjects
{
public class YammerUser
{
public int Id { get; set; }
public long Id { get; set; }
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
Expand All @@ -14,7 +14,7 @@ public class YammerUser
public string JobTitle { get; set; }
public string Department { get; set; }
public string Timezone { get; set; }
public int NetworkId { get; set; }
public long NetworkId { get; set; }
public string NetworkName { get; set; }
public IEnumerable<string> PhoneNumbers { get; set; }
public DateTime ActivatedAt { get; set; }
Expand Down

0 comments on commit 8e4f5db

Please sign in to comment.