Skip to content

Commit

Permalink
fixed ID bug for messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Kuffner committed Feb 13, 2019
1 parent 9aabbc1 commit 9368631
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
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
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

0 comments on commit 9368631

Please sign in to comment.