public static FB_Page _from_graphql(JToken data) { if (data.get("profile_picture") == null) { data["profile_picture"] = new JObject(new JProperty("uri", "")); } if (data.get("city") == null) { data["city"] = new JObject(new JProperty("name", "")); } FB_Plan plan = null; if (data.get("event_reminders") != null && data.get("event_reminders")?.get("nodes") != null) { plan = FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()); } return(new FB_Page( uid: data.get("id")?.Value <string>(), url: data.get("url")?.Value <string>(), city: data.get("city")?.get("name")?.Value <string>(), category: data.get("category_type")?.Value <string>(), photo: data.get("profile_picture")?.get("uri")?.Value <string>(), name: data.get("name")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, plan: plan )); }
/// <summary> /// Represents a Facebook thread /// </summary> /// <param name="type"></param> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="last_message_timestamp"></param> /// <param name="message_count"></param> /// <param name="plan"></param> public FB_Thread(ThreadType type, string uid, string photo = null, string name = null, string last_message_timestamp = null, int message_count = 0, FB_Plan plan = null) { this.uid = uid; this.type = type; this.photo = photo; this.name = name; this.last_message_timestamp = last_message_timestamp; this.message_count = message_count; this.plan = plan; }
public static FB_Plan _from_fetch(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("event_time")?.Value <string>(), title: data.get("title")?.Value <string>(), location: data.get("location_name")?.Value <string>(), location_id: data.get("location_id")?.Value <string>() ); rtn.uid = data.get("oid")?.Value <string>(); rtn.author_id = data.get("creator_id")?.Value <string>(); rtn.guests = data.get("event_members")?.Value <JObject>().Properties().Select((x) => { return(new { Key = x.Name, Value = FB_Plan_Constants.GUESTS[x.Value?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
public static FB_Plan _from_graphql(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("time")?.Value <string>(), title: data.get("event_title")?.Value <string>(), location: data.get("location_name")?.Value <string>() ); rtn.uid = data.get("id")?.Value <string>(); rtn.author_id = data.get("lightweight_event_creator")?.get("id")?.Value <string>(); rtn.guests = data.get("event_reminder_members")?.get("edges")?.Select((x) => { return(new { Key = x.get("node")?.get("id")?.Value <string>(), Value = FB_Plan_Constants.GUESTS[x.get("guest_list_state")?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
public static FB_Plan _from_pull(JToken data) { FB_Plan rtn = new FB_Plan( time: data.get("event_time")?.Value <string>(), title: data.get("event_title")?.Value <string>(), location: data.get("event_location_name")?.Value <string>(), location_id: data.get("event_location_id")?.Value <string>() ); rtn.uid = data.get("event_id")?.Value <string>(); rtn.author_id = data.get("event_creator_id")?.Value <string>(); rtn.guests = JToken.Parse(data.get("guest_state_list")?.Value <string>()).Select((x) => { return(new { Key = x.get("node")?.get("id")?.Value <string>(), Value = FB_Plan_Constants.GUESTS[x.get("guest_list_state")?.Value <string>()] }); }).ToDictionary(t => t.Key, t => t.Value); return(rtn); }
public static FB_Marketplace _from_graphql(JToken data) { if (data.get("image") == null) { data["image"] = new JObject(new JProperty("uri", "")); } var c_info = FB_Group._parse_customization_info(data); var last_message_timestamp = data.get("last_message")?.get("nodes")?.FirstOrDefault()?.get("timestamp_precise")?.Value <string>(); var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null?FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()) : null; return(new FB_Marketplace( uid: data.get("thread_key")?.get("thread_fbid")?.Value <string>(), participants: new HashSet <string>(data.get("all_participants")?.get("nodes")?.Select(node => node.get("messaging_actor")?.get("id")?.Value <string>())), nicknames: (Dictionary <string, string>)c_info.GetValueOrDefault("nicknames"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), admins: new HashSet <string>(data.get("thread_admins")?.Select(node => node.get("id")?.Value <string>())), approval_mode: data.get("approval_mode")?.Value <bool>() ?? false, approval_requests: data.get("group_approval_queue") != null ? new HashSet <string>(data.get("group_approval_queue")?.get("nodes")?.Select(node => node.get("requester")?.get("id")?.Value <string>())) : null, photo: data.get("image")?.get("uri")?.Value <string>(), name: data.get("name")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, last_message_timestamp: last_message_timestamp, plan: plan)); }
/// <summary> /// Represents a Facebook marketplace. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="participants"></param> /// <param name="nicknames"></param> /// <param name="color"></param> /// <param name="emoji"></param> /// <param name="admins"></param> /// <param name="approval_mode"></param> /// <param name="approval_requests"></param> /// <param name="join_link"></param> public FB_Marketplace(string uid, string photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, ISet <string> participants = null, Dictionary <string, string> nicknames = null, string color = null, JToken emoji = null, ISet <string> admins = null, bool approval_mode = false, ISet <string> approval_requests = null, string join_link = null) : base(ThreadType.MARKETPLACE, uid, photo, name, message_count: message_count, last_message_timestamp: last_message_timestamp, plan: plan) { this.participants = participants ?? new HashSet <string>(); this.nicknames = nicknames ?? new Dictionary <string, string>(); this.color = color ?? ThreadColor.MESSENGER_BLUE; this.emoji = emoji; this.admins = admins ?? new HashSet <string>(); this.approval_mode = approval_mode; this.approval_requests = approval_requests ?? new HashSet <string>(); this.join_link = join_link; }
public static FB_User _from_thread_fetch(JToken data) { var c_info = FB_User._parse_customization_info(data); var participants = data.get("all_participants")?.get("nodes")?.Select(node => node.get("messaging_actor")); var user = participants.Where((p) => p.get("id")?.Value <string>() == data.get("thread_key")?.get("other_user_id")?.Value <string>())?.FirstOrDefault(); var last_message_timestamp = data.get("last_message")?.get("nodes")?.FirstOrDefault()?.get("timestamp_precise")?.Value <string>(); var name = user.get("name")?.Value <string>(); var first_name = user.get("first_name")?.Value <string>() ?? user.get("short_name")?.Value <string>(); var last_name = first_name != null?name?.Replace(first_name, "")?.Trim() : null; var gender = GENDER.graphql_GENDERS["UNKNOWN"]; if (data.get("gender")?.Type == JTokenType.Integer) { gender = GENDER.standard_GENDERS[data.get("gender")?.Value <int>() ?? 0]; } else { int gender_int = 0; if (int.TryParse(data.get("gender")?.Value <string>(), out gender_int)) { gender = GENDER.standard_GENDERS[gender_int]; } else { gender = GENDER.graphql_GENDERS[data.get("gender")?.Value <string>() ?? "UNKNOWN"]; } }; if (user.get("big_image_src") == null) { user["big_image_src"] = new JObject(new JProperty("uri", "")); } var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null?FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()) : null; return(new FB_User( uid: user.get("id")?.Value <string>(), url: user.get("url")?.Value <string>(), name: name, first_name: first_name, last_name: last_name, is_friend: user.get("is_viewer_friend")?.Value <bool>() ?? false, gender: gender, affinity: user.get("viewer_affinity")?.Value <float>() ?? 0, nickname: (string)c_info.GetValueOrDefault("nickname"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), own_nickname: (string)c_info.GetValueOrDefault("own_nickname"), photo: user.get("big_image_src")?.get("uri")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, last_message_timestamp: last_message_timestamp, plan: plan)); }
public static FB_User _from_graphql(JToken data) { if (data.get("profile_picture") == null) { data["profile_picture"] = new JObject(new JProperty("uri", "")); } var c_info = FB_User._parse_customization_info(data); var plan = data.get("event_reminders")?.get("nodes")?.FirstOrDefault() != null?FB_Plan._from_graphql(data.get("event_reminders")?.get("nodes")?.FirstOrDefault()) : null; var name = data.get("name")?.Value <string>(); var first_name = data.get("first_name")?.Value <string>() ?? data.get("short_name")?.Value <string>(); var last_name = first_name != null?name?.Replace(first_name, "")?.Trim() : null; var gender = GENDER.graphql_GENDERS["UNKNOWN"]; if (data.get("gender")?.Type == JTokenType.Integer) { gender = GENDER.standard_GENDERS[data.get("gender")?.Value <int>() ?? 0]; } else { int gender_int = 0; if (int.TryParse(data.get("gender")?.Value <string>(), out gender_int)) { gender = GENDER.standard_GENDERS[gender_int]; } else { gender = GENDER.graphql_GENDERS[data.get("gender")?.Value <string>() ?? "UNKNOWN"]; } }; return(new FB_User( uid: data.get("id")?.Value <string>(), url: data.get("url")?.Value <string>(), name: name, first_name: first_name, last_name: last_name, is_friend: data.get("is_viewer_friend")?.Value <bool>() ?? false, gender: gender, affinity: data.get("viewer_affinity")?.Value <float>() ?? 0, nickname: (string)c_info.GetValueOrDefault("nickname"), color: (string)c_info.GetValueOrDefault("color"), emoji: (JToken)c_info.GetValueOrDefault("emoji"), own_nickname: (string)c_info.GetValueOrDefault("own_nickname"), photo: data.get("profile_picture")?.get("uri")?.Value <string>(), message_count: data.get("messages_count")?.Value <int>() ?? 0, plan: plan)); }
/// <summary> /// Represents a Facebook user. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="url"></param> /// <param name="first_name"></param> /// <param name="last_name"></param> /// <param name="is_friend"></param> /// <param name="gender"></param> /// <param name="affinity"></param> /// <param name="nickname"></param> /// <param name="own_nickname"></param> /// <param name="color"></param> /// <param name="emoji"></param> public FB_User(string uid, string photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, string url = null, string first_name = null, string last_name = null, bool is_friend = false, string gender = null, float affinity = 0, string nickname = null, string own_nickname = null, string color = null, JToken emoji = null) : base(ThreadType.USER, uid, photo, name, message_count: message_count, last_message_timestamp: last_message_timestamp, plan: plan) { this.url = url; this.first_name = first_name; this.last_name = last_name ?? (first_name != null ? name?.Replace(first_name, "")?.Trim() : null); this.is_friend = is_friend; this.gender = gender; this.affinity = affinity; this.nickname = nickname; this.own_nickname = own_nickname; this.color = color ?? ThreadColor.MESSENGER_BLUE; this.emoji = emoji; }
/// <summary> /// Represents a Facebook room. Inherits `Group` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="last_message_timestamp"></param> /// <param name="plan"></param> /// <param name="participants"></param> /// <param name="nicknames"></param> /// <param name="color"></param> /// <param name="emoji"></param> /// <param name="admins"></param> /// <param name="approval_mode"></param> /// <param name="approval_requests"></param> /// <param name="join_link"></param> /// <param name="privacy_mode"></param> public FB_Room(string uid, string photo = null, string name = null, int message_count = 0, string last_message_timestamp = null, FB_Plan plan = null, ISet <string> participants = null, Dictionary <string, string> nicknames = null, string color = null, string emoji = null, ISet <string> admins = null, bool approval_mode = false, ISet <string> approval_requests = null, string join_link = null, bool privacy_mode = false) : base(uid, photo, name, message_count, last_message_timestamp, plan, participants, nicknames, color, emoji, admins, approval_mode, approval_requests, join_link) { this.type = ThreadType.ROOM; this.privacy_mode = privacy_mode; }
/// <summary> /// Represents a Facebook page. Inherits `Thread` /// </summary> /// <param name="uid"></param> /// <param name="photo"></param> /// <param name="name"></param> /// <param name="message_count"></param> /// <param name="plan"></param> /// <param name="url"></param> /// <param name="city"></param> /// <param name="likes"></param> /// <param name="sub_title"></param> /// <param name="category"></param> public FB_Page(string uid, string photo = null, string name = null, int message_count = 0, FB_Plan plan = null, string url = null, string city = null, int likes = 0, string sub_title = null, string category = null) : base(ThreadType.PAGE, uid, photo, name, message_count: message_count, plan: plan) { // Represents a Facebook page. Inherits `Thread` this.url = url; this.city = city; this.likes = likes; this.sub_title = sub_title; this.category = category; }