static void Main()
        {
            var baseUrl = "http://localhost:12243/";
            var contentType = "application/json";
            var requester = new HttpRequester(baseUrl, contentType);

            // Test album Creation
            Album album = new Album { Producer = "Pesho", Title = "Testov album", ReleaseDate = DateTime.Now };
            requester.Post<Album>("api/album", album);
            Console.WriteLine("Simple Album added!");

            Song song = new Song { Genre = "RnB", Title = "Shake it!", Year = DateTime.Now.AddYears(-20) };
            Artist artist = new Artist { Name = "Pesho Zlia", BirthDate = new DateTime(1950, 1, 1), Country = "Germany" };
            album.Songs.Add(song);
            album.Artists.Add(artist);

            requester.Post<Album>("api/album", album);
            Console.WriteLine("Album added!");

            // Test albums Retrieving
            var retrievedAlbums = requester.Get<IList<Album>>("api/album/");
            foreach (var retrievedAlbum in retrievedAlbums)
            {
                Console.WriteLine("Album found! Title:" + retrievedAlbum.Title);
            }

            // Test one album Retrieving
            var getedAlbum = requester.Get<Album>("api/album/" + retrievedAlbums[0].AlbumId);

            Console.WriteLine("First Album found! Title:" + getedAlbum.Title);

            // Test album updating

            getedAlbum.Title = "Updated Title";
            requester.Put<Album>("api/album/" + getedAlbum.AlbumId, getedAlbum);
            Console.WriteLine("Title updated!");

            // Check new title
            getedAlbum = requester.Get<Album>("api/album/" + retrievedAlbums[0].AlbumId);
            Console.WriteLine("First Album found! Title:" + getedAlbum.Title);

            // Add
            Album newAlbum = new Album { Producer = "Pesho", Title = "Testov album", ReleaseDate = DateTime.Now };

            //Delete the album!
            requester.Delete<Album>("api/album/" + getedAlbum.AlbumId, getedAlbum);
            Console.WriteLine("Album deleted");
        }
Exemple #2
0
        static void Main()
        {
            //Dictionary<string, string> requestMap = new Dictionary<string, string>();
            //requestMap.Add("callback", "Payeezy.callback");
            //requestMap.Add("ta_token", "123");
            //requestMap.Add("auth", "false");
            //requestMap.Add("type", "FDToken");
            //requestMap.Add("credit_card.type", "visa");
            //requestMap.Add("credit_card.cardholder_name", "Kolev Iliya");
            //requestMap.Add("credit_card.card_number", "4788250000028291");
            //requestMap.Add("credit_card.exp_date", "1218");
            //requestMap.Add("credit_card.cvv", "123");
            //// billing address is optional
            //requestMap.Add("billing_address.city", "St.Louis");
            //requestMap.Add("billing_address.country", "US");
            //requestMap.Add("billing_address.email", "*****@*****.**");
            //requestMap.Add("billing_address.phone.type", "home");
            //requestMap.Add("billing_address.phone.number", "212-515-1212");
            //requestMap.Add("billing_address.street", "12115 LACKLAND");
            //requestMap.Add("billing_address.state_province", "MO");
            //requestMap.Add("billing_address.phone.number", "212-515-1212");
            //requestMap.Add("billing_address.zip_postal_code", "63146");

            // this picks the properties from the .payeezy.properties files
            // alternatively you can populate the properties and pass it to the constructor
            //PayeezyClientHelper clientHelper = new PayeezyClientHelper();
            //try
            //{
            //    PayeezyResponse payeezyResponse = clientHelper.doGetTokenCall(requestMap);
            //    Console.WriteLine(payeezyResponse.getResponseBody());
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.StackTrace);
            //}
            var studentsServiceUrl = "https://api-cert.payeezy.com";

            var testUrl = "http://localhost:29863";

            //HttpRequester.Post(studentsServiceUrl + "students", newBook);

            //var card = new Card()
            //{
            //    Id = 1,
            //    Token = "465456464666",
            //    HolderName = "Ivan Ivanov"
            //};


            //var cards = HttpRequester.Get<IEnumerable<Card>>(studentsServiceUrl + "/v1/securitytokens");


            //var values = Hvar values = HttpRequester.Get<ValuesResponse>(testUrl + "/api/values");ttpRequester.Get<ValuesResponse>(testUrl + "/api/values");

            //var values = HttpRequester.Get<ValuesResponse>(testUrl + "/api/values");
            //var newVal = new ValuesResponse() { Name = "NovoJivotno" };
            //var responsePostValue = HttpRequester.Post<string>(testUrl + "/api/values", newVal);
            //Console.WriteLine(responsePostValue);
            ////HttpRequester.Get(testUrl + "/api/values");
            //Console.WriteLine(values.Name);
            //foreach (var item in values)
            //{
            //    Console.WriteLine(item);
            //}



            var values = HttpRequester.Get <Card>("https://api-cert.payeezy.com" + "/v1/securitytokens?apikey=y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a&js_security_key=js-6125e57ce5c46e10087a545b9e9d7354c23e1a1670d9e9c7&ta_token=NOIW&auth=true&callback=Payeezy.callback&type=FDToken&credit_card.type=visa&credit_card.cardholder_name=John%20Smith&credit_card.card_number=4788250000028291&credit_card.exp_date=1030&credit_card.cvv=123");

            Console.WriteLine(values.Status);
            Console.WriteLine(values.Result.Token.Value);


            var newVal = new ValuesResponse()
            {
                Name = "NovoJivotno"
            };

            var data = new Purchase()
            {
                MerchantRef     = "Astonishing-Sale",
                TransactionType = "purchase",
                Method          = "token",
                Amount          = "200",
                CurrencyCode    = "USD",
                Token           = new Token()
                {
                    TokenType = "FDToken",
                    TokenData = new TokenData()
                    {
                        Type           = "visa",
                        Value          = "2537446225198291",
                        CardholderName = "JohnSmith",
                        ExpDate        = "1030"
                    }
                }
            };

            Dictionary <string, string> requestHeaderMap = new Dictionary <string, string>();

            requestHeaderMap.Add(SecurityConstants.APIKEY, "y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a");
            requestHeaderMap.Add(SecurityConstants.TOKEN, "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6");
            requestHeaderMap.Add(SecurityConstants.AUTHORIZE, "YWI2MjFkMzVhOWVhMTkzZTZlYjExYzYxMGFhZWM1ZWY1NWQ3NDgwNTA1YmNhZTM0ZmNmM2Q1MjkxMzVmNDMzZA");
            requestHeaderMap.Add(SecurityConstants.TIMESTAMP, "1480621081859");

            var responsePostValue = HttpRequester.Post <PurchaseResponse>("https://api-cert.payeezy.com/v1/transactions", data, requestHeaderMap);

            Console.WriteLine(responsePostValue.Method);


            //var jsonHelper = new JSONHelperN<Card>();
            //var sss = jsonHelper.getJSONObject(card);
            //Console.WriteLine(sss);
            //var kkk = jsonHelper.fromJson(sss);
            //Console.WriteLine(kkk.Token);

            //var url = "http://www.abv.bg";
            //HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            //HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            //if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
            //    Console.WriteLine("\r\nResponse Status Code is OK and StatusDescription is: {0}",
            //                         myHttpWebResponse.StatusDescription);
            //// Releases the resources of the response.
            //Console.WriteLine(myHttpWebResponse.GetResponseStream());
            //Console.WriteLine("-------------------------------------");
            //Console.WriteLine(myHttpWebResponse.GetResponseStream());
            //myHttpWebResponse.Close();
        }