From 56da10452064b672feeb0d487fec62941b7f5f39 Mon Sep 17 00:00:00 2001 From: esau Date: Tue, 16 Jun 2015 10:50:50 -0300 Subject: [PATCH] alteração de pastas --- Readme.md | 117 --------------------------------------------------------------------------------------------------------------------- api-rest.pdf | Bin 37485 -> 0 bytes js/client/README.md | 364 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rest/Readme.md | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rest/Readme.pdf | Bin 0 -> 37485 bytes 5 files changed, 481 insertions(+), 117 deletions(-) delete mode 100644 Readme.md delete mode 100644 api-rest.pdf create mode 100644 js/client/README.md create mode 100644 rest/Readme.md create mode 100644 rest/Readme.pdf diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 61e2f29..0000000 --- a/Readme.md +++ /dev/null @@ -1,117 +0,0 @@ -# Authenticate - -This method authenticate a player to your gamification and opens a session for the authenticated player on success. Authentication against the Funifier API is done with your gamification's API key, Authentication Mode and some combinations of credentials. - -GET Method - -```sh -http[s]://service2.funifier.com/2.0.0/authenticate -``` - -**Parameters** . - - - api_key: **String/Required** - Field that identify the key of gamification - - auth_mode: **String/Required** - Identify which method of authentication will use. The values can be [IMPLICIT,PASSWORD,CREDENTIAL,FACEBOOK] - - oauth_access_token: **String/Optional** - Use this field when the auth_mode is FACEBOOK. This value is the Facbook Token - - player: **String/Required** - Identify the Player of gamification - - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security - - password: **String/Optional** - Use this field when the auth_mode authentication is PASSWORD - - expiration: **int/Optional** - Used to define expirations time in seconds of sessions - - language: **int/Optional** - Set the default language in authentication - - callback: **String/Optional** - Use to callbacks in javascript - -### Example Request -```sh -https://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=IMPLICIT&player=player@funifier.com -``` -```sh -https://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=PASSWORD&player=player@funifier.com&password=123 -``` -```sh -mhttps://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=CREDENTIAL&player=player@funifer.com&app_secret=54d80b7f34282de652978326 -``` - -### Example Response Sucess - -```sh -{"access_token" : "54d80a14e4b0e8d184586a1c"} -``` -### Example Response Error -``` -{"message" : "player player@funifier.com does not exist, ask your administrator to create it in studio2.funifier.com","code" : 401,"type" : "Unauthorized"} -``` - -# Track - -This method send actions performed by players to Funifier. Requires you to call this method whenever the action occurs, and pass the action name, and all the metadata you care about. - -POST Method - -```sh -http[s]://service2.funifier.com/2.0.0/track -``` - - - api_key: **String/Required** - Field that identify the key of gamification - - access_token: **String/Required** - This field authorize the player to request this method, This value can be obtain by method Authenticate - - player: **String/Required** - Identify the Player of gamification - - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security - - action: **String/Required** - This field identifies the action that will be registered - - attributes: **String/Optional** - In This field can be past the objects of action. It is a Json Object. e.g. {"attribute1":"value1", "attribute2":"value2"} - - timestamp: **long/Optional** - This field is used to define a date. The type is a long - - callback: **String/Optional** - Use to callbacks in javascript - -### Example Request - -```sh -https://service2.funifier.com/2.0.0/track?api_key=556df789108d44a65c389583&action=sell&attributes={"product":"book","price":12.5}&access_token=54d8139ae4b0e8d184586a1f -``` -```sh -https://service2.funifier.com/2.0.0/track?api_key=556df789108d44a65c389583&action=sell&attributes={"product":"book","price":12.5}&player=player@funifier.com&app_secret=54d80b7f34282de652978326 -``` -### Example Response Sucess -```sh -{"message" : "action tracked","code" : 200,"type" : "OK"} -``` -### Example Response Error -``` -{"message" : "action sell does not exist","code" : 400, "type" : "Bad Request"} -``` - -# Widget Data - -This method retrieves information about players, win-states, incentives and other objects inside the gamification. Use this to show to visually engage the players with their status and other infos. - -GET Method -```sh -http[s]://service2.funifier.com/2.0.0/get_widget_data -``` -## Parameters - - - - api_key: **String/Required** - Field that identify the key of gamification - - oauth_access_token: **String/Optional** - Use this field when the auth_mode is FACEBOOK. This value is the Facbook Token - - player: **String/Required** - Identify the Player of gamification - - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security - - include_teams: **boolean/Optional** - If value is true, the list of teams will be loaded - - include_levels: **boolean/Optional** - If value is true, the list of levels will be loaded - - include_challenges: **boolean/Optional** If value is true, the list of challenges will be loaded - - include_catalogs: **boolean/Optional** - If value is true, the list of catalogs will be loaded - - include_leaderboards: **boolean/Optional** - If value is true, the list of leaderboards will be loaded - - include_friends: **boolean/Optional** - If value is true, the list of friends will be loaded - - include_actions: **boolean/Optional** - If value is true, the list of actions will be loaded - - include_points: **boolean/Optional** - If value is true, the list of points will be loaded - - language: **int/Optional** - Set the default language in authentication - - callback: **String/Optional** - Use to callbacks in javascript - -# Example Response -```sh - https://service2.funifier.com/2.0.0/get_widget_data?api_key=556df789108d44a65c389583&access_token=54d8139ae4b0e8d184586a1f&include_challenges=true -``` - -```sh - https://service2.funifier.com/2.0.0/get_widget_data?api_key=556df789108d44a65c389583&player=ricardo@funifier.com&app_secret=54d80b7f34282de652978326&include_challenges=true -``` -## Example Response -```sh -{"player":{"name" : "Player Name","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"total_challenges" : 2,"challenges" : {"54d8098034282de65297817a" : 1,"54d809dc34282de65297822f" : 1},"total_points" : 25,"point_categories" : {"54d8064034282de652977c52" : 25},"total_catalog_items" : 1,"catalog_items" : {"54d8077c34282de652977e7f" : 1},"level_progress" : {"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8067e34282de652977cb6"},"percent_completed" : 2.5,"next_points" : 975,"next_level" : {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8069734282de652977cf0"},"total_levels" : 2,"percent" : 2.5},"challenge_progress" : [ ],"teams" : [ "54d806c134282de652977d65", "54d806d534282de652977d9e", "54d806e934282de652977df8" ],"friends" : [ "player@funifier.com" ],"positions" : [ ],"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8067e34282de652977cb6"},"_id" : "player@funifier.com"},"teams":[ {"name" : "Brazil","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806c134282de652977d65"}, {"name" : "Canada","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806d534282de652977d9e"}, {"name" : "Mexico","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806e934282de652977df8"} ],"levels":[ {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"}, {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8069734282de652977cf0"} ],"challenges":[ {"challenge" : "Big Sales Hero","description" : "You are a sales hero for closing a big opportunity of $100.000. enjoy this reward as you have earned the right to be recognized as a \"big sales hero\". PS. enjoy the commission cheque!","range" : 0,"active" : true,"rules" : [ {"actionId" : "54d8088c34282de652978027","position" : 1,"operator" : 5,"total" : 0,"timeAmount" : 0,"timeScale" : 0,"outOfTime" : false,"everyAmount" : 0,"everyScale" : 0,"filters" : [ {"value" : "100000","operator" : 5,"param" : "price"} ],"_id" : "54d8098034282de652978179"} ],"triggerUrl" : "","teamChallenge" : false,"limitTotal" : 1,"limitPerType" : 0,"limitTimeAmount" : 1,"limitTimeScale" : 5,"badge" : {"medium" : {"url" : "http://funifier.com/image.png"}},"hideUntilEarned" : false,"points" : [ {"total" : 10,"category" : "54d8064034282de652977c52","operation" : 0} ],"notifications" : [ {"event" : 0,"type" : 0,"scope" : 0,"content" : "{} completed {}"} ],"items" : [ "54d8077c34282de652977e7f" ],"tags" : [ ],"triggerURL" : "","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8098034282de65297817a"}, {"challenge" : "Lead Start","description" : "Register your first lead in the system to earn this badge. Use the system well is a good way to start your sales career and earn 5 experiences points.","range" : 0,"active" : true,"rules" : [ {"actionId" : "54d808a634282de65297805f","position" : 1,"operator" : 5,"total" : 0,"timeAmount" : 0,"timeScale" : 0,"outOfTime" : false,"everyAmount" : 0,"everyScale" : 0,"filters" : [ ],"_id" : "54d809dc34282de65297822e"} ],"triggerUrl" : "","teamChallenge" : false,"limitTotal" : 1,"limitPerType" : 0,"limitTimeAmount" : 0,"limitTimeScale" : 0,"badge" : {"medium" : {"url" : "http://funifier.com/image.png"}},"principals" : [ ],"hideUntilEarned" : false,"points" : [ {"total" : 15,"category" : "54d8064034282de652977c52","operation" : 0} ],"notifications" : [ {"event" : 0,"type" : 0,"scope" : 0,"content" : "{} completed {}"} ],"items" : [ ],"triggerURL" : "","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d809dc34282de65297822f"} ], "catalogs":[ {"catalog" : "Privilegies","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8070c34282de652977e3c"} ],"catalog_items":[ {"catalogId" : "54d8070c34282de652977e3c","name" : "Parking Place","description" : "Access to the private parking lot of the company for one month.","points" : [ {"total" : 100,"category" : "54d8064034282de652977c52","operation" : 0} ],"amount" : 100,"maxPerUser" : 10,"levelId" : "","active" : true,"real" : false,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"owned" : 0,"_id" : "54d8077c34282de652977e7f"}, {"catalogId" : "54d8070c34282de652977e3c","name" : "Home-Office","description" : "Being able to work a full day without leaving home.","points" : [ {"total" : 121,"category" : "54d8064034282de652977c52","operation" : 0} ],"amount" : 200,"maxPerUser" : 20,"levelId" : "","active" : true,"real" : false,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"owned" : 0,"_id" : "54d807e834282de652977efa"} ],"friends":[ {"name" : "Player Name","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"total_challenges" : 1,"challenges" : {"54d809dc34282de65297822f" : 1},"total_points" : 15,"point_categories" : {"54d8064034282de652977c52" : 15},"total_catalog_items" : 0,"catalog_items" : { },"level_progress" : {"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"},"percent_completed" : 1.5,"next_points" : 985,"next_level" : {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8069734282de652977cf0"},"total_levels" : 2,"percent" : 1.5},"challenge_progress" : [ ],"teams" : [ "54d806c134282de652977d65" ],"friends" : [ "player2@funifier.com" ],"positions" : [ ],"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"},"_id" : "player@funifier.com"} ]} -``` \ No newline at end of file diff --git a/api-rest.pdf b/api-rest.pdf deleted file mode 100644 index 0ddb10a..0000000 Binary files a/api-rest.pdf and /dev/null differ diff --git a/js/client/README.md b/js/client/README.md new file mode 100644 index 0000000..c524d83 --- /dev/null +++ b/js/client/README.md @@ -0,0 +1,364 @@ +## Usage + +###Configuração +Para usar o funifier em produção, insira a seguinte linha na tag head de todas as paginas que deseja habilitar: + + +```html + +``` + + +### Iniciação Async mode +Para iniciar o funifier de maneira assincrona, insira uma função antes do script do funifier: + +```javascript +window.funifierAsyncInit = function(){ + Funifier.init({ + apiKey : 'SUA API KEY' + }); +}; +``` + +Dessa maneira, assim que o funifier tiver sido processado, irá chamar a função 'funifierAsyncInit' caso exista. + +### Iniciação Sync mode + +Você pode inicializar também o funifier a qualquer momento após o carregamento do script do funifier chamando seu método de inicio: +```javascript + Funifier.init({ + apiKey : 'SUA API KEY' + }); +``` + +#Documentação + +##Componentes +O funifier tem algumas bibliotecas integradas, que pode ser usado em seus widgets/integrações, note no entanto, que as que tem o prefixo '_' são de uso do core do Funifier e por isso não tem garantia de estar presente numa versão futura. + +Funifier contêm os seguintes componentes: + +- [jquery](https://jquery.com/): `Funifier._$` 1.11.1 +- [async](https://github.com/caolan/async): `Funifier._async` +- [lodash](https://lodash.com/): `Funifier._` +- [validator](https://github.com/chriso/validator.js): `Funifier._validator` +- [mustache](https://github.com/janl/mustache.js/): `Funifier._mustache` +- [headjs](http://headjs.com/): `Funifier.headjs` +- [magnificPopup](http://dimsemenov.com/plugins/magnific-popup/): `Funifier._$.magnificPopup` +- [qs](https://github.com/hapijs/qs): `Funifier._qs` + +Para a documentação dos componentes acima, verifique no site do respectivo componente. + +### Métodos +* [`init`](#init) +* [`listen`](#listen) +* [`unlisten`](#unlisten) +* [`api`](#api) +* [`track`](#track) +* [`auth`](#auth) + * [`authenticate`](#authenticate) + * [`isAuthenticate`](#isAuthenticate) + * [`logout`](#logout) + + +--------------------------------------- +### init(config, callback) + +Utilizado para iniciar a api do funifier. +Recebe como parâmetro um objeto e um callback. + +__config__ +* `apiKey` : String - Apikey configurada no studio. +* `hideInline` : Boolean - Define a exibição do modo inline para admin. __default__ : false +* `showNotification`: Boolean - Exibir/ocultar as notificações. __default__ : true +* `disableCustomCss` : Boolean - Define se o funifier ira carregar o css dos widgets. __default__ : custom-{api_key}-v{version}.css. +* `disableCustomJs`: Boolean - Define se o funifier ira carregar o js com as funções de widgets. __default__ : custom-{api_key}-v{version}.js. +* `url` + * `service` : String - Url do service. __default__ : '//service2.funifier.com/2.0.0/' + * `client` : String - Url do client. __default__ : '//client2.funifier.com/2.0.0' + * `studio` : String - Url do studio. __default__ : '//studio2.funifier.com' + * `css` : String - Caminho de css para sobrescrever o padrão. __default__ : null + * `js` : String - Caminho do js para sobrescrever o padrão. __default__ : null + +__callback__ + +Recebe uma função que é executada assim que o funifier terminou de inicializar os objetos para a apiKey informada, sendo, que ja carregou todas as dependencias, scripts e styles. + +Parâmetros: +* `err` Recebe um erro caso tenha um + +__Exemplo__ + +```js +Funifier.init({ + apiKey : 'SUA API KEY', + hideInline: false, + url : { + css : 'http://www.meudominio.com/custom-css-replace.css' + } +},function(err){ + if(err){ + console.log('Ocorreu um erro'); + } +}); +``` + +--------------------------------------- +### listen(name, callback) +Monitora um evento do funifier +* `name` : String - Nome do evento a ser monitorado +* `callback` : Function - Função a ser executada. + +--------------------------------------- +### unlisten(name) +Para remover eventos do funifier monitorados pelo listen. +* `name` : String - Nome do evento a excluir o listen. +* +--------------------------------------- +### api(endpoint,params,callback) +Método para comunicação com o service. + +* `endpoint` : String - Metodo a ser requisitado no service. +* `params` : Object - Parâmetros a ser enviado para o service. +* `callback` : Function - retorno + +__Exemplos__ + +```js +Funifier.api('get_leaderboard', + {sort: 1, limit: 10, view: 0, group : 1}, + function(err,data){ + if(err==null){ + alert('Lista de leaderboards recebida') + console.log(data); + }else{ + alert('Ocorreu um erro :(') + } + } +); +``` + +```js +Funifier.api('get_widget_data', + null, + function(err,data){ + if(err==null){ + alert('Retorno recebido') + console.log(data); + }else{ + alert('Ocorreu um erro :(') + } + } +); +``` + +--------------------------------------- +### api(endpoint,params,options,callback) +Método para comunicação com o service. + +* `endpoint` : String - Metodo a ser requisitado no service. +* `params` : Object - Parâmetros a ser enviado para o service. +* `options` : Object - Parâmetros adicionais. +* `callback` : Function - retorno + +__Exemplos__ + +```js +Funifier.api('get_leaderboard', + {sort: 1, limit: 10, view: 0, group : 1}, + {type:'GET',contentType:'application/json'}, + function(err,data){ + if(err==null){ + alert('Lista de leaderboards recebida') + console.log(data); + }else{ + alert('Ocorreu um erro :(') + } + } +); +``` + + +--------------------------------------- +### track(options,callback) +Traqueia uma ação + +__options__ +* `action` : String - Id ou nome da action. +* `attributes` : Array - lista de atributos, opicional. + +__callback__ + +Função executada apos o track. +* `err` - Recebe um erro ou nulo. +* `data` - Response do servidor. + +__Exemplo__ + +```js +Funifier.track({ + action: 'visitarPagina' +},function(err,data){ + if(err==null){ + alert('Action traqueada') + } +}); +``` + +--------------------------------------- +### auth +####authenticate(options,callback) +Função usada para autenticar jogadores. + +__options__ +* `auth_mode` : String - Tipo de autenticação, valores disponiveis. + * facebook + * google + * IMPLICIT + * PASSWORD +* `player` : String - Id do jogador, requerido para auth_mode 'IMPLICIT' e 'PASSWORD'. (String) +* `password` : String - Senha do jogador, requerido para auth_mode 'PASSWORD' +* `modal` : Boolean - Define se a autenticação via google ou facebook sera feita atraves de um popup, (opcional usado apenas para auth_mode 'google' e 'facebook') + +__callback__ + +Função que de retorno. (Não é executada caso o auth_mode for facebook ou google e modal for igual a false ) +* `err` - Recebe um erro ou nulo. +* `data` - Response do servidor: + +__Exemplo Facebook__ + +```js +Funifier.auth.authenticate({ + auth_mode: 'facebook', + modal: true +},function(err,data){ + if(err==null){ + alert('Seja bem vindo') + } +}); +``` + +__Exemplo via Senha__ + +```js +Funifier.auth.authenticate({ + auth_mode: 'PASSWORD', + player: 'jogador1' + password: 'pass@123' +},function(err,data){ + if(err==null){ + alert('Seja bem vindo') + } +}); +``` + +####isAuthenticate(callback) + +Verifica se o jogador está autenticado. + +__callback__ + * `isAuthenticate` :Bollean + +__Exemplo__ + +```js +Funifier.auth.isAuthenticate(function(_isAuthenticate){ + if(isAuthenticate){ + alert('Seja bem vindo, você está autenticado'); + }else{ + alert('Desculpe, faça login, você não está autenticado'); + } +}); +``` + +####logout(callback) + +Efetua logout do jogador. + +__callback__ + * `err` + * `data` + +__Exemplo__ + +```js +Funifier.auth.logout(function(err){ + if(err==null){ + alert('Jogador deslogado com sucesso'); + }else{ + alert('Ocorreu um erro'); + } +}); +``` + + + +## Widget + +A estrutura basica de um widget: +```javascript +var ct = '
Hello World!
' +render(ct,function(config){ + var elemento = config.element; + elemento.find('a').click(function(){ + alert('Você clicou no link'); + }); +}); +``` + +O método render recebe uma string ou um objeto jquery e um metodo de retorno onde pode-se incluir eventos. + +Dentro do script você tem acesso a variável 'json' ,'theme_html', '$' e 'jQuery'. +O jquery disponível no widget é um jquery do objeto Funifier, caso queira acessar o jquery da pagina, use window.$ ou window.jQuery. + +A variável json está disponivel em alguns tipos de widgets. + + +Você pode usar o mustache para renderizar seu html. + +```javascript +Funifier.auth.isAuthenticate(function(isAuthenticate) { + json.isAuthenticate = isAuthenticate; + var str = Mustache.render(theme_html,json); + render(str,function(config){ + var el = config.element; + //your code + }); +}); +``` +Você pode requisitar um recurso no servidor antes de renderizar. + +```javascript +Funifier.auth.isAuthenticate(function(isAuthenticate) { + Funifier.api('get_widget_data', {include_challenges: true}, function(err,json){ + json.isAuthenticate = isAuthenticate; + var str = Mustache.render(theme_html,json); + render(str,function(config){ + var el = config.element; + //your code + }); + }); +}); +``` + +## Debug + +Por padrão o Funifier Client não exibe qualquer informação de error/info no console sendo necessário habilitar. +Para habilitar todas as mensagens do funifier, abra o console javascript e digite: + +```javascript + Funifier.debug.enable('*'); +``` + +Você pode habilitar o log para mensagens específicas: +```javascript + Funifier.debug.enable('Funifier:social:*'); +``` +```javascript + Funifier.debug.enable('Funifier:core:*'); +``` +Caso queira desabilitar as mensagens: +```javascript +Funifier.debug.disable(); +``` \ No newline at end of file diff --git a/rest/Readme.md b/rest/Readme.md new file mode 100644 index 0000000..61e2f29 --- /dev/null +++ b/rest/Readme.md @@ -0,0 +1,117 @@ +# Authenticate + +This method authenticate a player to your gamification and opens a session for the authenticated player on success. Authentication against the Funifier API is done with your gamification's API key, Authentication Mode and some combinations of credentials. + +GET Method + +```sh +http[s]://service2.funifier.com/2.0.0/authenticate +``` + +**Parameters** . + + - api_key: **String/Required** - Field that identify the key of gamification + - auth_mode: **String/Required** - Identify which method of authentication will use. The values can be [IMPLICIT,PASSWORD,CREDENTIAL,FACEBOOK] + - oauth_access_token: **String/Optional** - Use this field when the auth_mode is FACEBOOK. This value is the Facbook Token + - player: **String/Required** - Identify the Player of gamification + - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security + - password: **String/Optional** - Use this field when the auth_mode authentication is PASSWORD + - expiration: **int/Optional** - Used to define expirations time in seconds of sessions + - language: **int/Optional** - Set the default language in authentication + - callback: **String/Optional** - Use to callbacks in javascript + +### Example Request +```sh +https://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=IMPLICIT&player=player@funifier.com +``` +```sh +https://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=PASSWORD&player=player@funifier.com&password=123 +``` +```sh +mhttps://service2.funifier.com/2.0.0/authenticate?api_key=556df789108d44a65c389583&auth_mode=CREDENTIAL&player=player@funifer.com&app_secret=54d80b7f34282de652978326 +``` + +### Example Response Sucess + +```sh +{"access_token" : "54d80a14e4b0e8d184586a1c"} +``` +### Example Response Error +``` +{"message" : "player player@funifier.com does not exist, ask your administrator to create it in studio2.funifier.com","code" : 401,"type" : "Unauthorized"} +``` + +# Track + +This method send actions performed by players to Funifier. Requires you to call this method whenever the action occurs, and pass the action name, and all the metadata you care about. + +POST Method + +```sh +http[s]://service2.funifier.com/2.0.0/track +``` + + - api_key: **String/Required** - Field that identify the key of gamification + - access_token: **String/Required** - This field authorize the player to request this method, This value can be obtain by method Authenticate + - player: **String/Required** - Identify the Player of gamification + - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security + - action: **String/Required** - This field identifies the action that will be registered + - attributes: **String/Optional** - In This field can be past the objects of action. It is a Json Object. e.g. {"attribute1":"value1", "attribute2":"value2"} + - timestamp: **long/Optional** - This field is used to define a date. The type is a long + - callback: **String/Optional** - Use to callbacks in javascript + +### Example Request + +```sh +https://service2.funifier.com/2.0.0/track?api_key=556df789108d44a65c389583&action=sell&attributes={"product":"book","price":12.5}&access_token=54d8139ae4b0e8d184586a1f +``` +```sh +https://service2.funifier.com/2.0.0/track?api_key=556df789108d44a65c389583&action=sell&attributes={"product":"book","price":12.5}&player=player@funifier.com&app_secret=54d80b7f34282de652978326 +``` +### Example Response Sucess +```sh +{"message" : "action tracked","code" : 200,"type" : "OK"} +``` +### Example Response Error +``` +{"message" : "action sell does not exist","code" : 400, "type" : "Bad Request"} +``` + +# Widget Data + +This method retrieves information about players, win-states, incentives and other objects inside the gamification. Use this to show to visually engage the players with their status and other infos. + +GET Method +```sh +http[s]://service2.funifier.com/2.0.0/get_widget_data +``` +## Parameters + + + - api_key: **String/Required** - Field that identify the key of gamification + - oauth_access_token: **String/Optional** - Use this field when the auth_mode is FACEBOOK. This value is the Facbook Token + - player: **String/Required** - Identify the Player of gamification + - app_secret: **String/Optional** - Token security, create this app_secret value in funfier studio on menu security + - include_teams: **boolean/Optional** - If value is true, the list of teams will be loaded + - include_levels: **boolean/Optional** - If value is true, the list of levels will be loaded + - include_challenges: **boolean/Optional** If value is true, the list of challenges will be loaded + - include_catalogs: **boolean/Optional** - If value is true, the list of catalogs will be loaded + - include_leaderboards: **boolean/Optional** - If value is true, the list of leaderboards will be loaded + - include_friends: **boolean/Optional** - If value is true, the list of friends will be loaded + - include_actions: **boolean/Optional** - If value is true, the list of actions will be loaded + - include_points: **boolean/Optional** - If value is true, the list of points will be loaded + - language: **int/Optional** - Set the default language in authentication + - callback: **String/Optional** - Use to callbacks in javascript + +# Example Response +```sh + https://service2.funifier.com/2.0.0/get_widget_data?api_key=556df789108d44a65c389583&access_token=54d8139ae4b0e8d184586a1f&include_challenges=true +``` + +```sh + https://service2.funifier.com/2.0.0/get_widget_data?api_key=556df789108d44a65c389583&player=ricardo@funifier.com&app_secret=54d80b7f34282de652978326&include_challenges=true +``` +## Example Response +```sh +{"player":{"name" : "Player Name","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"total_challenges" : 2,"challenges" : {"54d8098034282de65297817a" : 1,"54d809dc34282de65297822f" : 1},"total_points" : 25,"point_categories" : {"54d8064034282de652977c52" : 25},"total_catalog_items" : 1,"catalog_items" : {"54d8077c34282de652977e7f" : 1},"level_progress" : {"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8067e34282de652977cb6"},"percent_completed" : 2.5,"next_points" : 975,"next_level" : {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8069734282de652977cf0"},"total_levels" : 2,"percent" : 2.5},"challenge_progress" : [ ],"teams" : [ "54d806c134282de652977d65", "54d806d534282de652977d9e", "54d806e934282de652977df8" ],"friends" : [ "player@funifier.com" ],"positions" : [ ],"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"notifications" : null,"requirements" : null,"_id" : "54d8067e34282de652977cb6"},"_id" : "player@funifier.com"},"teams":[ {"name" : "Brazil","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806c134282de652977d65"}, {"name" : "Canada","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806d534282de652977d9e"}, {"name" : "Mexico","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d806e934282de652977df8"} ],"levels":[ {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"}, {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8069734282de652977cf0"} ],"challenges":[ {"challenge" : "Big Sales Hero","description" : "You are a sales hero for closing a big opportunity of $100.000. enjoy this reward as you have earned the right to be recognized as a \"big sales hero\". PS. enjoy the commission cheque!","range" : 0,"active" : true,"rules" : [ {"actionId" : "54d8088c34282de652978027","position" : 1,"operator" : 5,"total" : 0,"timeAmount" : 0,"timeScale" : 0,"outOfTime" : false,"everyAmount" : 0,"everyScale" : 0,"filters" : [ {"value" : "100000","operator" : 5,"param" : "price"} ],"_id" : "54d8098034282de652978179"} ],"triggerUrl" : "","teamChallenge" : false,"limitTotal" : 1,"limitPerType" : 0,"limitTimeAmount" : 1,"limitTimeScale" : 5,"badge" : {"medium" : {"url" : "http://funifier.com/image.png"}},"hideUntilEarned" : false,"points" : [ {"total" : 10,"category" : "54d8064034282de652977c52","operation" : 0} ],"notifications" : [ {"event" : 0,"type" : 0,"scope" : 0,"content" : "{} completed {}"} ],"items" : [ "54d8077c34282de652977e7f" ],"tags" : [ ],"triggerURL" : "","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8098034282de65297817a"}, {"challenge" : "Lead Start","description" : "Register your first lead in the system to earn this badge. Use the system well is a good way to start your sales career and earn 5 experiences points.","range" : 0,"active" : true,"rules" : [ {"actionId" : "54d808a634282de65297805f","position" : 1,"operator" : 5,"total" : 0,"timeAmount" : 0,"timeScale" : 0,"outOfTime" : false,"everyAmount" : 0,"everyScale" : 0,"filters" : [ ],"_id" : "54d809dc34282de65297822e"} ],"triggerUrl" : "","teamChallenge" : false,"limitTotal" : 1,"limitPerType" : 0,"limitTimeAmount" : 0,"limitTimeScale" : 0,"badge" : {"medium" : {"url" : "http://funifier.com/image.png"}},"principals" : [ ],"hideUntilEarned" : false,"points" : [ {"total" : 15,"category" : "54d8064034282de652977c52","operation" : 0} ],"notifications" : [ {"event" : 0,"type" : 0,"scope" : 0,"content" : "{} completed {}"} ],"items" : [ ],"triggerURL" : "","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d809dc34282de65297822f"} ], "catalogs":[ {"catalog" : "Privilegies","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8070c34282de652977e3c"} ],"catalog_items":[ {"catalogId" : "54d8070c34282de652977e3c","name" : "Parking Place","description" : "Access to the private parking lot of the company for one month.","points" : [ {"total" : 100,"category" : "54d8064034282de652977c52","operation" : 0} ],"amount" : 100,"maxPerUser" : 10,"levelId" : "","active" : true,"real" : false,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"owned" : 0,"_id" : "54d8077c34282de652977e7f"}, {"catalogId" : "54d8070c34282de652977e3c","name" : "Home-Office","description" : "Being able to work a full day without leaving home.","points" : [ {"total" : 121,"category" : "54d8064034282de652977c52","operation" : 0} ],"amount" : 200,"maxPerUser" : 20,"levelId" : "","active" : true,"real" : false,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"owned" : 0,"_id" : "54d807e834282de652977efa"} ],"friends":[ {"name" : "Player Name","image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"total_challenges" : 1,"challenges" : {"54d809dc34282de65297822f" : 1},"total_points" : 15,"point_categories" : {"54d8064034282de652977c52" : 15},"total_catalog_items" : 0,"catalog_items" : { },"level_progress" : {"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"},"percent_completed" : 1.5,"next_points" : 985,"next_level" : {"level" : "Advanced","position" : 1,"description" : "Advanced level description","minPoints" : 1000,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8069734282de652977cf0"},"total_levels" : 2,"percent" : 1.5},"challenge_progress" : [ ],"teams" : [ "54d806c134282de652977d65" ],"friends" : [ "player2@funifier.com" ],"positions" : [ ],"level" : {"level" : "Rookie","position" : 0,"description" : "Rookie level description","minPoints" : 10,"image" : {"medium" : {"url" : "http://funifier.com/image.png"}},"_id" : "54d8067e34282de652977cb6"},"_id" : "player@funifier.com"} ]} +``` \ No newline at end of file diff --git a/rest/Readme.pdf b/rest/Readme.pdf new file mode 100644 index 0000000..0ddb10a Binary files /dev/null and b/rest/Readme.pdf differ -- libgit2 0.22.2