diff --git a/.gitignore b/.gitignore
index 0165950..15f7150 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,156 @@
-Sample/Sample/obj
+################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+
+[Dd]ebug/
+x64/
+build/
+[Bb]in
+[Oo]bj
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.log
+*.scc
+
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+*.cachefile
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+*.ncrunch*
+.*crunch*.local.xml
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.Publish.xml
+*.pubxml
+
+# NuGet Packages Directory
+## TODO: If you have NuGet Package Restore enabled, uncomment the next line
+packages
+
+# Windows Azure Build Output
+csx
+*.build.csdef
+
+# Windows Store app package directory
+AppPackages/
+
+# Others
+sql/
+*.Cache
+ClientBin/
+[Ss]tyle[Cc]op.*
+~$*
+*~
+*.dbmdl
+*.[Pp]ublish.xml
+*.pfx
+*.publishsettings
+*.user
+/.nuget
+
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+App_Data/*.mdf
+App_Data/*.ldf
+
+#############
+## Windows detritus
+#############
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Mac crap
+.DS_Store
+
diff --git a/CoconutAPI/CoconutAPI.cs b/CoconutAPI/CoconutAPI.cs
index cd39206..ef0d995 100644
--- a/CoconutAPI/CoconutAPI.cs
+++ b/CoconutAPI/CoconutAPI.cs
@@ -1,48 +1,58 @@
-using System;
using RestSharp;
-using System.Web.Script.Serialization;
-using System.Collections.Generic;
using System.Net;
+using Newtonsoft.Json;
+using RestSharp.Authenticators;
namespace Coconut
{
- public class CoconutAPI
- {
- RestClient Cli;
- JavaScriptSerializer Json;
+ public interface ICoconutAPI
+ {
+ ///
+ /// Create a Job
+ ///
+ /// A string representing the config content
+ /// CoconutJob instance
+ CoconutJob Submit(string data);
+ }
+
+ public class CoconutAPI : ICoconutAPI
+ {
+ private RestClient _cli;
///
- /// Create an CoconutClient instance
+ /// Create an CoconutAPI instance
///
- ///
+ ///
///
- /// CoconutClient Coconut = new CoconutClient("k-myapikey");
+ /// CoconutAPI Coconut = new CoconutAPI("k-myapikey");
///
- public CoconutAPI (string APIKey)
+ public CoconutAPI (string apiKey)
{
- Cli = new RestClient("https://api.coconut.co");
- Cli.Authenticator = new HttpBasicAuthenticator(APIKey, "");
- Cli.AddDefaultHeader("Accept", "application/json");
- Cli.UserAgent = "Coconut/2.0.0 (dotnet)";
-
- Json = new JavaScriptSerializer();
+ _cli = new RestClient("https://api.coconut.co")
+ {
+ Authenticator = new HttpBasicAuthenticator(apiKey, "")
+ };
+ _cli.AddDefaultHeader("Accept", "application/json");
+ _cli.UserAgent = "Coconut/2.0.0 (dotnet)";
}
+ ///
/// Create a Job
///
- /// A string representing the config content
+ /// A string representing the config content
/// CoconutJob instance
- public CoconutJob Submit(string Data)
+ public CoconutJob Submit(string data)
{
- return Json.Deserialize(Request("v1/job", Method.POST, Data));
+ return JsonConvert.DeserializeObject(Request("v1/job", Method.POST, data));
}
- private string Request(string path, RestSharp.Method method, string Data) {
+ private string Request(string path, RestSharp.Method method, string data)
+ {
var request = new RestRequest(path, method);
- request.AddParameter("text/plain", Data, ParameterType.RequestBody);
+ request.AddParameter("text/plain", data, ParameterType.RequestBody);
- RestResponse response = Cli.Execute(request);
+ var response = _cli.Execute(request);
var code = response.StatusCode;
if(code == HttpStatusCode.Created || code == HttpStatusCode.OK || code == HttpStatusCode.NoContent)
@@ -51,8 +61,8 @@ private string Request(string path, RestSharp.Method method, string Data) {
}
else
{
- string ErrorMessage = Json.Deserialize (response.Content).Message;
- throw new CoconutException(ErrorMessage);
+ var errorMessage = JsonConvert.DeserializeObject (response.Content).Message;
+ throw new CoconutException(errorMessage);
}
}
diff --git a/CoconutAPI/CoconutAPI.csproj b/CoconutAPI/CoconutAPI.csproj
index 330f975..8e55933 100644
--- a/CoconutAPI/CoconutAPI.csproj
+++ b/CoconutAPI/CoconutAPI.csproj
@@ -1,4 +1,4 @@
-
+
Debug
@@ -28,11 +28,16 @@
False
+
+ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+ ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
+ True
+
-
- ..\RestSharp.dll
-
@@ -40,5 +45,8 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/CoconutAPI/bin/Debug/CoconutAPI.dll b/CoconutAPI/bin/Debug/CoconutAPI.dll
deleted file mode 100755
index 87dbaf3..0000000
Binary files a/CoconutAPI/bin/Debug/CoconutAPI.dll and /dev/null differ
diff --git a/CoconutAPI/bin/Debug/CoconutAPI.dll.mdb b/CoconutAPI/bin/Debug/CoconutAPI.dll.mdb
deleted file mode 100644
index 7014bba..0000000
Binary files a/CoconutAPI/bin/Debug/CoconutAPI.dll.mdb and /dev/null differ
diff --git a/CoconutAPI/bin/Debug/RestSharp.dll b/CoconutAPI/bin/Debug/RestSharp.dll
deleted file mode 100755
index 7fc5f1e..0000000
Binary files a/CoconutAPI/bin/Debug/RestSharp.dll and /dev/null differ
diff --git a/CoconutAPI/bin/Release/CoconutAPI.dll b/CoconutAPI/bin/Release/CoconutAPI.dll
deleted file mode 100755
index 5fcffe5..0000000
Binary files a/CoconutAPI/bin/Release/CoconutAPI.dll and /dev/null differ
diff --git a/CoconutAPI/bin/Release/RestSharp.dll b/CoconutAPI/bin/Release/RestSharp.dll
deleted file mode 100755
index 7fc5f1e..0000000
Binary files a/CoconutAPI/bin/Release/RestSharp.dll and /dev/null differ
diff --git a/CoconutAPI/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs b/CoconutAPI/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
deleted file mode 100644
index fdcb678..0000000
--- a/CoconutAPI/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-//
-[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
diff --git a/CoconutAPI/obj/Debug/CoconutAPI.csproj.FilesWrittenAbsolute.txt b/CoconutAPI/obj/Debug/CoconutAPI.csproj.FilesWrittenAbsolute.txt
deleted file mode 100644
index 643511d..0000000
--- a/CoconutAPI/obj/Debug/CoconutAPI.csproj.FilesWrittenAbsolute.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/bin/Debug/CoconutAPI.dll.mdb
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/bin/Debug/CoconutAPI.dll
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Debug/CoconutAPI.dll
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Debug/CoconutAPI.dll.mdb
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/bin/Debug/RestSharp.dll
diff --git a/CoconutAPI/obj/Debug/CoconutAPI.dll b/CoconutAPI/obj/Debug/CoconutAPI.dll
deleted file mode 100755
index 87dbaf3..0000000
Binary files a/CoconutAPI/obj/Debug/CoconutAPI.dll and /dev/null differ
diff --git a/CoconutAPI/obj/Debug/CoconutAPI.dll.mdb b/CoconutAPI/obj/Debug/CoconutAPI.dll.mdb
deleted file mode 100644
index 7014bba..0000000
Binary files a/CoconutAPI/obj/Debug/CoconutAPI.dll.mdb and /dev/null differ
diff --git a/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.1.AssemblyAttribute.cs b/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.1.AssemblyAttribute.cs
deleted file mode 100644
index 50eaa9f..0000000
--- a/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.1.AssemblyAttribute.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-//
-[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5.1", FrameworkDisplayName = "")]
diff --git a/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.AssemblyAttribute.cs b/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.AssemblyAttribute.cs
deleted file mode 100644
index fdcb678..0000000
--- a/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.AssemblyAttribute.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-//
-[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
diff --git a/CoconutAPI/obj/Release/CoconutAPI.csproj.FilesWrittenAbsolute.txt b/CoconutAPI/obj/Release/CoconutAPI.csproj.FilesWrittenAbsolute.txt
deleted file mode 100644
index 19d5268..0000000
--- a/CoconutAPI/obj/Release/CoconutAPI.csproj.FilesWrittenAbsolute.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.1.AssemblyAttribute.cs
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/bin/Release/CoconutAPI.dll
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Release/CoconutAPI.dll
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/bin/Release/RestSharp.dll
-/Users/sadikzzz/Dev/coconut/libraries/coconutnet/CoconutAPI/obj/Release/.NETFramework,Version=v4.5.AssemblyAttribute.cs
diff --git a/CoconutAPI/obj/Release/CoconutAPI.dll b/CoconutAPI/obj/Release/CoconutAPI.dll
deleted file mode 100755
index 5fcffe5..0000000
Binary files a/CoconutAPI/obj/Release/CoconutAPI.dll and /dev/null differ
diff --git a/CoconutAPI/packages.config b/CoconutAPI/packages.config
new file mode 100644
index 0000000..7b2a573
--- /dev/null
+++ b/CoconutAPI/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/RestSharp.dll b/RestSharp.dll
deleted file mode 100755
index 7fc5f1e..0000000
Binary files a/RestSharp.dll and /dev/null differ