public static FB_Attachment graphql_to_extensible_attachment(JToken data) { var story = data.get("story_attachment"); if (story == null) { return(null); } var target = story.get("target"); if (target == null) { return(new FB_UnsentMessage(uid: data.get("legacy_attachment_id")?.Value <string>())); } var _type = target.get("__typename")?.Value <string>(); if (_type == "MessageLocation") { return(FB_LocationAttachment._from_graphql(story)); } else if (_type == "MessageLiveLocation") { return(FB_LiveLocationAttachment._from_graphql(story)); } else if (new string[] { "ExternalUrl", "Story" }.Contains(_type)) { return(FB_ShareAttachment._from_graphql(story)); } return(null); }
public static new FB_LiveLocationAttachment _from_graphql(JToken data) { var target = data.get("target"); var rtn = new FB_LiveLocationAttachment( uid: target.get("live_location_id")?.Value <string>(), latitude: target.get("coordinate")?.get("latitude")?.Value <double>() ?? 0, longitude: target.get("coordinate")?.get("longitude")?.Value <double>() ?? 0, name: data.get("title_with_entities")?.get("text")?.Value <string>(), expiration_time: target.get("expiration_time")?.Value <string>(), is_expired: target.get("is_expired")?.Value <bool>() ?? false); var media = data.get("media"); if (media != null && media.get("image") != null) { var image = media.get("image"); rtn.image_url = image?.get("uri")?.Value <string>(); rtn.image_width = image?.get("width")?.Value <int>() ?? 0; rtn.image_height = image?.get("height")?.Value <int>() ?? 0; } rtn.url = data.get("url")?.Value <string>(); return(rtn); }