{"id":19566762,"url":"https://github.com/vedi/restifizer-unity3d","last_synced_at":"2025-04-27T02:31:34.004Z","repository":{"id":26506020,"uuid":"29958597","full_name":"vedi/restifizer-unity3d","owner":"vedi","description":"Restifizer SDK for Unity3d","archived":false,"fork":false,"pushed_at":"2016-11-20T14:00:31.000Z","size":26,"stargazers_count":62,"open_issues_count":5,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-04T19:32:35.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vedi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-28T08:54:15.000Z","updated_at":"2023-06-13T12:55:53.000Z","dependencies_parsed_at":"2022-08-20T18:50:15.077Z","dependency_job_id":null,"html_url":"https://github.com/vedi/restifizer-unity3d","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedi%2Frestifizer-unity3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedi%2Frestifizer-unity3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedi%2Frestifizer-unity3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vedi%2Frestifizer-unity3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vedi","download_url":"https://codeload.github.com/vedi/restifizer-unity3d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251080168,"owners_count":21533061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T05:33:56.711Z","updated_at":"2025-04-27T02:31:33.770Z","avatar_url":"https://github.com/vedi.png","language":"C#","funding_links":[],"categories":["Game Development"],"sub_categories":["Unity Engine: Resources"],"readme":"﻿Restifizer SDK for Unity3D\n==========\n\nRestifizer - it's a way to significantly simplify creation of full-functional RESTful services, using MongoDB as a database.\nAnd this is SDK that allows you to easily integrate this solution to your Unity3d games.\n  \n\u003e Restifizer is available at https://github.com/vedi/restifizer\n\n\u003e For a quick start you can use our full functional seed-project based on MEAN.JS (http://meanjs.org/), it is available at https://github.com/vedi/restifizer-mean.js.\n\n\u003e The SDK is very young, and we continuously work to improve it. Any feedback is appreciated.\n\n## Prerequisites\n\nThis SDK depends on UnityHTTP (https://github.com/andyburke/UnityHTTP). Please, integrate it to your project.\n\n## Getting started\n\n1. Add sources of SDK to your project.\n1. Put `RestifizerManager` to your scene.\n1. Set up `Base Url` you want to use in Inspector.\n1. Optionally, set `Error Handler` draging there the script that implements `IErrorHandler` interface (see `Error Handling` for details).\n1. Bind `RestifizerManager` to a script, where you want to use it (defining such property in the script, adn setting it in Inspector).\n\nYou're ready to make requests to Restifizer.\n\n## Requests\n\nRestifizerManager allows you to create `RestifizerRequest` with the following call:\n \n```\nRestifizerManager.ResourceAt(path)\n```\n\nFor example,\n\n```\nRestifizerManager.ResourceAt(\"api/users\")\n```\n\n`RestifizerRequest` has a set of self-explanatory methods which can be combined to a chain if calls. For example:\n\n```\nRestifizerManager.ResourceAt(\"api/users\").SetFields(\"name\").OrderBy(\"createdAt\")\n```\n\nThe example creates and configures the request to work with \"api/users\" path and set up `field` and `orderBy` params (see appropriate sections in Restifizer documentation https://github.com/vedi/restifizer#supported-params).\n\nAfter you configured the request as a final touch you should specify http-method to call. The following methods are supported:\n* GET,\n* POST,\n* PUT,\n* PATCH,\n* DELETE.\n\nWhen you call GET you provide just `callback`, for other methods you additionaly provide `params` - \nHashtable to be serialized to JSON and put to request body.\n\nFor example, getting list of the users:\n\n```\nRestifizerManager.ResourceAt(\"api/users\").\n        SetFields(\"name\").\n        OrderBy(\"createdAt\").\n        Get((response) =\u003e {\n            // response.ResourceList - at this point you can use the result\n        });\n```\n\nAnd another example, signing up an user:\n\n```\n        Hashtable parameters = new Hashtable();\n        parameters.Add(\"username\", \"test\");\n        parameters.Add(\"password\", \"test\");\n\n        RestifizerManager.ResourceAt(\"api/users\").Post(parameters, (response) =\u003e {\n            // response.Resource - at this point you can use the result \n        });\n\n```\n\n## Accessing to exact resources\n\nThere is a lot of cases, where we need to specify ID of an affected resource in our request. \nIn REST API such IDs are specified as an additional part of resource path. \nIn Restifizer SDK in order to focus a request on an exact record you should call `One` method, passing ID there.\n    \nFor example, we are changing an user's password:\n```\n        Hashtable parameters = new Hashtable();\n        parameters.Add(\"password\", \"newPassword\");\n\n        RestifizerManager.ResourceAt(\"api/users\").One(userId).Patch(parameters, (response) =\u003e {\n            // response.Resource - at this point you can use the result \n        });\n        \n```\n\n## Authentication\n\nRestifizer SDK support 2 kinds of authentications: \n* Client Credentials (https://tools.ietf.org/html/rfc6749#section-1.3.4)\n* Access Token (https://tools.ietf.org/html/rfc6749#section-1.4)\n \nIn order to use it in your request you need to configure `RestifizerManager` before.\n\n### Client Credentials\n\nConfiguration:\n\n```\nRestifizerManager.ConfigClientAuth(CLIENT_ID, CLIENT_SECRET);\n```\n\nUsing (add `WithClientAuth()` to the chain):\n\n```\nRestifizerManager.ResourceAt(\"api/users\").\n        WithClientAuth().\n        SetFields(\"name\").\n        OrderBy(\"createdAt\").\n        Get((response) =\u003e {\n            // response.ResourceList - at this point you can use the result\n        });\n```\n\n### Access Token\n\nConfiguration:\n\n```\nRestifizerManager.ConfigBearerAuth(accessToken);\n```\n\nUsing (add `WithBearerAuth()` to the chain):\n\n```\n        RestifizerManager.ResourceAt(\"api/users\").\n                WithBearerAuth().\n                One(userId).\n                Patch(parameters, (response) =\u003e {\n                    // response.Resource - at this point you can use the result \n                });\n```\n\n## Response\n\nResponse from the server is wrapped with `RestifizerResponse` that provides you with parsed data. \nDepending on context of request it can be a resource or a list of resources. \nThere are 2 appropriate properties for this: `response.Resource` - `Hashtable`, or `response.ResourceList` - `ArrayList` of `Hashtable`s.\n    \n## Error Handling\n\nThere are 2 approaches to handle error in the SDK: via EventHandler, and in callbacks of requests.\n\nIf you set `ErrorHandler` of `RestifizerManager` with instance of `IErrorHandler`, every error will pass through its method\n`bool onRestifizerError(RestifizerError restifizerError)`. \nIf you want to suppress further handling in `callback` of the request, you should return `false` in this method.\nOtherwise, your callback will be called, with `Error` propery of response set to instance of `RestifizerError`.\n  \nFor example,\n\n```\n    public bool onRestifizerError(RestifizerError restifizerError) {\n        Debug.Log(restifizerError.Message);\n        return true;    // do not stop propagating\n    }\n\n    public void ExitGame() {\n\n        Hashtable parameters = new Hashtable();\n        . . .\n        RestifizerManager.ResourceAt(\"api/games/\").One(gameId).WithBearerAuth().Patch(parameters, (response) =\u003e {\n          if (response.HasError) {\n            // handle response.Error here\n          }\n        });\n    }\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedi%2Frestifizer-unity3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvedi%2Frestifizer-unity3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvedi%2Frestifizer-unity3d/lists"}