{"__v":0,"_id":"588f722cbcace50f0052ba1a","category":{"version":"588f722bbcace50f0052b9e1","project":"565f5fa26bafd40d0030a064","_id":"588f722bbcace50f0052b9e5","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-18T20:31:28.395Z","from_sync":false,"order":3,"slug":"sdks","title":"Client SDKs"},"parentDoc":null,"project":"565f5fa26bafd40d0030a064","user":"565f5f29de5dc50d00acfe9f","version":{"__v":1,"_id":"588f722bbcace50f0052b9e1","project":"565f5fa26bafd40d0030a064","createdAt":"2017-01-30T17:04:43.410Z","releaseDate":"2017-01-30T17:04:43.410Z","categories":["588f722bbcace50f0052b9e2","588f722bbcace50f0052b9e3","588f722bbcace50f0052b9e4","588f722bbcace50f0052b9e5","588f722bbcace50f0052b9e6","588f722bbcace50f0052b9e7"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"5.3.0","version":"5.3.0"},"updates":["57e54abe7ee1b50e00b7df4e","57ea8c451ac5b01900de38b1"],"next":{"pages":[],"description":""},"createdAt":"2016-05-18T15:14:22.005Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"The nanoscale.io .NET PCL SDK is a lightweight SDK written in C#. It can be used to connect a client to a nanoscale.io gateway. You can view the source <a href=\"https://github.com/nanoscaleio/justapis-dotnetpcl-sdk\" target=\"_blank\">here on GitHub</a>.\n\nDependencies\n===========\n\nAPGW_CORE library\n\nSystem.Net.Http - From NuGet\n\nAutofac - From NuGet\n\nNewtonsoft.JSON - From NuGet\n\nIntroduction\n==========\n\nThe main class to work with is APGateway. You will use an instance of this class to make requests.\n\nAn instance should be created using a builder (APGatewayBuilder). \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGatewayBuilder builder = new APGatewayBuilder();\\nbuilder.url(\\\"http://foo.lvh.me:3000/api/v1/foo\\\");\\n\\n// Provide the application  context and build the gateway object\\nAPGateway gw = builder.build();\",\n      \"language\": \"csharp\",\n      \"name\": \"Instance creation\"\n    }\n  ]\n}\n[/block]\nSetup\n===========\n\nUnpack the zip file to find APGW_|platform|.dll and AGPW_CORE.dll. Place these as dependent assemblies into your app.\n\nBootstrap the SDK by doing:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Common.Config.Setup();\",\n      \"language\": \"csharp\",\n      \"name\": \"Setup\"\n    }\n  ]\n}\n[/block]\nExamples\n===========\n\nCreate an APGateway builder with a base url of http://localhost/api/v1/\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGatewayBuilder builder = new APGatewayBuilder ();\\nbuilder.Uri (\\\"http://localhost/api/v1/\\\");\\nAPGateway gw = builder.Build ();\",\n      \"language\": \"csharp\",\n      \"name\": \"Create builder\"\n    }\n  ]\n}\n[/block]\nSends an asynchronous request with \"/foo\" appended to base url\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGatewayBuilder builder = new APGatewayBuilder ();\\nbuilder.Uri (\\\"http://localhost/api/v1/\\\");\\nAPGateway gw = builder.Build ();\\n\\n// Send the request to http://localhost/api/v1/foo\\ngw.GetAsync (url: \\\"/foo\\\", callback: new APGW.StringCallback () {\\n    OnSuccess = (res) => {\\n        Console.WriteLine (res);\\n    },                 \\n    OnError = (error) => {\\n        Console.WriteLine(error.Message);\\n    }   \\n});\",\n      \"language\": \"csharp\",\n      \"name\": \"Asynchronous get request\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGatewayBuilder builder = new APGatewayBuilder ();\\nbuilder.Uri (\\\"http://localhost/api/v1/\\\");\\nAPGateway gw = builder.Build ();\\n\\nDictionary<string,string> body = new Dictionary<string,string>();\\nbody.Add(\\\"foo\\\", \\\"bar\\\");\\n// Send the request to http://localhost/api/v1/foo\\ngw.PostAsync (url: \\\"/foo\\\", body: body, callback: new APGW.StringCallback () {\\n    OnSuccess = (res) => {\\n        Console.WriteLine (res);\\n    },                 \\n    OnError = (error) => {\\n        Console.WriteLine(error.Message);\\n    }   \\n});\",\n      \"language\": \"csharp\",\n      \"name\": \"Asynchronous post request\"\n    }\n  ]\n}\n[/block]\nSends a synchronous request with \"/foo\" appended to base url\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGatewayBuilder builder = new APGatewayBuilder ();\\nbuilder.Uri (\\\"http://localhost/api/v1/\\\");\\nAPGateway gw = builder.Build ();\\n\\nSystem.Threading.ThreadPool.QueueUserWorkItem((s) => {\\n  // Send the request to http://localhost/api/v1/foo\\n  var result = gw.GetSync (url: \\\"/foo\\\");\\n});\",\n      \"language\": \"csharp\",\n      \"name\": \"Synchronous get request\"\n    }\n  ]\n}\n[/block]\nCertificate Pinning\n===========\n\nCertificate pinning allows you to tie certificates against specified domains. It defends against attacks on certificate authorities.\nIt has it's limitations as well. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"APGW.CertManager.addCert (\\\"localhost\\\", dataAsByteArray);\\n\\nAPGatewayBuilder builder = new APGatewayBuilder ();\\nbuilder.Uri (\\\"http://localhost/api/v1/\\\");\\nAPGateway gw = builder.Build ();\\n\\ngw.UsePinning (true).GetAsync (url: \\\"/foo\\\", callback: new APGW.StringCallback () {\\n    OnSuccess = (res) => {\\n        Console.WriteLine (res);\\n    },                 \\n    OnError = (error) => {\\n        Console.WriteLine(error.Message);\\n    }   \\n});\",\n      \"language\": \"csharp\",\n      \"name\": \"Certificate pinning\"\n    }\n  ]\n}\n[/block]\n```","excerpt":"","slug":"net-pcl","type":"basic","title":".NET PCL"}
The nanoscale.io .NET PCL SDK is a lightweight SDK written in C#. It can be used to connect a client to a nanoscale.io gateway. You can view the source <a href="https://github.com/nanoscaleio/justapis-dotnetpcl-sdk" target="_blank">here on GitHub</a>. Dependencies =========== APGW_CORE library System.Net.Http - From NuGet Autofac - From NuGet Newtonsoft.JSON - From NuGet Introduction ========== The main class to work with is APGateway. You will use an instance of this class to make requests. An instance should be created using a builder (APGatewayBuilder). [block:code] { "codes": [ { "code": "APGatewayBuilder builder = new APGatewayBuilder();\nbuilder.url(\"http://foo.lvh.me:3000/api/v1/foo\");\n\n// Provide the application context and build the gateway object\nAPGateway gw = builder.build();", "language": "csharp", "name": "Instance creation" } ] } [/block] Setup =========== Unpack the zip file to find APGW_|platform|.dll and AGPW_CORE.dll. Place these as dependent assemblies into your app. Bootstrap the SDK by doing: [block:code] { "codes": [ { "code": "Common.Config.Setup();", "language": "csharp", "name": "Setup" } ] } [/block] Examples =========== Create an APGateway builder with a base url of http://localhost/api/v1/ [block:code] { "codes": [ { "code": "APGatewayBuilder builder = new APGatewayBuilder ();\nbuilder.Uri (\"http://localhost/api/v1/\");\nAPGateway gw = builder.Build ();", "language": "csharp", "name": "Create builder" } ] } [/block] Sends an asynchronous request with "/foo" appended to base url [block:code] { "codes": [ { "code": "APGatewayBuilder builder = new APGatewayBuilder ();\nbuilder.Uri (\"http://localhost/api/v1/\");\nAPGateway gw = builder.Build ();\n\n// Send the request to http://localhost/api/v1/foo\ngw.GetAsync (url: \"/foo\", callback: new APGW.StringCallback () {\n OnSuccess = (res) => {\n Console.WriteLine (res);\n }, \n OnError = (error) => {\n Console.WriteLine(error.Message);\n } \n});", "language": "csharp", "name": "Asynchronous get request" } ] } [/block] [block:code] { "codes": [ { "code": "APGatewayBuilder builder = new APGatewayBuilder ();\nbuilder.Uri (\"http://localhost/api/v1/\");\nAPGateway gw = builder.Build ();\n\nDictionary<string,string> body = new Dictionary<string,string>();\nbody.Add(\"foo\", \"bar\");\n// Send the request to http://localhost/api/v1/foo\ngw.PostAsync (url: \"/foo\", body: body, callback: new APGW.StringCallback () {\n OnSuccess = (res) => {\n Console.WriteLine (res);\n }, \n OnError = (error) => {\n Console.WriteLine(error.Message);\n } \n});", "language": "csharp", "name": "Asynchronous post request" } ] } [/block] Sends a synchronous request with "/foo" appended to base url [block:code] { "codes": [ { "code": "APGatewayBuilder builder = new APGatewayBuilder ();\nbuilder.Uri (\"http://localhost/api/v1/\");\nAPGateway gw = builder.Build ();\n\nSystem.Threading.ThreadPool.QueueUserWorkItem((s) => {\n // Send the request to http://localhost/api/v1/foo\n var result = gw.GetSync (url: \"/foo\");\n});", "language": "csharp", "name": "Synchronous get request" } ] } [/block] Certificate Pinning =========== Certificate pinning allows you to tie certificates against specified domains. It defends against attacks on certificate authorities. It has it's limitations as well. [block:code] { "codes": [ { "code": "APGW.CertManager.addCert (\"localhost\", dataAsByteArray);\n\nAPGatewayBuilder builder = new APGatewayBuilder ();\nbuilder.Uri (\"http://localhost/api/v1/\");\nAPGateway gw = builder.Build ();\n\ngw.UsePinning (true).GetAsync (url: \"/foo\", callback: new APGW.StringCallback () {\n OnSuccess = (res) => {\n Console.WriteLine (res);\n }, \n OnError = (error) => {\n Console.WriteLine(error.Message);\n } \n});", "language": "csharp", "name": "Certificate pinning" } ] } [/block] ```