Created
August 23, 2016 03:31
-
-
Save gpincheiraa/d267d82dba92a042ea970d5f8067d00d to your computer and use it in GitHub Desktop.
Draw for loopback model es6 defiition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from 'request-promise'; | |
var token = process.env.SBIF_TOKEN_URL, | |
api_url = process.env.SBIF_API_URL; | |
class SbifApi{ | |
constructor(SbifModel){ | |
//map remote methods to class methods. Set an extra this using the .bind function | |
SbifModel.uf = this.getData.bind(SbifModel, 'uf'); | |
SbifModel.utm = this.getData.bind(SbifModel, 'utm'); | |
SbifModel.ipc = this.getData.bind(SbifModel, 'ipc'); | |
SbifModel.dolar = this.getData.bind(SbifModel, 'dolar'); | |
SbifModel.euro = this.getData.bind(SbifModel, 'euro'); | |
//Set remotes | |
this.setRemotes(SbifModel, {name: 'uf', path: '/uf', root: 'uf'}); | |
this.setRemotes(SbifModel, {name: 'utm', path: '/utm', root: 'utm'}); | |
this.setRemotes(SbifModel, {name: 'ipc', path: '/ipc', root: 'ipc'}); | |
this.setRemotes(SbifModel, {name: 'dolar', path: '/dolar', root: 'dolar'}); | |
this.setRemotes(SbifModel, {name: 'euro', path: '/euro', root: 'euro'}); | |
return SbifModel; | |
} | |
setRemotes(model, remoteMethod){ | |
} | |
} | |
} | |
module.exports = (Model) => { new SbifApi(Model) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment