Commits

Collin Watson committed fdb1bec

Project Initialization

Comments (0)

Files changed (14)

+glob:BigDoor.UI/obj/
+glob:BigDoor/bin/
+glob:BigDoor/obj/
+glob:BigDoor.suo
+glob:BigDoor.UI/bin/

BigDoor.UI/BigDoor.UI.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{EBDE1546-9857-4002-BA2A-45180BC9DFDA}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>BigDoor.UI</RootNamespace>
+    <AssemblyName>BigDoor.UI</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\BigDoor\BigDoor.csproj">
+      <Project>{ACE3E89C-4888-43B9-9A5E-A94621400001}</Project>
+      <Name>BigDoor</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

BigDoor.UI/Program.cs

+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+using BigDoor;
+
+namespace BigDoor.UI
+{
+    class Program
+    {
+        static Keys keys = new Keys("APPLICATION", "SECRET");
+
+        static ApiClient BigDoor = new ApiClient(keys, "http://collin.api.bigdoor.com");
+        static void Main(string[] args)
+        {
+            HttpDict query = new HttpDict();
+            query.Add("max_records", "1");
+            Response resp = BigDoor.Read("/named_transaction_group", query);
+            
+            Console.WriteLine(resp.Body);
+        }
+    }
+}

BigDoor.UI/Properties/AssemblyInfo.cs

+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("BigDoor.UI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("BigDoor.Console")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("7d6d620f-a197-4e92-9ead-6b9c13f46318")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BigDoor", "BigDoor\BigDoor.csproj", "{ACE3E89C-4888-43B9-9A5E-A94621400001}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BigDoor.UI", "BigDoor.UI\BigDoor.UI.csproj", "{EBDE1546-9857-4002-BA2A-45180BC9DFDA}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Release|Any CPU.Build.0 = Release|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{ACE3E89C-4888-43B9-9A5E-A94621400001}.Release|x86.ActiveCfg = Release|Any CPU
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Debug|Any CPU.ActiveCfg = Debug|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Debug|Mixed Platforms.Build.0 = Debug|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Debug|x86.ActiveCfg = Debug|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Debug|x86.Build.0 = Debug|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Release|Any CPU.ActiveCfg = Release|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Release|Mixed Platforms.ActiveCfg = Release|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Release|Mixed Platforms.Build.0 = Release|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Release|x86.ActiveCfg = Release|x86
+		{EBDE1546-9857-4002-BA2A-45180BC9DFDA}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BigDoor
+{
+    internal static class Api
+    {
+        public static List<string> Codes = new List<string>()
+        {
+            "Created",
+            "Updated",
+            "Invalid signature; review the Request Signature process and retry",
+            "User Cap met; if applicable, wait and retry or re-configure caps.",
+            "Token previously used (pre); use a unique token",
+            "No Named Group Primary; set a Primary Named Transaction for this group.",
+            "Variable amounts not allowed; retry without passing amount, or reconfigure group.",
+            "Balance exceeded for this user; advise end-user",
+            "Transaction error; alert service provider",
+            "Summary update error; alert service provider",
+            "Token previously used (post); use a unique token",
+            "HTTP Method not allowed on this resource",
+            "HTTP Method not recognized",
+            "User has been disabled; contact us to re-enable",
+            "Named Transaction has incorrect is_source flag. Sales of goods must not be sources",
+            "HTTP Method not allowed because it was missing a required argument",
+            "HTTP Method not allowed because it attempted to use a not owned or otherwise invalid resource",
+            "HTTP Method not allowed because it attempted to use a not owned or otherwise invalid resource",
+            "Timestamp has expired; create a new request with a current timestamp",
+            "6 challenge response failures",
+            "Challenge-response accepted"
+        };
+    }
+}

BigDoor/ApiClient.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BigDoor
+{
+    public class ApiClient
+    {
+        public Keys Keys { get; private set; }
+        public Uri Host { get; set; }
+        public ApiClient(Keys keys) : this(keys, (string)null) { }
+        public ApiClient(Keys keys, string host) : this(keys, new Uri(host)) { }
+        public ApiClient(Keys keys, Uri host)
+        {
+            Keys = keys;
+            Host = host;
+        }
+
+        public Response Read(string path)
+        {
+            return this.Read(path, null);
+        }
+        
+        public Response Read(string path, HttpDict query)
+        {
+            return Request.Read(Keys, path, Host, query);
+        }
+
+        public Response Create(string path)
+        {
+            return this.Create(path, null);
+        }
+
+        public Response Create(string path, HttpDict envelope)
+        {
+            return this.Create(path, envelope, null);
+        }
+
+        public Response Create(string path, HttpDict envelope, HttpDict query)
+        {
+            return Request.Create(Keys, path, Host, envelope, query);
+        }
+
+        public Response Update(string path)
+        {
+            return this.Update(path, null);
+        }
+        
+        public Response Update(string path, HttpDict envelope)
+        {
+            return this.Update(path, envelope, null);
+        }
+        
+        public Response Update(string path, HttpDict envelope, HttpDict query)
+        {
+            return Request.Update(Keys, path, Host, envelope, query);
+        }
+
+        public Response Delete(string path)
+        {
+            return this.Delete(path, null);
+        }
+        
+        public Response Delete(string path, HttpDict query)
+        {
+            return Request.Delete(Keys, path, Host, query);
+        }
+
+        public Response Run(string path, HttpMethod method)
+        {
+            return this.Run(path, method, null);
+        }
+
+        public Response Run(string path, HttpMethod method, HttpDict query)
+        {
+            return this.Run(path, method, query, null);
+        }
+
+        public Response Run(string path, HttpMethod method, HttpDict query, HttpDict envelope)
+        {
+            return Request.Run(Keys, path, method, Host, query, envelope);
+        }
+    }
+}

BigDoor/BigDoor.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{ACE3E89C-4888-43B9-9A5E-A94621400001}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>BigDoor</RootNamespace>
+    <AssemblyName>BigDoor</AssemblyName>
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Newtonsoft.Json.Net20">
+      <HintPath>..\..\..\Downloads\Json35r7\Bin\DotNet20\Newtonsoft.Json.Net20.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ApiClient.cs" />
+    <Compile Include="Api.cs" />
+    <Compile Include="HttpMethod.cs" />
+    <Compile Include="Keys.cs" />
+    <Compile Include="Request.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="HttpDict.cs" />
+    <Compile Include="Response.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

BigDoor/HttpDict.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Collections;
+using System.Runtime.Serialization;
+
+namespace BigDoor
+{
+    public class HttpDict : Dictionary<string, List<string>>
+    {
+        public HttpDict() : base() { }
+        public HttpDict(int capacity) : base(capacity) { }
+        public HttpDict(IEqualityComparer<string> comparer) : base(comparer) { }
+        public HttpDict(IDictionary<string, List<string>> dict) : base(dict) { }
+        public HttpDict(int capacity, IEqualityComparer<string> comparer) : base(capacity, comparer) { }
+        public HttpDict(SerializationInfo info, StreamingContext context) : base(info, context) { }
+        public HttpDict(IDictionary<string, List<string>> dict, IEqualityComparer<string> comparer) : base(dict, comparer) { }
+
+        public void Add<T>(string key, T value)
+        {
+            this.Add<T>(key, new T[] { value });
+        }
+
+        public void Add<T>(string key, IEnumerable<T> values)
+        {
+            if (!this.ContainsKey(key))
+                this[key] = new List<string>();
+
+            if (typeof(T) != typeof(string))
+            {
+                foreach (T val in values)
+                {
+                    string str_val = val.ToString();
+                    if (!String.IsNullOrEmpty(str_val))
+                        this[key].Add(str_val);
+                }
+            }
+            else
+                this[key].AddRange((IEnumerable<string>)values);
+        }
+
+        public override string ToString()
+        {
+            return this.ToString(false);
+        }
+
+        public string ToString(bool sort)
+        {
+            return this.ToString(null, sort, null, null);
+        }
+
+        public string ToString(IDictionary<string, bool> ignores)
+        {
+            return this.ToString(ignores, false, null, null);
+        }
+
+        public string ToString(string pair_format, string value_format)
+        {
+            return this.ToString(null, false, pair_format, value_format);
+        }
+
+        public string ToString(IDictionary<string, bool> ignores, string pair_format, string value_format)
+        {
+            return this.ToString(ignores, false, pair_format, value_format);
+        }
+
+        public string ToString(bool sort, string pair_format, string value_format)
+        {
+            return this.ToString(null, sort, pair_format, value_format);
+        }
+
+        public string ToString(IDictionary<string, bool> ignores, bool sort, string pair_format, string value_format)
+        {
+            if (this.Keys.Count < 1) { return ""; }
+            if (ignores == null) { ignores = new Dictionary<string, bool>(); }
+            IDictionary<string, string> list = new Dictionary<string, string>();
+            if (sort) { list = new SortedList<string, string>(); }
+            if (pair_format == null) { pair_format = "{0}={1}"; }
+            if (value_format == null) { value_format = "{0}&{1}"; }
+
+            foreach (KeyValuePair<string, List<string>> entry in this)
+            {
+                bool ignore = ignores.ContainsKey(entry.Key) && ignores[entry.Key];
+                if (!ignore && entry.Value != null)
+                {
+                    foreach (string val in entry.Value)
+                    {
+                        string k = String.Format(pair_format, entry.Key, val);
+                        list.Add(k, k);
+                    }
+                }
+            }
+
+            string final = "";
+            foreach (KeyValuePair<string, string> pair in list)
+            {
+                if (String.IsNullOrEmpty(final)) 
+                    final = pair.Key;
+                else
+                    final = String.Format(value_format, final, pair.Key);
+            }
+            return final;
+        }
+    }
+}

BigDoor/HttpMethod.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BigDoor
+{
+    public enum HttpMethod
+    {
+        Get, Post, Put, Delete
+    }
+}
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BigDoor
+{
+    public class Keys
+    {
+        public string Application { get; private set; }
+        public string Secret { get; private set; }
+        public Keys(string application, string secret)
+        {
+            if(application == null)
+                throw new ArgumentNullException("application");
+            if(secret == null) 
+                throw new ArgumentNullException("secret");
+
+            application = application.Trim();
+            secret = secret.Trim();
+            
+            if (String.IsNullOrEmpty(application))
+                throw new ArgumentException("Key cannot be empty.", "application");
+            if (String.IsNullOrEmpty(secret))
+                throw new ArgumentException("Key cannot be empty.", "secret");
+
+            Application = application;
+            Secret = secret;
+        }
+    }
+}

BigDoor/Properties/AssemblyInfo.cs

+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("BigDoor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("BigDoor")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("778bea1b-d6cd-475e-ac36-d901ca49fde6")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

BigDoor/Request.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Net;
+using System.IO;
+using System.Security.Cryptography;
+using System.Runtime.Serialization;
+
+namespace BigDoor
+{
+    public static class Request
+    {
+        #region Run
+
+        public static Response Run(Keys keys, string path)
+        {
+            return Run(keys, path, HttpMethod.Get, null, null);
+        }
+        public static Response Run(Keys keys, string path, HttpDict query)
+        {
+            return Run(keys, path, HttpMethod.Get, null, query);
+        }
+        public static Response Run(Keys keys, string path, Uri host)
+        {
+            return Run(keys, path, HttpMethod.Get, host, null);
+        }
+        public static Response Run(Keys keys, string path, HttpMethod method)
+        {
+            return Run(keys, path, method, null, null);
+        }
+        public static Response Run(Keys keys, string path, HttpMethod method, Uri host)
+        {
+            return Run(keys, path, method, host, null);
+        }
+        public static Response Run(Keys keys, string path, HttpMethod method, HttpDict query)
+        {
+            return Run(keys, path, method, null, query);
+        }
+        public static Response Run(Keys keys, string path, HttpMethod method, Uri host, HttpDict query)
+        {
+            return Run(keys, path, method, host, query, null);
+        }
+        public static Response Run(Keys keys, string path, HttpMethod method, Uri host, HttpDict query, HttpDict envelope)
+        {
+            host = host == null ? new Uri("http://api.bigdoor.com") : host;
+            if (path == null) { path = ""; }
+            if (path.StartsWith("/")) { path = path.Substring(1); }
+            if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
+            path = "/api/publisher/" + keys.Application.Replace("/", "") + "/" + path;
+            query = query == null ? new HttpDict() : query;
+            envelope = envelope == null ? new HttpDict() : envelope;
+            string uri_host = host.Scheme + "://" + host.Host + (host.Port == 80 ? "" : ":" + host.Port.ToString());
+            string time = (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds.ToString();
+            query.Add("time", time);
+            envelope.Add("time", time);
+
+            if (method == HttpMethod.Get || method == HttpMethod.Delete) { envelope = null; }
+            if (method == HttpMethod.Delete)
+            {
+                query.Add("delete_token", Guid.NewGuid().ToString().Replace("-", ""));
+            }
+            else if (method == HttpMethod.Post || method == HttpMethod.Put)
+            {
+                envelope.Add("token", Guid.NewGuid().ToString().Replace("-", ""));
+            }
+            string sig = Sign(keys.Secret, path, query, envelope);
+            query.Add("sig", sig);
+            string qs = query.ToString();
+            string abs_path = path + (String.IsNullOrEmpty(qs) ? "" : "?" + qs);
+            WebRequest web_req = HttpWebRequest.Create(new Uri(uri_host + abs_path));
+            web_req.Method = method.ToString().ToUpper();
+            if(envelope != null) {
+                byte[] data = Encoding.UTF8.GetBytes(envelope.ToString());
+                web_req.ContentType="application/x-www-form-urlencoded";
+                web_req.ContentLength = data.Length;
+                using (Stream s = web_req.GetRequestStream()) { s.Write(data, 0, data.Length); }
+            }
+            try { return new Response((HttpWebResponse)web_req.GetResponse()); }
+            catch (WebException e) { return new Response((HttpWebResponse)e.Response); }
+        }
+
+        #endregion
+        
+        #region Create
+
+        public static Response Create(Keys keys, string path)
+        {
+            return Request.Create(keys, path, null, null);
+        }
+        public static Response Create(Keys keys, string path, HttpDict envelope)
+        {
+            return Request.Create(keys, path, null, envelope);
+        }
+        public static Response Create(Keys keys, string path, Uri host)
+        {
+            return Request.Create(keys, path, host, null);
+        }
+        public static Response Create(Keys keys, string path, Uri host, HttpDict envelope)
+        {
+            return Request.Create(keys, path, host, envelope, null);
+        }
+        public static Response Create(Keys keys, string path, Uri host, HttpDict envelope, HttpDict query)
+        {
+            return Request.Run(keys, path, HttpMethod.Post, host, query, envelope);
+        }
+
+        #endregion
+
+        #region Read
+
+        public static Response Read(Keys keys, string path)
+        {
+            return Request.Read(keys, path, null, null);
+        }
+        public static Response Read(Keys keys, string path, HttpDict query)
+        {
+            return Request.Read(keys, path, null, query);
+        }
+        public static Response Read(Keys keys, string path, Uri host)
+        {
+            return Request.Read(keys, path, host, null);
+        }
+        public static Response Read(Keys keys, string path, Uri host, HttpDict query)
+        {
+            return Request.Read(keys, path, host, query, null);
+        }
+        public static Response Read(Keys keys, string path, Uri host, HttpDict query, HttpDict envelope)
+        {
+            return Request.Run(keys, path, HttpMethod.Get, host, query, envelope);
+        }
+
+        #endregion
+
+        #region Update
+
+        public static Response Update(Keys keys, string path)
+        {
+            return Request.Update(keys, path, null, null);
+        }
+        public static Response Update(Keys keys, string path, HttpDict envelope)
+        {
+            return Request.Update(keys, path, null, envelope);
+        }
+        public static Response Update(Keys keys, string path, Uri host)
+        {
+            return Request.Update(keys, path, host, null);
+        }
+        public static Response Update(Keys keys, string path, Uri host, HttpDict envelope)
+        {
+            return Request.Update(keys, path, host, envelope, null);
+        }
+        public static Response Update(Keys keys, string path, Uri host, HttpDict envelope, HttpDict query)
+        {
+            return Request.Run(keys, path, HttpMethod.Put, host, query, envelope);
+        }
+
+        #endregion
+
+        #region Delete
+
+        public static Response Delete(Keys keys, string path)
+        {
+            return Delete(keys, path, null, null);
+        }
+        public static Response Delete(Keys keys, string path, HttpDict query)
+        {
+            return Request.Delete(keys, path, null, query);
+        }
+        public static Response Delete(Keys keys, string path, Uri host)
+        {
+            return Request.Delete(keys, path, host, null);
+        }
+        public static Response Delete(Keys keys, string path, Uri host, HttpDict query)
+        {
+            return Request.Delete(keys, path, host, query, null);
+        }
+        public static Response Delete(Keys keys, string path, Uri host, HttpDict query, HttpDict envelope)
+        {
+            return Request.Run(keys, path, HttpMethod.Delete, host, query, envelope);
+        }
+
+        #endregion
+
+        #region Sign
+
+        private static List<string> SIG_WHITE_LIST = new List<string> { "format", "sig" };
+
+        public static string Sign(string secret, string absolute_path) { return Sign(secret, absolute_path, null); }
+        public static string Sign(string secret, string absolute_path, HttpDict query) { return Sign(secret, absolute_path, query, null); }
+        public static string Sign(string secret, string absolute_path, HttpDict query, HttpDict envelope) {
+            query = query == null ? new HttpDict() : query;
+            envelope = envelope == null ? new HttpDict() : envelope;
+            Dictionary<string, bool> ignores = new Dictionary<string, bool>();
+            foreach (string s in SIG_WHITE_LIST) 
+                ignores[s] = true;
+            string key = absolute_path + query.ToString(ignores, true, "{0}{1}", "{0}{1}") + envelope.ToString(ignores, true, "{0}{1}", "{0}{1}") + secret;
+            return BitConverter.ToString(new SHA256Managed().ComputeHash(Encoding.ASCII.GetBytes(key))).ToLower().Replace("-", "");
+        }
+
+        #endregion
+    }
+}

BigDoor/Response.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Net;
+
+namespace BigDoor
+{
+    public class Response
+    {
+        public string Body { get; private set; }
+        public int ApiCode { get; private set; }
+        public string ApiStatus { get; private set; }
+        public int HttpCode { get; private set; }
+        public string HttpStatus { get; private set; }
+        public Response(HttpWebResponse resp)
+        {
+            HttpCode = (int)resp.StatusCode;
+            HttpStatus = resp.StatusDescription;
+            using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
+            {
+                Body = reader.ReadToEnd();
+            }
+            int api_code = -1;
+            if (HttpCode == 201 && resp.Method == "POST") ApiCode = 0;
+            else if (HttpCode == 200 && resp.Method == "PUT") ApiCode = 1;
+            else if (Int32.TryParse(Body, out api_code)) ApiCode = api_code;
+            else ApiCode = -1;
+            if (ApiCode > -1 && ApiCode < Api.Codes.Count)
+                ApiStatus = Api.Codes[ApiCode];
+        }
+    }
+}