Exemplo n.º 1
0
            public FourSquareTip(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                if (JSONDictionary.ContainsKey("response"))
                {
                    JSONDictionary = ExtractDictionary(JSONDictionary, "response");
                }
                JSONDictionary = ExtractDictionary(JSONDictionary, "tip");
                id = GetDictionaryValue(JSONDictionary, "id");
                text = GetDictionaryValue(JSONDictionary, "text");
                createdAt = GetDictionaryValue(JSONDictionary, "createdAt");
                status = GetDictionaryValue(JSONDictionary, "status");
                url = GetDictionaryValue(JSONDictionary, "url");

                if (JSONDictionary.ContainsKey("photo"))
                {
                    //throw new Exception("To Do Item for this class");
                    //todo
                }

                if (JSONDictionary.ContainsKey("user"))
                {
                    user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
                }
                if (JSONDictionary.ContainsKey("venue"))
                {
                    venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
                }
                if (JSONDictionary.ContainsKey("todo"))
                {
                    if ((GetDictionaryValue(ExtractDictionary(JSONDictionary, "todo"),"count")) != "")
                    {
                        todocount = Convert.ToInt16(GetDictionaryValue(ExtractDictionary(JSONDictionary, "todo"),"count"));
                    }
                }
                if (JSONDictionary.ContainsKey("done"))
                {
                    if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("groups"))
                    {
                        //throw new Exception("To Do Item for this class");
                        //todo
                    }
                    if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("friends"))
                    {
                        //throw new Exception("To Do Item for this class");
                        //todo
                    }
                }
            }
Exemplo n.º 2
0
            public FourSquareVenues(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                JSONDictionary = ExtractDictionary(JSONDictionary, "response");
                if (JSONDictionary != null)
                {
                    if (JSONDictionary["venues"].GetType() == typeof(List<object>))
                    {
                        foreach (object Obj in (GetDictionaryList(JSONDictionary, "venues")))
                        {
                            venues.Add(new FourSquareVenue((Dictionary<string, object>)Obj));
                        }
                        count = venues.Count;
                    }
                    else
                    {
                        JSONDictionary = ExtractDictionary(JSONDictionary, "venues");
                        if (JSONDictionary.ContainsKey("count"))
                        {
                            count = (int)JSONDictionary["count"];
                        }
                        foreach (object Obj in (GetDictionaryList(JSONDictionary, "items")))
                        {
                            Dictionary<string, object> VenueHistoryObj = (Dictionary<string, object>)Obj;
                            int beenHere = 0;
                            if (VenueHistoryObj.ContainsKey("beenHere"))
                            {
                                beenHere = (int)VenueHistoryObj["beenHere"];
                            }

                            FourSquareVenue Venue = new FourSquareVenue((Dictionary<string, object>)((Dictionary<string, object>)Obj)["venue"]);
                            Venue.beenHere = beenHere;
                            venues.Add(Venue);
                        }
                    }
                }
            }
Exemplo n.º 3
0
            public FourSquarePhoto(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                JSONDictionary = ExtractDictionary(JSONDictionary, "response:photo");
                id = JSONDictionary["id"].ToString();
                createdAt = JSONDictionary["createdAt"].ToString();
                url = JSONDictionary["url"].ToString();

                if (JSONDictionary.ContainsKey("sizes"))
                {
                    foreach (object SizeObj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "sizes"),"items")))
                    {
                        sizes.Add(new FourSquarePhotoSize((Dictionary<string, object>)SizeObj));
                    }
                }

                if (JSONDictionary.ContainsKey("source"))
                {
                    //todo
                }

                if (JSONDictionary.ContainsKey("user"))
                {
                    user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
                }

                if (JSONDictionary.ContainsKey("venue"))
                {
                    venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
                }

                if (JSONDictionary.ContainsKey("tip"))
                {
                    //todo
                }

                if (JSONDictionary.ContainsKey("checkin"))
                {
                    checkin = new FourSquareCheckin((Dictionary<string, object>)JSONDictionary["checkin"]);
                }
            }
Exemplo n.º 4
0
 public FourSquareSpecial(Dictionary<string, object> JSONDictionary)
     : base(JSONDictionary)
 {
     JSONDictionary = ExtractDictionary(JSONDictionary, "response:special");
     id = GetDictionaryValue(JSONDictionary, "id");
     type = GetDictionaryValue(JSONDictionary, "type");
     message = GetDictionaryValue(JSONDictionary, "message");
     description = GetDictionaryValue(JSONDictionary, "description");
     finePrint = GetDictionaryValue(JSONDictionary, "finePrint");
     if (GetDictionaryValue(JSONDictionary, "unlocked").ToLower().Equals("true"))
     {
         unlocked = true;
     }
     icon = GetDictionaryValue(JSONDictionary, "icon");
     title = GetDictionaryValue(JSONDictionary, "title");
     state = GetDictionaryValue(JSONDictionary, "state");
     progress = GetDictionaryValue(JSONDictionary, "progress");
     progressDescription = GetDictionaryValue(JSONDictionary, "progressDescription");
     detail = GetDictionaryValue(JSONDictionary, "detail");
     target = GetDictionaryValue(JSONDictionary, "target");
     if (JSONDictionary.ContainsKey("friendsHere"))
     {
         throw new Exception("Todo");
     }
     if (JSONDictionary.ContainsKey("venue"))
     {
         venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
     }
 }
Exemplo n.º 5
0
            public FourSquareCheckin(Dictionary<string, object> JSONDictionary)
                : base(JSONDictionary)
            {
                JSONDictionary = ExtractDictionary(JSONDictionary, "response:checkin");
                id = GetDictionaryValue(JSONDictionary, "id");
                type = GetDictionaryValue(JSONDictionary, "type");
                _private = GetDictionaryValue(JSONDictionary, "private");
                if (JSONDictionary.ContainsKey("user"))
                {
                    user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
                }

                timeZone = GetDictionaryValue(JSONDictionary, "timeZone");

                if (JSONDictionary.ContainsKey("venue"))
                {
                    venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
                }

                if (JSONDictionary.ContainsKey("location"))
                {
                    location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]);
                }

                shout = GetDictionaryValue(JSONDictionary, "shout");
                createdAt = GetDictionaryValue(JSONDictionary, "createdAt");

                if (JSONDictionary.ContainsKey("source"))
                {
                    source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]);
                }

                if (JSONDictionary.ContainsKey("photos"))
                {
                    Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"];
                    if (Int32.Parse(PhotoThings["count"].ToString()) > 0)
                    {
                        foreach (object PhotoObj in (GetDictionaryList( PhotoThings, "items")))
                        {
                            photos.Add(new FourSquarePhoto((Dictionary<string, object>)PhotoObj));
                        }
                    }
                }

                if (JSONDictionary.ContainsKey("comments"))
                {
                    if ((GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items")).Count > 0)
                    {
                        foreach (object obj in (GetDictionaryList( ExtractDictionary(JSONDictionary, "comments"),"items")))
                        {
                            comments.Add(new FourSquareComment((Dictionary<string, object>)obj));
                        }
                    }
                }

                if (JSONDictionary.ContainsKey("overlaps"))
                {
                    foreach (object obj in (GetDictionaryList(ExtractDictionary(JSONDictionary, "overlaps"),"items")))
                    {
                        overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj));
                    }
                }

                if (JSONDictionary.ContainsKey("isMayor"))
                {
                    if (JSONDictionary["isMayor"].ToString().Equals("True"))
                    {
                        IsMayor = true;
                    }
                }
            }
Exemplo n.º 6
0
 /// <summary>
 /// Gives details about a venue, including location, mayorship, tags, tips, specials, and category.
 /// </summary>
 /// <param name="VENUE_ID">required ID of venue to retrieve</param>
 public static FourSquareVenue Venue(string VENUE_ID, string AccessToken)
 {
     HTTPGet GET = new HTTPGet();
     string EndPoint = "https://api.foursquare.com/v2/venues/" + VENUE_ID + "?callback=XXX&v=" + Version + "&oauth_token=" + AccessToken;
     GET.Request(EndPoint);
     Dictionary<string, object> JSONDictionary = JSONDeserializer(GET.ResponseBody);
     FourSquareVenue Venue = new FourSquareVenue(JSONDictionary);
     return Venue;
 }
Exemplo n.º 7
0
        public FourSquareTip(Dictionary<string, object> JSONDictionary)
        {
            JSON = JSONSerializer(JSONDictionary);
            id = GetDictionaryValue(JSONDictionary, "id");
            text = GetDictionaryValue(JSONDictionary, "text");
            createdAt = GetDictionaryValue(JSONDictionary, "createdAt");
            status = GetDictionaryValue(JSONDictionary, "status");
            url = GetDictionaryValue(JSONDictionary, "url");

            if (JSONDictionary.ContainsKey("photo"))
            {
                //throw new Exception("To Do Item for this class");
                //todo
            }

            if (JSONDictionary.ContainsKey("user"))
            {
                user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
            }
            if (JSONDictionary.ContainsKey("venue"))
            {
                venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
            }
            if (JSONDictionary.ContainsKey("todo"))
            {
                if (((int)((Dictionary<string, object>)JSONDictionary["todo"])["count"]) > 0)
                {
                    todocount = ((int)((Dictionary<string, object>)JSONDictionary["todo"])["count"]);
                }
            }
            if (JSONDictionary.ContainsKey("done"))
            {
                if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("groups"))
                {
                    throw new Exception("To Do Item for this class");
                }
                if (((Dictionary<string, object>)JSONDictionary["done"]).ContainsKey("friends"))
                {
                    throw new Exception("To Do Item for this class");
                }
            }
        }
Exemplo n.º 8
0
        public FourSquareCheckin(Dictionary<string, object> JSONDictionary)
        {
            JSON = JSONSerializer(JSONDictionary);

            id = GetDictionaryValue(JSONDictionary, "id");
            type = GetDictionaryValue(JSONDictionary, "type");
            _private = GetDictionaryValue(JSONDictionary, "private");
            if (JSONDictionary.ContainsKey("user"))
            {
                user = new FourSquareUser((Dictionary<string, object>)JSONDictionary["user"]);
            }

            timeZone = GetDictionaryValue(JSONDictionary, "timeZone");

            if (JSONDictionary.ContainsKey("venue"))
            {
                venue = new FourSquareVenue((Dictionary<string, object>)JSONDictionary["venue"]);
            }

            if (JSONDictionary.ContainsKey("location"))
            {
                location = new FourSquareLocation((Dictionary<string, object>)JSONDictionary["location"]);
            }

            shout = GetDictionaryValue(JSONDictionary, "shout");
            createdAt = GetDictionaryValue(JSONDictionary, "createdAt");

            if (JSONDictionary.ContainsKey("source"))
            {
                source = new FourSquareSource((Dictionary<string, object>)JSONDictionary["source"]);
            }

            if (JSONDictionary.ContainsKey("photos"))
            {
                Dictionary<string, object> PhotoThings = (Dictionary<string, object>)JSONDictionary["photos"];
                if (Int32.Parse(PhotoThings["count"].ToString()) > 0)
                {
                    foreach (object obj in (object[])PhotoThings["items"])
                    {
                        //TODO: Photos as an object
                        throw new Exception("Photos here!");
                    }
                }
            }

            if (JSONDictionary.ContainsKey("comments"))
            {
                if (((object[])ExtractDictionary(JSONDictionary, "comments")["items"]).Length > 0)
                {
                    foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "comments")["items"]))
                    {
                        comments.Add(new FourSquareComment((Dictionary<string, object>)obj));
                    }
                }
            }

            if (JSONDictionary.ContainsKey("overlaps"))
            {
                foreach (object obj in ((object[])ExtractDictionary(JSONDictionary, "overlaps")["items"]))
                {
                    overlaps.Add(new FourSquareOverlaps((Dictionary<string, object>)obj));
                }
            }

            if (JSONDictionary.ContainsKey("isMayor"))
            {
                if (JSONDictionary["isMayor"].ToString().Equals("True"))
                {
                    IsMayor = true;
                }
            }
        }
Exemplo n.º 9
0
    /// <summary>
    /// Returns a list of all venues visited by the specified user, along with how many visits and when they were last there.  
    /// </summary>
    /// <param name="USER_ID">For now, only "self" is supported</param>
    /// <param name="BeforeTimeStamp">Seconds since epoch.</param>
    /// <param name="AfterTimeStamp">Seconds after epoch.</param>
    /// <param name="CategoryID">Limits returned venues to those in this category. If specifying a top-level category, all sub-categories will also match the query.</param>
    public static List<FourSquareVenue> UserVenueHistory(string USER_ID, string BeforeTimeStamp, string AfterTimeStamp, string CategoryID, string AccessToken)
    {
        List<FourSquareVenue> VenueHistory = new List<FourSquareVenue>();

        string Query = "";

        if (!BeforeTimeStamp.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "beforeTimestamp=" + BeforeTimeStamp;
        }

        if (!AfterTimeStamp.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "afterTimestamp=" + AfterTimeStamp;
        }

        if (!CategoryID.Equals(""))
        {
            if (Query.Equals(""))
            {
                Query = "?";
            }
            else
            {
                Query += "&";
            }
            Query += "categoryId=" + CategoryID;
        }

        if (Query.Equals(""))
        {
            Query = "?";
        }
        else
        {
            Query += "&";
        }

        HTTPGet GET = new HTTPGet();
        string EndPoint = "https://api.foursquare.com/v2/users/" + USER_ID + "/venuehistory" + Query + "oauth_token=" + AccessToken;
        GET.Request(EndPoint);
        string json = GET.ResponseBody;
        JavaScriptSerializer JSONDeserializer = new JavaScriptSerializer();
        Dictionary<string, object> DeserializedDictionary = (Dictionary<string, object>)JSONDeserializer.Deserialize(json, typeof(object));
        DeserializedDictionary = ExtractDictionary(DeserializedDictionary, "response:venues");
        foreach (object Obj in (object[])DeserializedDictionary["items"])
        {
            int beenHere = Int32.Parse(((Dictionary<string, object>)Obj)["beenHere"].ToString());
            FourSquareVenue Venue = new FourSquareVenue((Dictionary<string, object>)((Dictionary<string, object>)Obj)["venue"]);
            Venue.beenHere = beenHere;
            VenueHistory.Add(Venue);
        }
        return VenueHistory;
    }