Best JavaScript code snippet using cucumber-gherkin
DMSvc.js
Source:DMSvc.js
...31 //32 /////////////////////////////////////////////////////////////////33 async getHubs (getToken, opts = {}) {34 const token = (typeof getToken == 'function')35 ? await getToken()36 : getToken37 return this._hubsAPI.getHubs (38 opts, {autoRefresh:false}, token)39 }40 /////////////////////////////////////////////////////////////////41 // Returns list of Hubs42 //43 /////////////////////////////////////////////////////////////////44 async getHub (getToken, hubId) {45 const token = (typeof getToken == 'function')46 ? await getToken()47 : getToken48 return this._hubsAPI.getHub (49 hubId, {autoRefresh:false}, token)50 }51 /////////////////////////////////////////////////////////////////52 // Returns list of Projects for specific Hub53 //54 /////////////////////////////////////////////////////////////////55 async getProjects (getToken, hubId, opts = {}) {56 const token = (typeof getToken == 'function')57 ? await getToken()58 : getToken59 return this._projectsAPI.getHubProjects (60 hubId, opts, {autoRefresh:false}, token)61 }62 /////////////////////////////////////////////////////////////////63 // Returns Project content64 //65 /////////////////////////////////////////////////////////////////66 async getProject (getToken, hubId, projectId) {67 const token = (typeof getToken == 'function')68 ? await getToken()69 : getToken70 return this._projectsAPI.getProject(71 hubId, projectId, {autoRefresh:false}, token)72 }73 /////////////////////////////////////////////////////////////////74 // Returns Project Top Folders75 // If the user has access to the projectâs root folder,76 // it only returns details of the root folder.77 // If the user does not have access to the root folder,78 // it returns details of all the highest level folders in79 // the folder hierarchy the user has access to.80 //81 /////////////////////////////////////////////////////////////////82 async getProjectTopFolders (getToken, hubId, projectId) {83 const token = (typeof getToken == 'function')84 ? await getToken()85 : getToken86 return this._projectsAPI.getProjectTopFolders(87 hubId, projectId, {autoRefresh:false}, token)88 }89 /////////////////////////////////////////////////////////////////90 // Returns Folder91 //92 /////////////////////////////////////////////////////////////////93 async getFolder (getToken, projectId, folderId) {94 const token = (typeof getToken == 'function')95 ? await getToken()96 : getToken97 return this._foldersAPI.getFolder(98 projectId, folderId, {autoRefresh:false}, token)99 }100 /////////////////////////////////////////////////////////////////101 // Returns Folder content102 //103 /////////////////////////////////////////////////////////////////104 async getFolderContent (getToken, projectId, folderId, opts = {}) {105 const token = (typeof getToken == 'function')106 ? await getToken()107 : getToken108 return this._foldersAPI.getFolderContents(109 projectId, folderId, opts, {autoRefresh:false}, token)110 }111 /////////////////////////////////////////////////////////////////112 // Returns Item details113 //114 /////////////////////////////////////////////////////////////////115 async getItem (getToken, projectId, itemId) {116 const token = (typeof getToken == 'function')117 ? await getToken()118 : getToken119 return this._itemsAPI.getItem(120 projectId, itemId, {autoRefresh:false}, token)121 }122 /////////////////////////////////////////////////////////////////123 // Returns Item tip version (most recent)124 //125 /////////////////////////////////////////////////////////////////126 async getItemTip (getToken, projectId, itemId) {127 const token = (typeof getToken == 'function')128 ? await getToken()129 : getToken130 return this._itemsAPI.getItemTip(131 projectId, itemId, {autoRefresh:false}, token)132 }133 /////////////////////////////////////////////////////////////////134 // Returns Versions for specific Item135 //136 /////////////////////////////////////////////////////////////////137 async getItemVersions (getToken, projectId, itemId, opts = {}) {138 const token = (typeof getToken == 'function')139 ? await getToken()140 : getToken141 return this._itemsAPI.getItemVersions(142 projectId, itemId, opts, {autoRefresh:false}, token)143 }144 /////////////////////////////////////////////////////////////////145 // Delete Item146 //147 /////////////////////////////////////////////////////////////////148 async deleteItem (getToken, projectId, itemId, opts = {}) {149 return new Promise(async(resolve, reject) => {150 try {151 const token = (typeof getToken == 'function')152 ? await getToken()153 : getToken154 const versionsRes = await this._itemsAPI.getItemVersions(155 projectId, itemId, opts, {autoRefresh:false}, token)156 const deleteTasks = versionsRes.body.data.map((version) => {157 return this.deleteVersion(158 token, projectId, version.id)159 })160 return Promise.all(deleteTasks)161 } catch (ex) {162 console.log(ex)163 reject (ex)164 }165 })166 }167 /////////////////////////////////////////////////////////////////168 // Returns Version for specific versionId169 //170 /////////////////////////////////////////////////////////////////171 async getVersion (getToken, projectId, versionId) {172 const token = (typeof getToken == 'function')173 ? await getToken()174 : getToken175 return this._versionsAPI.getVersion(176 projectId, versionId, {autoRefresh:false}, token)177 }178 /////////////////////////////////////////////////////////////////179 // Delete Version180 //181 /////////////////////////////////////////////////////////////////182 async deleteVersion (getToken, projectId, versionId) {183 try {184 const token = (typeof getToken == 'function')185 ? await getToken()186 : getToken187 const versionsRes =188 await this._versionsAPI.getVersion(189 projectId, versionId,190 {autoRefresh:false}, token)191 const payload = this.createDeleteVersionPayload(192 versionsRes.body.data.relationships.item.data.id)193 //return this._versionsAPI.postVersion(194 // projectId, JSON.stringify(payload),195 // {autoRefresh:false}, token)196 const url =197 `${DMSvc.SERVICE_BASE_URL}/projects/` +198 `${projectId}/versions`199 const headers = {200 'Content-Type': 'application/vnd.api+json',201 'Authorization': 'Bearer ' + token.access_token202 }203 return requestAsync({204 method: 'POST',205 body: payload,206 json: true,207 headers,208 url209 })210 } catch (ex) {211 Promise.reject (ex)212 }213 }214 /////////////////////////////////////////////////////////////////215 // Creates new Storage location on OSS for DM216 //217 /////////////////////////////////////////////////////////////////218 async createStorage (getToken, projectId, folderId, filename) {219 const token = (typeof getToken == 'function')220 ? await getToken()221 : getToken222 const payload = this.createStoragePayload (223 folderId, filename)224 //return this._projectsAPI.postStorage(225 // projectId, JSON.stringify(payload),226 // {autoRefresh:false}, token)227 const url =228 `${DMSvc.SERVICE_BASE_URL}/projects/` +229 `${projectId}/storage`230 const headers = {231 'Content-Type': 'application/vnd.api+json',232 'Authorization': 'Bearer ' + token.access_token233 }234 return requestAsync({235 method: 'POST',236 body: payload,237 json: true,238 headers,239 url240 })241 }242 /////////////////////////////////////////////////////////////////243 // Creates new Item244 //245 /////////////////////////////////////////////////////////////////246 async createItem (247 getToken, projectId, folderId, objectId,248 displayName, isBIM = false) {249 const token = (typeof getToken == 'function')250 ? await getToken()251 : getToken252 const payload = this.createItemPayload(253 folderId, objectId, displayName, isBIM)254 //return this._itemsAPI.postItem(255 // projectId, JSON.stringify(payload),256 // {autoRefresh:false}, token)257 const url =258 `${DMSvc.SERVICE_BASE_URL}/projects/` +259 `${projectId}/items`260 const headers = {261 'Content-Type': 'application/vnd.api+json',262 'Authorization': 'Bearer ' + token.access_token263 }264 return requestAsync({265 method: 'POST',266 body: payload,267 json: true,268 headers,269 url270 })271 }272 /////////////////////////////////////////////////////////////////273 // Creates new Version274 //275 /////////////////////////////////////////////////////////////////276 async createVersion (getToken,277 projectId, itemId, objectId, displayName, isBIM) {278 const token = (typeof getToken == 'function')279 ? await getToken()280 : getToken281 const payload = this.createVersionPayload(282 itemId, objectId, displayName, isBIM)283 //return this._versionsAPI.postVersion(284 // projectId, JSON.stringify(payload),285 // {autoRefresh:false}, token)286 const url =287 `${DMSvc.SERVICE_BASE_URL}/projects/` +288 `${projectId}/versions`289 const headers = {290 'Content-Type': 'application/vnd.api+json',291 'Authorization': 'Bearer ' + token.access_token292 }293 return requestAsync({294 method: 'POST',295 body: payload,296 json: true,297 headers,298 url299 })300 }301 /////////////////////////////////////////////////////////////////302 // Get Item relationship References303 //304 /////////////////////////////////////////////////////////////////305 async getItemRelationshipsRefs (306 getToken, projectId, itemId, opts = {}) {307 const token = (typeof getToken == 'function')308 ? await getToken()309 : getToken310 return this._itemsAPI.getItemRelationshipsRefs(311 projectId, itemId, opts,312 {autoRefresh:false}, token)313 }314 /////////////////////////////////////////////////////////////////315 // Create Item relationship reference316 //317 /////////////////////////////////////////////////////////////////318 async createItemRelationshipRef (319 getToken, projectId, targetItemId, refVersionId) {320 const token = (typeof getToken == 'function')321 ? await getToken()322 : getToken323 const payload = this.createItemRelationshipRefPayload(324 refVersionId)325 //return this._itemsAPI.postItemRelationshipsRef(326 // projectId, targetItemId, JSON.stringify(payload),327 // {autoRefresh:false}, token)328 const url =329 `${DMSvc.SERVICE_BASE_URL}/projects/` +330 `${projectId}/items/${targetItemId}/` +331 `relationships/refs`332 const headers = {333 'Content-Type': 'application/vnd.api+json',334 'Authorization': 'Bearer ' + token.access_token335 }336 return requestAsync({337 method: 'POST',338 body: payload,339 json: true,340 headers,341 url342 })343 }344 /////////////////////////////////////////////////////////////////345 // Get Version relationship references346 //347 /////////////////////////////////////////////////////////////////348 async getVersionRelationshipsRefs (349 getToken, projectId, versionId, opts = {}) {350 const token = (typeof getToken == 'function')351 ? await getToken()352 : getToken353 return this._versionsAPI.getVersionRelationshipsRefs(354 projectId, versionId, opts,355 {autoRefresh:false}, token)356 }357 /////////////////////////////////////////////////////////////////358 // Create Version relationship reference359 //360 /////////////////////////////////////////////////////////////////361 async createVersionRelationshipRef (362 getToken, projectId, targetVersionId, refVersionId) {363 const token = (typeof getToken == 'function')364 ? await getToken()365 : getToken366 const payload = this.createVersionRelationshipRefPayload(367 refVersionId)368 //return this._versionsAPI.postVersionRelationshipsRef(369 // projectId, targetVersionId, JSON.stringify(payload),370 // {autoRefresh:false}, token)371 const url =372 `${DMSvc.SERVICE_BASE_URL}/projects/` +373 `${projectId}/versions/${targetVersionId}/` +374 `relationships/refs`375 const headers = {376 'Content-Type': 'application/vnd.api+json',377 'Authorization': 'Bearer ' + token.access_token378 }379 return requestAsync({380 method: 'POST',381 body: payload,382 json: true,383 headers,384 url385 })386 }387 /////////////////////////////////////////////////////////////////388 // Create new folder389 //390 /////////////////////////////////////////////////////////////////391 async createFolder (392 getToken, projectId, parentFolderId, folderName) {393 const token = (typeof getToken == 'function')394 ? await getToken()395 : getToken396 const url =397 `${DMSvc.SERVICE_BASE_URL}/projects/` +398 `${projectId}/folders`399 const payload = this.createFolderPayload(400 parentFolderId,401 folderName)402 const headers = {403 'Content-Type': 'application/vnd.api+json',404 'Authorization': 'Bearer ' + token.access_token405 }406 return requestAsync({407 method: 'POST',408 body: payload,409 json: true,410 headers,411 url412 })413 }414 /////////////////////////////////////////////////////////////////415 // Search folder416 //417 /////////////////////////////////////////////////////////////////418 async searchFolder (getToken, projectId, folderId, filter) {419 const token = (typeof getToken == 'function')420 ? await getToken()421 : getToken422 const url =423 `${DMSvc.SERVICE_BASE_URL}/projects/` +424 `${projectId}/folders/${folderId}/search?` +425 filter426 const headers = {427 'Authorization': 'Bearer ' + token.access_token428 }429 return requestAsync({430 method: 'GET',431 json: true,432 headers,433 url434 })435 }436 /////////////////////////////////////////////////////////437 // Upload file and create new item or new version438 //439 /////////////////////////////////////////////////////////440 upload (getToken, projectId, folderId, file, opts) {441 return new Promise(async(resolve, reject) => {442 try {443 const displayName = file.originalname444 const storageRes = await this.createStorage(445 getToken, projectId, folderId, displayName)446 const ossSvc = ServiceManager.getService(447 'OssSvc')448 const objectId = ossSvc.parseObjectId(449 storageRes.body.data.id)450 const dmOpts = Object.assign({}, opts, {451 onComplete: async(upload) => {452 try {453 // look for items with the same displayName454 const items =455 await this.findItemsWithAttributes(456 getToken,457 projectId,458 folderId, {459 displayName460 })461 if (items.length > 0) {462 const item = items[0]463 const versionRes = await this.createVersion(464 getToken, projectId, item.id,465 storageRes.body.data.id,466 displayName,467 opts.isBIM)468 const response = {469 version: versionRes.body.data,470 storage: versionRes.body.data,471 item: item,472 upload473 }474 opts.onComplete(response)475 } else {476 const itemRes = await this.createItem(477 getToken, projectId, folderId,478 storageRes.body.data.id,479 displayName,480 opts.isBIM)481 const versions = await this.getItemVersions(482 getToken, projectId, itemRes.body.data.id)483 const response = {484 version: versions.body.data[0],485 storage: storageRes.body.data,486 item: itemRes.body.data,487 upload488 }489 opts.onComplete(response)490 }491 } catch (ex) {492 opts.onError(ex)493 }494 }495 })496 const uploadRes =497 await ossSvc.uploadObjectChunked (498 getToken,499 objectId.bucketKey,500 objectId.objectKey,501 file, dmOpts)502 resolve(uploadRes)503 } catch (ex) {504 reject(ex)505 }506 })507 }508 /////////////////////////////////////////////////////////////////509 // Returns Items matching search criteria510 //511 /////////////////////////////////////////////////////////////////512 findItemsWithAttributes (513 getToken, projectId, folderId, attributes, recursive = false) {514 return new Promise(async(resolve, reject) => {515 try {516 const token = (typeof getToken == 'function')517 ? await getToken()518 : getToken519 const folderItems = await this.getFolderContent(520 token, projectId, folderId)521 const tasks = folderItems.body.data.map((folderItem) => {522 if (folderItem.type === 'items') {523 var match = true524 for (var key in attributes) {525 if(attributes[key] !== folderItem.attributes[key]){526 match = false527 }528 }529 if (match) {530 return Promise.resolve(folderItem)531 } else {...
Services.js
Source:Services.js
...21 //****Reservas22 'obtenerListadoReservas': function ( fInicio, status, srvPte) {23 return $http.get(_api + 'listadoReservas?fechaInicio='+fInicio+"&status="+status+"&serviciosPendientes="+srvPte,24 25 {"headers": {"Authorization" : "Bearer "+token.getToken()}}26 );27 },28 29 'obtenerListadoServiciosReserva': function ( idReserva, tipoSrv, tipoStatus) {30 var pIdReserva = idReserva? idReserva : ''; 31 return $http.get(_api + 'listadoServiciosReserva/'+pIdReserva+"?tipoServicio="+tipoSrv+"&status="+tipoStatus,32 33 {"headers": {"Authorization" : "Bearer "+token.getToken()}}34 );35 },36 'obtenerListadoObservacionesReserva': function ( idReserva) {37 return $http.get(_api + 'listadoObservacionesReserva/'+idReserva,38 39 {"headers": {"Authorization" : "Bearer "+token.getToken()}}40 );41 },42 43 'editarObservacionReserva': function (idCalendario, usuario, leido) {44 return $http.post(_api + 'observacionReserva',45 {46 "idCalendario": idCalendario,47 "usuario": usuario,48 "leido": leido,49 },50 {"headers": {"Authorization" : "Bearer "+token.getToken()}}51 );52 },53 'crearContacto': function ( idReserva, nombre, email, localizador) {54 return $http.put(_api + 'contacto',55 {56 57 "idReserva": idReserva,58 "nombre": nombre,59 "email": email,60 "localizador": localizador,61 },62 {"headers": {"Authorization" : "Bearer "+token.getToken()}}63 );64 },65 66 'editarEstadoServicio': function (idReserva, actStatus, textoCalendario, idReservaServicio, tipoCalendario, listIden) {67 return $http.post(_api + 'estadoServicio',68 {69 "idReserva": idReserva,70 "actStatus": actStatus,71 "textoCalendario": textoCalendario,72 73 "idReservaServicio": idReservaServicio,74 "tipoCalendario": tipoCalendario,75 "listIden": listIden,76 },77 {"headers": {"Authorization" : "Bearer "+token.getToken()}}78 );79 },80 81 'obtenerTiposCalendario': function (idGrupo) {82 return $http.get(_api + 'tiposCalendario/'+idGrupo,83 {"headers": {"Authorization" : "Bearer "+token.getToken()}}84 );85 },86 87 88 'obtenerInfoVuelo': function (idCiaAerea, numeroVuelo) {89 return $http.get(_api + 'infoVuelo',90 {91 "idCiaAerea": idCiaAerea,92 "numeroVuelo": numeroVuelo93 },94 {"headers": {"Authorization" : "Bearer "+token.getToken()}}95 );96 },97 'crearTrasladoPredeterminado': function ( idCiaAerea, numeroVuelo, fechaSalida, idCiudadSalida, idAeropuertoSalida, horaSalida, idCiudadLlegada, idAeropuertoLlegada, horaLlegada, horaRecogida, inOut, notas) {98 return $http.put(_api + 'trasladoPredeterminado',99 {100 101 "idCiaAerea": idCiaAerea,102 "numeroVuelo": numeroVuelo,103 "fechaSalida": fechaSalida,104 "idCiudadSalida": idCiudadSalida,105 "idAeropuertoSalida": idAeropuertoSalida,106 "horaSalida": horaSalida,107 "idCiudadLlegada": idCiudadLlegada,108 "idAeropuertoLlegada": idAeropuertoLlegada,109 "horaLlegada": horaLlegada,110 "horaRecogida": horaRecogida,111 "inOut": inOut,112 "notas": notas,113 114 },115 {"headers": {"Authorization" : "Bearer "+token.getToken()}}116 );117 },118 119 120 //****Hoteles121 122 'obtenerListadoHotelesAlternativos': function ( idReserva, idReservaServicio) {123 return $http.get(_api + 'listadoHotelesAlternativos?idReserva='+idReserva+"&idReservaServicio="+idReservaServicio,124 125 {"headers": {"Authorization" : "Bearer "+token.getToken()}}126 );127 },128 'editarHotelAlternativo': function (idReservaServicio, idHotel, idPrestatario) {129 return $http.post(_api + 'hotelAlternativo',130 {131 "idReservaServicio": idReservaServicio,132 "idHotel": idHotel,133 "idPrestatario": idPrestatario,134 },135 {"headers": {"Authorization" : "Bearer "+token.getToken()}}136 );137 },138 139 'obtenerListadoVuelosPredeterminados': function () {140 return $http.get(_api + 'listadoVuelosPredeterminados',141 {142 143 },144 {"headers": {"Authorization" : "Bearer "+token.getToken()}}145 );146 },147 'editarVueloPredeterminado': function (idReservaServicio, Traslados, fechaTkt, fechaEmision) {148 return $http.post(_api + 'VueloPredeterminado',149 {150 "idReservaServicio": idReservaServicio,151 "Traslados": Traslados,152 "fechaTkt": fechaTkt,153 "fechaEmision": fechaEmision,154 },155 {"headers": {"Authorization" : "Bearer "+token.getToken()}}156 );157 },158 //************************Traslados********************************159 'obtenerListadoTraslados': function () {160 161 return $http.get(_api + 'listadoTraslados',162 163 {"headers": {"Authorization" : "Bearer "+token.getToken()}}164 );165 },166 'obtenerDetalleTraslado': function (idTraslado, idReservaServicio) {167 var pIdTraslado = idTraslado? idTraslado : '';168 return $http.get(_api + 'traslado/'+pIdTraslado+"?idReservaServicio="+idReservaServicio,169 170 {"headers": {"Authorization" : "Bearer "+token.getToken()}}171 );172 },173 'editarTraslado': function (idGestionTrasladosPeticion, idReservaServicio, usuario, statusServicio, horaTrasladoDesde, horaTrasladoHasta) {174 return $http.post(_api + 'traslado',175 {176 "idGestionTrasladosPeticion": idGestionTrasladosPeticion,177 "idReservaServicio": idReservaServicio,178 "usuario": usuario,179 "statusServicio": statusServicio,180 "horaTrasladoDesde": horaTrasladoDesde,181 "horaTrasladoHasta": horaTrasladoHasta,182 },183 {"headers": {"Authorization" : "Bearer "+token.getToken()}}184 );185 },186 'verificarCoste': function (idGestionTrasladosPeticion, idReservaServicio, costeProveedor, usuario, observacionesCambio, moneda) {187 return $http.post(_api + 'verificarCoste',188 {189 "idGestionTrasladosPeticion": idGestionTrasladosPeticion,190 "idReservaServicio": idReservaServicio,191 "costeProveedor": costeProveedor,192 "usuario": usuario,193 "observacionesCambio": observacionesCambio,194 "moneda": moneda,195 },196 {"headers": {"Authorization" : "Bearer "+token.getToken()}}197 );198 },199 'editarCoste': function (idGestionTrasladosPeticion, idReservaServicio, costeProveedor, usuario, observaciones, moneda) {200 return $http.post(_api + 'coste',201 {202 "idGestionTrasladosPeticion": idGestionTrasladosPeticion,203 "idReservaServicio": idReservaServicio,204 "costeProveedor": costeProveedor,205 "usuario": usuario,206 "observaciones": observaciones,207 "moneda": moneda,208 },209 {"headers": {"Authorization" : "Bearer "+token.getToken()}}210 );211 },212 'editarTrasladoPickUp': function (idReserva, idReservaServicio, nuevaHora, usuario) {213 return $http.post(_api + 'trasladoPickUp',214 {215 "idReserva": idReserva,216 "idReservaServicio": idReservaServicio,217 "nuevaHora": nuevaHora,218 "usuario": usuario,219 },220 {"headers": {"Authorization" : "Bearer "+token.getToken()}}221 );222 },223 'validarEnviosProveedor': function (codigoValidacion) {224 return $http.post(_api + 'validarEnviosProveedor',225 {226 "codigoValidacion": codigoValidacion,227 },228 {"headers": {"Authorization" : "Bearer "+token.getToken()}}229 );230 },231 'editarServiciosNoShow': function (listServicio) {232 return $http.put(_api + 'serviciosNoShow',233 {234 "listServicio": listServicio,235 },236 {"headers": {"Authorization" : "Bearer "+token.getToken()}}237 );238 },239 //**********Servicios Expediente240 'obtenerListadoServiciosExpediente': function ( fechaDesde, fechaHasta) {241 return $http.get(_api + 'listadoServiciosExpediente?fechaDesde='+fechaDesde+"&fechaHasta="+fechaHasta,242 243 {"headers": {"Authorization" : "Bearer "+token.getToken()}}244 );245 },246 'confirmarServiciosExpediente': function (listIdentificadoresPlanilla, listIdentificadoresServicios, usuario) {247 return $http.post(_api + 'confirmarServiciosExpediente',248 {249 250 "listIdentificadoresPlanilla": listIdentificadoresPlanilla,251 "listIdentificadoresServicios": listIdentificadoresServicios,252 "usuario": usuario,253 },254 {"headers": {"Authorization" : "Bearer "+token.getToken()}}255 );256 },257 'cambiarPrestatarioServiciosExpediente': function (listIdentificadoresPlanilla, listIdentificadoresServicios, idPrestatario, usuario) {258 return $http.post(_api + 'cambiarPrestatarioServiciosExpediente',259 {260 261 "listIdentificadoresPlanilla": listIdentificadoresPlanilla,262 "listIdentificadoresServicios": listIdentificadoresServicios,263 "idPrestatario": idPrestatario,264 "usuario": usuario,265 },266 {"headers": {"Authorization" : "Bearer "+token.getToken()}}267 );268 },269 'obtenerCabeceraExpediente': function (idExpediente) {270 return $http.get(_api + 'cabeceraExpediente',271 {272 "idExpediente": idExpediente,273 },274 {"headers": {"Authorization" : "Bearer "+token.getToken()}}275 );276 },277 'obtenerRoomingListCabecera': function (idExpediente) {278 return $http.get(_api + 'roomingListCabecera',279 {280 281 "idExpediente": idExpediente,282 },283 {"headers": {"Authorization" : "Bearer "+token.getToken()}}284 );285 },286 'obtenerRoomingListExpediente': function (idExpediente, idPrestatario, fechaInicio, tipoServicio) {287 return $http.get(_api + 'roomingListExpediente?idExpediente='+idExpediente+"&idPrestatario="+idPrestatario+"&fechaInicio="+fechaInicio+"&tipoServicio="+tipoServicio,288 289 {"headers": {"Authorization" : "Bearer "+token.getToken()}}290 );291 },292 293 294 //*****Buses****295 'obtenerListadoBusesPendientesFacturar': function () {296 return $http.get(_api + 'listadoBusesPendientesFacturar',297 298 {"headers": {"Authorization" : "Bearer "+token.getToken()}}299 );300 },301 'obtieneImporteFacturaBus': function ( listIdentificadoresDetalle) {302 return $http.get(_api + 'importeFacturaBus',303 {304 305 "listIdentificadoresDetalle": listIdentificadoresDetalle,306 },307 {"headers": {"Authorization" : "Bearer "+token.getToken()}}308 );309 },310 'generarFacturaBuses': function ( listIdentificadoresDetalle, numeroFactura, fechaFactura) {311 return $http.post(_api + 'generarFacturaBuses',312 {313 314 "listIdentificadoresDetalle": listIdentificadoresDetalle,315 "numeroFactura": numeroFactura,316 "fechaFactura": fechaFactura,317 },318 {"headers": {"Authorization" : "Bearer "+token.getToken()}}319 );320 },321 'obtenerListadoFacturasBuses': function () {322 return $http.get(_api + 'listadoFacturasBuses',323 324 {"headers": {"Authorization" : "Bearer "+token.getToken()}}325 );326 },327 'eliminarFacturaBus': function ( idGestionBusesFacturasProveedores) {328 return $http.delete(_api + 'facturaBus',329 {330 331 "idGestionBusesFacturasProveedores": idGestionBusesFacturasProveedores,332 },333 {"headers": {"Authorization" : "Bearer "+token.getToken()}}334 );335 },336 //facturas337 'obtenerListadoServiciosPendienteFacturar': function () {338 return $http.get(_api + 'listadoServiciosPendienteFacturar',339 340 {"headers": {"Authorization" : "Bearer "+token.getToken()}}341 );342 },343 'obtenerRoomingListServicio': function (idReservaServicio) {344 return $http.get(_api + 'roomingListServicio',345 {346 "idReservaServicio": idReservaServicio,347 348 },349 {"headers": {"Authorization" : "Bearer "+token.getToken()}}350 );351 },352 353 'obtieneImporteFacturaServicios': function ( listaServicios, listaServiciosExtra) {354 return $http.post(_api + 'obtieneImporteFacturaServicios',355 {356 "listaServicios": listaServicios,357 "listaServiciosExtra": listaServiciosExtra,358 },359 {"headers": {"Authorization" : "Bearer "+token.getToken()}}360 );361 },362 'generarFacturaServicios': function ( listaServicios, listaServiciosExtra, numeroFactura, fechaFactura) {363 return $http.post(_api + 'generarFacturaServicios',364 {365 "listaServicios": listaServicios,366 "listaServiciosExtra": listaServiciosExtra,367 "numeroFactura": numeroFactura,368 "fechaFactura": fechaFactura,369 },370 {"headers": {"Authorization" : "Bearer "+token.getToken()}}371 );372 },373 'obtenerListadoFacturasServicios': function () {374 return $http.get(_api + 'listadoFacturasServicios',375 376 {"headers": {"Authorization" : "Bearer "+token.getToken()}}377 );378 },379 'eliminarFacturaServicios': function ( idGestionTrasladoFacturaProveedor) {380 return $http.post(_api + 'eliminarFacturaServicios',381 {382 "idGestionTrasladoFacturaProveedor": idGestionTrasladoFacturaProveedor,383 },384 {"headers": {"Authorization" : "Bearer "+token.getToken()}}385 );386 },387 //**************documents****388 'obtenerListadoDocumentos': function () {389 return $http.get(_api + 'listadoDocumentos',390 391 {"headers": {"Authorization" : "Bearer "+token.getToken()}}392 );393 },394 //**************head phones****395 'obtenerListadoHeadPhones': function () {396 return $http.get(_api + 'listadoHeadPhones',397 398 {"headers": {"Authorization" : "Bearer "+token.getToken()}}399 );400 },401 'confirmarHeadPhone': function ( idGestionHdph, observacionesProveedor) {402 return $http.post(_api + 'confirmarHeadPhone',403 {404 "idGestionHdph": idGestionHdph,405 "observacionesProveedor": observacionesProveedor,406 },407 {"headers": {"Authorization" : "Bearer "+token.getToken()}}408 );409 },410 'confirmarHeadPhoneMulti': function (listIdGestionHdph, observacionesProveedor) {411 return $http.post(_api + 'confirmarHeadPhoneMulti',412 {413 "listIdGestionHdph": listIdGestionHdph,414 "observacionesProveedor": observacionesProveedor,415 },416 {"headers": {"Authorization" : "Bearer "+token.getToken()}}417 );418 },419 'validarPrecioHeadPhone': function (idGestionHdph) {420 return $http.post(_api + 'validarPrecioHeadPhone',421 {422 "idGestionHdph": idGestionHdph,423 },424 {"headers": {"Authorization" : "Bearer "+token.getToken()}}425 );426 },427 'modificarPrecioHeadPhone': function (idGestionHdph, importePropuesto, observacionesProveedor) {428 return $http.post(_api + 'precioHeadPhone',429 {430 "idGestionHdph": idGestionHdph,431 "importePropuesto": importePropuesto,432 "observacionesProveedor": observacionesProveedor,433 },434 {"headers": {"Authorization" : "Bearer "+token.getToken()}}435 );436 },437 'obtenerListadoPendienteFacturarHeadPhones': function () {438 return $http.get(_api + 'listadoPendienteFacturarHeadPhones',439 440 {"headers": {"Authorization" : "Bearer "+token.getToken()}}441 );442 },443 'facturarHeadPhones': function (listIdentificadores, numeroFactura, fechaFactura) {444 return $http.post(_api + 'facturarHeadPhones',445 {446 "listIdentificadores": listIdentificadores,447 "numeroFactura": numeroFactura,448 "fechaFactura": fechaFactura,449 450 },451 {"headers": {"Authorization" : "Bearer "+token.getToken()}}452 );453 },454 'obtenerListadoFacturasHeadPhones': function () {455 return $http.get(_api + 'listadoFacturasHeadPhones',456 457 {"headers": {"Authorization" : "Bearer "+token.getToken()}}458 );459 },460 461 //****Seguros462 'obtenerListadoSeguros': function () {463 return $http.get(_api + 'listadoSeguros',464 465 {"headers": {"Authorization" : "Bearer "+token.getToken()}}466 );467 },468 //*****Maestros********************469 'obtenerMaestroProveedores': function () {470 return $http.get(_api + 'maestroProveedores',471 472 {"cache": true}473 //{"headers": {"Authorization" : "Bearer "+token.getToken()}}474 );475 },476 'obtenerMaestroCiasAereas': function () {477 return $http.get(_api + 'maestroCiasAereas',478 479 {"headers": {"Authorization" : "Bearer "+token.getToken()}}480 );481 },482 'obtenerMaestroCiudades': function () {483 return $http.get(_api + 'maestroCiudades',484 485 {"headers": {"Authorization" : "Bearer "+token.getToken()}}486 );487 },488 'obtenerMaestroTerminalesTraslados': function () {489 return $http.get(_api + 'maestroTerminalesTraslados',490 491 {"headers": {"Authorization" : "Bearer "+token.getToken()}}492 );493 }494 };495 }496])497.factory('token', function(base64) {498 var token;499 return{500 getToken: function(){501 return token;502 },503 getDecodedPayload:function(){504 return token === undefined ? {} : JSON.parse(base64.urldecode(token.split('.')[1])) ;505 },...
getData.js
Source:getData.js
...102 ibType: ibType,103 userName: userName,104 userSpell: userSpell,105 nameSpell: nameSpell106}, successCallback, getToken());107108/**109 * 注å-å¡«ååºæ¬èµæ110 */111var registerStep1 = (email, userName, userSpell, nameSpell, idCardNo, idCardAddress, isSameAddress, permanentAddress, isAmerican, successCallback) => http('POST', '/user/info_step1', {112 email: email,113 userName: userName,114 userSpell: userSpell,115 nameSpell: nameSpell,116 idCardNo: idCardNo,117 idCardAddress: idCardAddress,118 nameSpell: nameSpell,119 idCardNo: idCardNo,120 idCardAddress: idCardAddress,121 isSameAddress: isSameAddress,122 permanentAddress: permanentAddress,123 isAmerican: isAmerican124}, successCallback, getToken());125126/**127 * 注å-å¡«å家åºåèä¸ä¿¡æ¯128 */129var registerStep2 = (familyCount, marriageInfo, professionType, professionName, isRelative, isDirector, companyAddress, companyName, addressProvince, addressCity, addressArea, successCallback) => http('POST', '/user/info_step2', {130 familyCount: familyCount,131 marriageInfo: marriageInfo,132 professionType: professionType,133 professionName: professionName,134 isRelative: isRelative,135 isDirector: isDirector,136 companyAddress: companyAddress,137 companyName: companyName,138 addressProvince: addressProvince,139 addressCity: addressCity,140 addressArea: addressArea141}, successCallback, getToken()); /**/142143/**144 * 注å-èµäº§å交æç»éª145 */146var registerStep3 = (netAssets, netCurrentAssets, netAnnualIncome, totalAssets, investAim, tradeYears, tradeTimes, knowledgeLevel, isOpenOptionTrade, optionTradeYears, isOpenOtherTrade, hasTwsTradeExperience, successCallback) => http('POST', '/user/info_step3', {147 netAssets: netAssets,148 netCurrentAssets: netCurrentAssets,149 netAnnualIncome: netAnnualIncome,150 totalAssets: totalAssets,151 investAim: investAim,152 tradeYears: tradeYears,153 tradeTimes: tradeTimes,154 knowledgeLevel: knowledgeLevel,155 isOpenOptionTrade: isOpenOptionTrade,156 optionTradeYears: optionTradeYears,157 isOpenOtherTrade: isOpenOtherTrade,158 hasTwsTradeExperience: hasTwsTradeExperience,159}, successCallback, getToken());160161/**162 * 注å-åè®®ç¾ç½²163 */164var registerStep4 = (realName, successCallback) => http('POST', '/user/info_step4', {165 realName: realName166}, successCallback, getToken()); /**/167168/**169 * 注å-ä¸ä¼ 身份è¯æ170 */171var registerStep5 = (imgA, imgB, successCallback) => http('POST', '/user/info_step5', {172 imgA: imgA,173 imgB: imgB,174}, successCallback, getToken(), 'true');175176/**177 * 个人ä¸å¿-è´¦æ·ä¿¡æ¯178 */179var profileInfo = (successCallback) => http('POST', '/my/center', {}, successCallback, getToken());180181182/**183 * 个人ä¸å¿-æ¶æ¯å表184 */185var messageList = (type, successCallback) => http('POST', '/my/message', { type: type }, successCallback, getToken());186187/**188 * 个人ä¸å¿-æ¶æ¯è¯¦æ
189 */190var messageDetail = (mid, successCallback) => http('POST', '/my/message-detail', { mid: mid }, successCallback, getToken());191192/**193 * 个人ä¸å¿-ä¿¡æ¯åé¦194 */195var feedBack = (type, des, successCallback) => http('POST', '/my/feedback', { type: type, des: des }, successCallback, getToken());196197/**198 * 个人ä¸å¿-设置-éåº199 */200var signOut = (successCallback) => http('POST', '/user/logout', {}, successCallback, getToken());201202/**203 * 个人ä¸å¿-é£é©æµè¯204 */205var riskTest = (question1, question2, question3, question4, question5, question6, question7, question8, question9, question10, successCallback) => http('POST', '/my/risk', { question1: question1, question2: question2, question3: question3, question4: question4, question5: question5, question6: question6, question7: question7, question8: question8, question9: question9, question10: question10 }, successCallback, getToken());206207/**208 * 个人ä¸å¿-é£é©æµè¯ç»æ209 */210var riskTestResult = (successCallback) => http('POST', '/my/risk-result', {}, successCallback, getToken());211212213/**214 * 个人ä¸å¿-åºæ¬ä¿¡æ¯215 */216var baseInfo = (successCallback) => http('POST', '/my/base-info', {}, successCallback, getToken());217218/**219 * 个人ä¸å¿-æ¯æ¥çäº220 */221var profitDetailList = (type, opType, successCallback) => http('POST', '/my/daily-income', { type: type, opType: opType }, successCallback, getToken());222223/**224 * æºè½èµäº§-交æçé¢å±ç¤ºæ°æ®225 */226var assetIndex = (opType, successCallback) => http('POST', '/my/index', { opType: opType }, successCallback, getToken());227228/**229 * æºè½èµäº§-èªé
交æçé¢å±ç¤ºæ°æ®230 */231var assetDiyIndex = (opType, successCallback) => http('POST', '/my/diy-index', { opType: opType }, successCallback, getToken());232233/**234 * æºè½èµäº§-饼å¾æ°æ®(ç¨æ·ç»å½å)235 */236var assetPieData = (type, successCallback) => http('POST', '/profile/get-ring', { type: type }, successCallback, getToken());237238/**239 * æºè½èµäº§-饼å¾æ°æ®(游客)240 */241var assetPieDataNoToken = (type, successCallback) => http('POST', '/profile/get-standard', { type: type }, successCallback);242243/**244 * æºè½èµäº§-æ ¹æ®æ¥æè·å饼å¾æ°æ®245 */246var assetPieDataByDate = (type, date, successCallback) => http('POST', '/profile/get-ring', { type: type, date: date }, successCallback, getToken());247248/**249 * æºè½èµäº§-ç¡®å®éæ©250 */251var assetAddType = (type, reset = 0, successCallback) => http('POST', '/my/add-type', { type: type, reset: reset }, successCallback, getToken());252253/**254 * æºè½èµäº§-ç»å详æ
255 */256var assetTypeDetail = (type, f, successCallback) => http('POST', '/my/asset-type', { type: type, f: f }, successCallback, getToken());257258/**259 * æºè½èµäº§-ç»å详æ
ç»å¾æ°æ®260 */261var assetTypeMonth = (type, successCallback) => http('POST', '/my/type-month', { type: type }, successCallback, getToken());262263/**264 * æºè½èµäº§-è·åè°ä»è®°å½è¯¦æ
265 */266var assetRecordDetail = (type, date, opType, successCallback) => http('POST', '/my/record-detail', { type: type, date: date, opType: opType }, successCallback, getToken());267268/**269 * æºè½èµäº§-åæ¯FOFä¹°å
¥270 */271var assetSimpleFOFBuy = (fofId, amount, successCallback) => http('POST', '/order/buy-fof', { fofId: fofId, amount: amount }, successCallback, getToken());272273/**274 * æºè½èµäº§-åæ¯FOFååº275 */276var assetSimpleFOFSell = (fofId, amount, successCallback) => http('POST', '/order/sell-fof', { fofId: fofId, amount: amount }, successCallback, getToken());277/**278 * æºè½èµäº§-ä¸ç¯®åFOFä¹°å
¥279 */280var assetMultiFOFBuy = (list, successCallback) => http('POST', '/order/basket-buy', { list: list }, successCallback, getToken());281282/**283 * æºè½èµäº§-FOF大类å表284 */285var assetFOFList = (successCallback) => http('POST', '/order/get-fof', {}, successCallback, getToken());286287/**288 * æºè½èµäº§-æ£æµæ¯å¦éè¦å®æ¶æ°æ®289 */290var checkTrade = (successCallback) => http('POST', '/order/check-trade', {}, successCallback);291292/**293 * æºè½èµäº§-èªé
è´¦æ·é¥¼å¾294 */295var getFofChart = (successCallback) => http('POST', '/order/fof-chart', {}, successCallback);296297/**298 * åç°-æ°é»å表299 */300var newsList = (page,isRecommend,category,perPage, successCallback) => http('POST', '/research/getnews', { page,isRecommend,category,perPage }, successCallback);301302303/**304 * åç°-æ°é»è¯¦æ
305 */306var newsDetail = (id, successCallback) => http('POST', '/research/news-detail', { id }, successCallback);307308/**309 * æºè½èµäº§-å§æ订å310 */311var assetOrderList = (orderType, cur, successCallback) => http('POST', '/order/list', { orderType, cur }, successCallback, getToken());312313/**314 * æºè½èµäº§-æ¥çº¿315 */316var assetFOFDayLine = (fofId, successCallback) => http('POST', '/analyse/day-line', { fofId }, successCallback);317318/**319 * æºè½èµäº§-å¨çº¿320 */321var assetFOFWeekLine = (fofId, successCallback) => http('POST', '/analyse/week-line', { fofId }, successCallback);322323/**324 * æºè½èµäº§-æ线325 */326var assetFOFMonthLine = (fofId, successCallback) => http('POST', '/analyse/month-line', { fofId }, successCallback);327328329/**330 * 主è¦å¸åº-FOFèµäº§å
çéææ°æ®331 */332var mainFOFStaticList = (successCallback) => http('POST', '/order/fof-group', {}, successCallback);333334335/**336 * 主è¦å¸åº-FOFèµäº§å
çéææ°æ®337 */338var mainIndexStaticList = (successCallback) => http('POST', '/order/index-group', {}, successCallback);339340341/**342 * æ¤å-æ¤é订å343 */344var orderCancel = (orderId, successCallback) => http('POST', '/order/cancel', { orderId }, successCallback, getToken());345346347/**348 * æçå®ç-ç¨æ·å¼æ·æ¥éª¤ä¿¡æ¯349 */350var profileGetStep = (successCallback) => http('POST', '/user/get-step', {}, successCallback, getToken());351352353/**354 * æ¨èç±»å-订åå表355 */356var commendOrderList = (type, cur, successCallback) => http('POST', '/my/change-list', { type, cur }, successCallback, getToken());357358359/**360 * æ¨èç±»å-订åå表361 */362var commendOrderCancel = (id, successCallback) => http('POST', '/my/cancel-order', { id }, successCallback, getToken());363364/**365 * 主è¦å¸åº-å
¨çå¸åº366 */367var mainMainStaticList = (successCallback) => http('POST', '/order/global-group', { }, successCallback);368369/**370 * FOF详æ
-å
³äº371 */372var fofAnalyseDetail = (fofId,successCallback) => http('POST', '/analyse/detail', { fofId }, successCallback);373374/**375 * æºè½èµäº§-æ¨èç»åååº376 */377var myCommendSell = (successCallback) => http('POST', '/my/sold-out', { }, successCallback, getToken());378379/**380 * æºè½èµäº§-æ¨èç»å建ä»ï¼è°ä»381 */382var myChangePostion = (toType,successCallback) => http('POST', '/my/change-position', { toType }, successCallback, getToken());383384/**385 * 大类ææ°-æ¥çº¿386 */387var assetIndexDayLine = (fofId, successCallback) => http('POST', '/analyse/id-line', { fofId }, successCallback);388389/**390 * 大类ææ°-å¨çº¿391 */392var assetIndexWeekLine = (fofId, successCallback) => http('POST', '/analyse/iw-line', { fofId }, successCallback);393394/**395 * 大类ææ°-æ线396 */397var assetIndexMonthLine = (fofId, successCallback) => http('POST', '/analyse/im-line', { fofId }, successCallback);398399400/**401 * 大类ææ°|FOFå
-åæ¶çº¿402 */403var assetMinuteLine = (fofId, successCallback) => http('POST', '/analyse/minute-line', { fofId }, successCallback);404405/**406 * 大类ææ°|FOFå
-åºæ¬ä¿¡æ¯ï¼æ¨æ¶ãä»å¼ï¼407 */408var assetLineBaseInfo = (fofId, successCallback) => http('POST', '/analyse/price', { fofId }, successCallback);409410/**411 * æçæä»-å5åETF412 */413var assetTopEtf = (type,successCallback) => http('POST', '/my/top-etf', { type }, successCallback, getToken());414415/**416 * æç模æçèµäº§-æ¨èç»ååèªé
ç»å417 */418var assetMyVirtual = (successCallback) => http('POST', '/my/vir-total', { }, successCallback, getToken());419420/**421 * FOFå
-åå²æ¶ç422 */423var assetHistoryIncome = (fofId,successCallback) => http('POST', '/analyse/history-income', { fofId }, successCallback, getToken());424425426/**427 * å®ç交æ-è´¦æ·ä¿¡æ¯428 */429var tradeRecIndex = (type,accountId,successCallback) => http('POST', '/trade/rec-index', { type,accountId }, successCallback, getToken());430431432/**433 * å®ç交æ-è·å交æè´¦å·434 */435var tradeGetAccount = (successCallback) => http('POST', '/trade/get-account', { }, successCallback, getToken());436437438/**439 * å®ç交æ-éæ©ç±»å440 */441var tradeChooseType = (type,accountId,successCallback) => http('POST', '/trade/choose-type', {type,accountId}, successCallback, getToken());442443444/**445 * å®ç交æ-å¢èµåè¯446 */447var tradeAddFund = (amt,currency,remarks,accountId,addProve,successCallback) => http('POST', '/trade/add-fund', {amt,currency,remarks,accountId,addProve}, successCallback, getToken(), 'true');448449450/**451 * å®ç交æ-èµåç³è¯·452 */453var tradeRedeem = (amt,currency,remarks,bankType,bankName,swiftCode,accountId,accountName,successCallback) => http('POST', '/trade/redeem', {amt,currency,remarks,bankType,bankName,swiftCode,accountId,accountName}, successCallback, getToken());454455/**456 * å®ç交æ-æ¯æ¥æ¶ç457 */458var tradeDailyProfit = (type,accountId,successCallback) => http('POST', '/trade/daily-profit', {type,accountId}, successCallback, getToken());459460/**461 * å®ç交æ-åæ¶å§æ462 */463var tradeCancelEntrust = (changeId,successCallback) => http('POST', '/trade/cancel', {changeId}, successCallback, getToken());464465/**466 * å®ç交æ-å§æå表467 */468var tradeEntrustList = (type, cur,successCallback) => http('POST', '/trade/change-list', {type, cur}, successCallback, getToken());469470/**471 * å®ç交æ-ååº472 */473var tradeSoldOut = (accountId,successCallback) => http('POST', '/trade/sold-out', {accountId}, successCallback, getToken());474475/**476 * å®ç交æ-æä»477 */478var tradePostionList = (accountId,successCallback) => http('POST', '/trade/position', {accountId}, successCallback, getToken());479480/**481 * å®ç交æ-åºå
¥éæç»-å
¥é482 */483var tradeAddFundRecord = (successCallback) => http('POST', '/trade/add-list', {}, successCallback, getToken());484485/**486 * å®ç交æ-åºå
¥éæç»-åºé487 */488var tradeRedeemRecord = (successCallback) => http('POST', '/trade/redeem-list', {}, successCallback, getToken());489490491/**492 * å®ç交æ-å¤ææ¯å¦è½å¤å¢èµ493 */494var tradeCanAdd = (successCallback) => http('POST', '/trade/can-add', {}, successCallback, getToken());495496/**497 * å®ç交æ-å¤ææ¯å¦è½å¤èµå498 */499var tradeCanRedeem = (successCallback) => http('POST', '/trade/can-redeem', {}, successCallback, getToken());500501export { 502 getRecommendGroupChart, mobileCode, accountLogin, checkExsis, sendMobile,503 checkout, mainMarket, mainMarketDetail, messageList,504 messageDetail, indexDetail, indexData,505 indexMarketDetail, packageMarketDetail,506 assetDetail, assetDetailList,507 entrustDetailList, profitDetailList, 508 myIndex, assetPieData, register, 509 registerStep0, registerStep1,510 registerStep2, registerStep3,511 registerStep4, registerStep5, 512 profileInfo, feedBack, signOut, 513 riskTest, baseInfo, assetIndex,
...
rest_angular.js
Source:rest_angular.js
...22 .factory('AccountRestAngular', function (Restangular, ENV, GetToken) {23 return Restangular.withConfig(function (RestangularConfigurer) {24 if (ENV.encode) {25 RestangularConfigurer.setDefaultHeaders({26 'x-access-token': GetToken.getToken(),27 server_type: 'user'28 });29 } else {30 RestangularConfigurer.setDefaultHeaders({31 'x-access-token': GetToken.getToken()32 });33 RestangularConfigurer.setBaseUrl(ENV.api.account);34 }35 })36 })37 .factory('PassRestAngular', function (Restangular, ENV, GetToken) {38 return Restangular.withConfig(function (RestangularConfigurer) {39 if (ENV.encode) {40 RestangularConfigurer.setDefaultHeaders({41 'x-access-token': GetToken.getToken(),42 server_type: 'traffic'43 });44 } else {45 RestangularConfigurer.setDefaultHeaders({46 'x-access-token': GetToken.getToken()47 });48 RestangularConfigurer.setBaseUrl(ENV.api.pass);49 }50 })51 })52 .factory('PassPayAngular', function (Restangular, ENV, GetToken) {53 return Restangular.withConfig(function (RestangularConfigurer) {54 if (ENV.encode) {55 RestangularConfigurer.setDefaultHeaders({56 "Content-Type": undefined57 });58 RestangularConfigurer.setDefaultHeaders({59 'x-access-token': GetToken.getToken(),60 server_type: 'traffic'61 });62 } else {63 RestangularConfigurer.setDefaultHeaders({64 "Content-Type": undefined65 });66 RestangularConfigurer.setDefaultHeaders({67 'x-access-token': GetToken.getToken()68 });69 RestangularConfigurer.setBaseUrl(ENV.api.pass);70 }71 })72 })73 .factory('StoreRestAngular', function (Restangular, ENV, GetToken) {74 return Restangular.withConfig(function (RestangularConfigurer) {75 if (ENV.encode) {76 RestangularConfigurer.setDefaultHeaders({77 'x-access-token': GetToken.getToken(),78 server_type: 'user'79 });80 } else {81 RestangularConfigurer.setDefaultHeaders({82 'x-access-token': GetToken.getToken()83 });84 RestangularConfigurer.setBaseUrl(ENV.api.account);85 }86 });87 })88 .factory('CreditRestAngular', function (Restangular, ENV, GetToken) {89 return Restangular.withConfig(function (RestangularConfigurer) {90 if (ENV.encode) {91 RestangularConfigurer.setDefaultHeaders({92 'x-access-token': GetToken.getToken(),93 server_type: 'finance'94 });95 } else {96 RestangularConfigurer.setDefaultHeaders({97 'x-access-token': GetToken.getToken()98 });99 RestangularConfigurer.setBaseUrl(ENV.api.credit);100 }101 });102 })103 .factory('TradeRestAngular', function (Restangular, ENV, GetToken) {104 return Restangular.withConfig(function (RestangularConfigurer) {105 if (ENV.encode) {106 RestangularConfigurer.setDefaultHeaders({107 'x-access-token': GetToken.getToken(),108 server_type: 'trade'109 });110 } else {111 RestangularConfigurer.setDefaultHeaders({112 'x-access-token': GetToken.getToken()113 });114 RestangularConfigurer.setBaseUrl(ENV.api.trade);115 }116 });117 })118 .factory('LogServiceAngular', function (Restangular, ENV, GetToken) {119 return Restangular.withConfig(function (RestangularConfigurer) {120 if (ENV.encode) {121 RestangularConfigurer.setDefaultHeaders({122 'x-access-token': GetToken.getToken(),123 server_type: 'log'124 });125 } else {126 RestangularConfigurer.setDefaultHeaders({127 'x-access-token': GetToken.getToken()128 });129 RestangularConfigurer.setBaseUrl(ENV.api.log);130 }131 });132 })133 .factory('MsgServiceAngular', function (Restangular, ENV, GetToken) {134 return Restangular.withConfig(function (RestangularConfigurer) {135 if (ENV.encode) {136 RestangularConfigurer.setDefaultHeaders({137 'x-access-token': GetToken.getToken(),138 server_type: 'msg'139 });140 } else {141 RestangularConfigurer.setDefaultHeaders({142 'x-access-token': GetToken.getToken()143 });144 RestangularConfigurer.setBaseUrl(ENV.api.msg);145 }146 });147 })148 .factory('AdminServiceAngular', function (Restangular, ENV, GetToken) {149 return Restangular.withConfig(function (RestangularConfigurer) {150 if (ENV.encode) {151 RestangularConfigurer.setDefaultHeaders({152 'x-access-token': GetToken.getToken(),153 server_type: 'admin'154 });155 } else {156 RestangularConfigurer.setDefaultHeaders({157 'x-access-token': GetToken.getToken()158 });159 RestangularConfigurer.setBaseUrl(ENV.api.admin);160 }161 });162 })163 .factory('StatistServiceAngular', function (Restangular, ENV, GetToken) {164 return Restangular.withConfig(function (RestangularConfigurer) {165 if (ENV.encode) {166 RestangularConfigurer.setDefaultHeaders({167 'x-access-token': GetToken.getToken(),168 server_type: 'statist'169 });170 } else {171 RestangularConfigurer.setDefaultHeaders({172 'x-access-token': GetToken.getToken()173 });174 RestangularConfigurer.setBaseUrl(ENV.api.statist);175 }176 });177 })178 .factory('ContactAngular', function (Restangular, ENV, GetToken) {179 return Restangular.withConfig(function (RestangularConfigurer) {180 if (ENV.encode) {181 RestangularConfigurer.setDefaultHeaders({182 'x-access-token': GetToken,183 server_type: 'contact'184 });185 } else {186 RestangularConfigurer.setDefaultHeaders({187 'x-access-token': GetToken188 });189 RestangularConfigurer.setBaseUrl(ENV.api.contact);190 }191 });192 })193 .factory('DynamicAngular', function (Restangular, ENV, GetToken) {194 return Restangular.withConfig(function (RestangularConfigurer) {195 if (ENV.encode) {196 RestangularConfigurer.setDefaultHeaders({197 'x-access-token': GetToken,198 server_type: 'dynamic'199 });200 } else {201 RestangularConfigurer.setDefaultHeaders({202 'x-access-token': GetToken203 });204 RestangularConfigurer.setBaseUrl(ENV.api.dynamic);205 }206 });207 })208 .factory('GetToken', function (AuthenticationService) {209 return {210 getToken: function () {211 var token;212 var user = AuthenticationService.getUserInfo();213 //var user = window.sessionStorage.setItem('userInfo', window.JSON.stringify(data));214 if (user) {215 token = user.token;216 } else {217 token = '';218 }219 return token;220 }221 }222 })223 .factory('AuthenticationService', ['Storage', '$log', '$location', '$q', function (Storage, $log, $location, $q) {224 var userInfo;225 var companyInfo;226 function getUserInfo() {227 if (Storage.get('userInfo')) {228 userInfo = Storage.get('userInfo');229 return userInfo;230 } else {231 //$log.warn("no login");232 // $location.path('/tab/login')233 // window.location.href = 'http://'+$location.$$host+':'+ $location.$$port + '#/tab/login'234 return null;235 }236 }237 function getCompanyInfo() {238 if (Storage.get('userInfo').company) {239 companyInfo = Storage.get('userInfo').company;240 return companyInfo;241 } else {242 return null;243 }244 }245 return {246 getUserInfo: getUserInfo,247 getCompanyInfo: getCompanyInfo,248 checkToken: function () {249 userInfo = getUserInfo();250 if (userInfo) {251 return $q.when(userInfo);252 } else {253 return $q.reject({254 authenticated: false255 })256 }257 }258 };259 }])260 .factory('NewTradeRestAngular', function (Restangular, ENV, GetToken) {261 return Restangular.withConfig(function (RestangularConfigurer) {262 if (ENV.encode) {263 RestangularConfigurer.setDefaultHeaders({264 'x-access-token': GetToken.getToken(),265 server_type: 'user'266 });267 } else {268 RestangularConfigurer.setDefaultHeaders({269 'x-access-token': GetToken.getToken()270 });271 RestangularConfigurer.setBaseUrl(ENV.api.newtrade);272 }273 })274 })275 .factory('MsgServiceAngular', function (Restangular, ENV, GetToken) {276 return Restangular.withConfig(function (RestangularConfigurer) {277 if (ENV.encode) {278 RestangularConfigurer.setDefaultHeaders({279 'x-access-token': GetToken.getToken(),280 server_type: 'msg'281 });282 } else {283 RestangularConfigurer.setDefaultHeaders({284 'x-access-token': GetToken.getToken()285 });286 RestangularConfigurer.setBaseUrl(ENV.api.msg);287 }288 });289 })290 .factory('WebIMAngular', function (Restangular, ENV, GetToken) {291 return Restangular.withConfig(function (RestangularConfigurer) {292 if (ENV.encode) {293 RestangularConfigurer.setDefaultHeaders({294 'x-access-token': GetToken.getToken(),295 server_type: 'webim'296 });297 } else {298 RestangularConfigurer.setDefaultHeaders({299 'x-access-token': GetToken.getToken()300 });301 RestangularConfigurer.setBaseUrl(ENV.api.webim);302 }303 });304 })305 .factory('MapServiceAngular', function (Restangular, ENV, GetToken) {306 return Restangular.withConfig(function (RestangularConfigurer) {307 if (ENV.encode) {308 RestangularConfigurer.setDefaultHeaders({309 'x-access-token': GetToken.getToken(),310 server_type: 'map'311 });312 } else {313 RestangularConfigurer.setDefaultHeaders({314 'x-access-token': GetToken.getToken()315 });316 RestangularConfigurer.setBaseUrl(ENV.api.map);317 }318 });319 })320 .factory('CompatibleServiceAngular', function (Restangular, ENV, GetToken) {321 return Restangular.withConfig(function (RestangularConfigurer) {322 if (ENV.encode) {323 RestangularConfigurer.setDefaultHeaders({324 'x-access-token': GetToken.getToken(),325 server_type: 'compatible'326 });327 } else {328 RestangularConfigurer.setDefaultHeaders({329 'x-access-token': GetToken.getToken()330 });331 RestangularConfigurer.setBaseUrl(ENV.api.compatible);332 }333 });...
parser.test.js
Source:parser.test.js
2var Parser = require('../lib/parser');3describe('Parser', function () {4 it('should parse text', function () {5 var parser = new Parser('Hello World');6 parser.getToken().type.should.equal(Parser.TOKEN_TEXT);7 parser.getToken().value.should.equal('Hello World');8 parser.next();9 parser.getToken().type.should.equal(Parser.TOKEN_EOF);10 });11 it('should parse variable', function () {12 var parser = new Parser('{{variableName_1}}');13 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);14 parser.next();15 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);16 parser.getToken().value.should.equal('variableName_1');17 parser.next();18 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);19 parser.next();20 parser.getToken().type.should.equal(Parser.TOKEN_EOF);21 });22 it('should parse number', function () {23 var parser = new Parser('{{123}}');24 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);25 parser.next();26 parser.getToken().type.should.equal(Parser.TOKEN_NUMBER);27 parser.getToken().value.should.equal('123');28 parser.next();29 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);30 parser.next();31 parser.getToken().type.should.equal(Parser.TOKEN_EOF);32 });33 it('should parse mixed variable and text', function () {34 var parser = new Parser('Hello, {{variableName_1}}!');35 parser.getToken().type.should.equal(Parser.TOKEN_TEXT);36 parser.getToken().value.should.equal('Hello, ');37 parser.next();38 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);39 parser.next();40 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);41 parser.getToken().value.should.equal('variableName_1');42 parser.next();43 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);44 parser.next();45 parser.getToken().type.should.equal(Parser.TOKEN_TEXT);46 parser.getToken().value.should.equal('!');47 parser.next();48 parser.getToken().type.should.equal(Parser.TOKEN_EOF);49 });50 it('should parse block', function () {51 var parser = new Parser('{{#if}}');52 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_BLOCK_EXPRESSION);53 parser.next();54 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);55 parser.getToken().value.should.equal('if');56 parser.next();57 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);58 parser.next();59 parser.getToken().type.should.equal(Parser.TOKEN_EOF);60 });61 it('should parse block close', function () {62 var parser = new Parser('{{/if}}');63 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_CLOSE_BLOCK_EXPRESSION);64 parser.next();65 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);66 parser.getToken().value.should.equal('if');67 parser.next();68 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);69 parser.next();70 parser.getToken().type.should.equal(Parser.TOKEN_EOF);71 });72 it('should parse expression with parameters', function () {73 var parser = new Parser('{{exec var1 "Hello" 234 param1=var2 param2="World!"}}');74 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);75 parser.next();76 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);77 parser.getToken().value.should.equal('exec');78 parser.next();79 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);80 parser.getToken().value.should.equal('var1');81 parser.next();82 parser.getToken().type.should.equal(Parser.TOKEN_STRING);83 parser.getToken().value.should.equal('Hello');84 parser.next();85 parser.getToken().type.should.equal(Parser.TOKEN_NUMBER);86 parser.getToken().value.should.equal('234');87 parser.next();88 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);89 parser.getToken().value.should.equal('param1');90 parser.next();91 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);92 parser.getToken().value.should.equal('=');93 parser.next();94 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);95 parser.getToken().value.should.equal('var2');96 parser.next();97 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);98 parser.getToken().value.should.equal('param2');99 parser.next();100 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);101 parser.getToken().value.should.equal('=');102 parser.next();103 parser.getToken().type.should.equal(Parser.TOKEN_STRING);104 parser.getToken().value.should.equal('World!');105 parser.next();106 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);107 parser.next();108 parser.getToken().type.should.equal(Parser.TOKEN_EOF);109 });110 it('should parse string value', function () {111 var parser = new Parser('{{"Hello"}}');112 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);113 parser.next();114 parser.getToken().type.should.equal(Parser.TOKEN_STRING);115 parser.getToken().value.should.equal('Hello');116 parser.next();117 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);118 parser.next();119 parser.getToken().type.should.equal(Parser.TOKEN_EOF);120 });121 it('should escape string value', function () {122 var parser = new Parser('{{"Hello \\"mate\\""}}');123 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);124 parser.next();125 parser.getToken().type.should.equal(Parser.TOKEN_STRING);126 parser.getToken().value.should.equal('Hello "mate"');127 parser.next();128 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);129 parser.next();130 parser.getToken().type.should.equal(Parser.TOKEN_EOF);131 });132 describe('logical', function () {133 it('should parse >', function () {134 var parser = new Parser('{{a>b}}');135 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);136 parser.next();137 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);138 parser.getToken().value.should.equal('a');139 parser.next();140 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);141 parser.getToken().value.should.equal('>');142 parser.next();143 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);144 parser.getToken().value.should.equal('b');145 parser.next();146 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);147 parser.next();148 parser.getToken().type.should.equal(Parser.TOKEN_EOF);149 });150 it('should parse >=', function () {151 var parser = new Parser('{{a>=b}}');152 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);153 parser.next();154 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);155 parser.getToken().value.should.equal('a');156 parser.next();157 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);158 parser.getToken().value.should.equal('>=');159 parser.next();160 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);161 parser.getToken().value.should.equal('b');162 parser.next();163 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);164 parser.next();165 parser.getToken().type.should.equal(Parser.TOKEN_EOF);166 });167 it('should parse <', function () {168 var parser = new Parser('{{a < b}}');169 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);170 parser.next();171 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);172 parser.getToken().value.should.equal('a');173 parser.next();174 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);175 parser.getToken().value.should.equal('<');176 parser.next();177 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);178 parser.getToken().value.should.equal('b');179 parser.next();180 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);181 parser.next();182 parser.getToken().type.should.equal(Parser.TOKEN_EOF);183 });184 it('should parse <=', function () {185 var parser = new Parser('{{a <= b}}');186 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);187 parser.next();188 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);189 parser.getToken().value.should.equal('a');190 parser.next();191 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);192 parser.getToken().value.should.equal('<=');193 parser.next();194 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);195 parser.getToken().value.should.equal('b');196 parser.next();197 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);198 parser.next();199 parser.getToken().type.should.equal(Parser.TOKEN_EOF);200 });201 it('should parse ==', function () {202 var parser = new Parser('{{a == b}}');203 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);204 parser.next();205 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);206 parser.getToken().value.should.equal('a');207 parser.next();208 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);209 parser.getToken().value.should.equal('==');210 parser.next();211 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);212 parser.getToken().value.should.equal('b');213 parser.next();214 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);215 parser.next();216 parser.getToken().type.should.equal(Parser.TOKEN_EOF);217 });218 it('should parse !=', function () {219 var parser = new Parser('{{a != b}}');220 parser.getToken().type.should.equal(Parser.TOKEN_BEGIN_EXPRESSION);221 parser.next();222 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);223 parser.getToken().value.should.equal('a');224 parser.next();225 parser.getToken().type.should.equal(Parser.TOKEN_OPERATOR);226 parser.getToken().value.should.equal('!=');227 parser.next();228 parser.getToken().type.should.equal(Parser.TOKEN_IDENTIFIER);229 parser.getToken().value.should.equal('b');230 parser.next();231 parser.getToken().type.should.equal(Parser.TOKEN_END_EXPRESSION);232 parser.next();233 parser.getToken().type.should.equal(Parser.TOKEN_EOF);234 });235 });...
user.js
Source:user.js
...5 mainPage() {6 // console.log("å¨user.jsä¸" + { userId });7 // é裡 return çææ¯ä¸å Promise8 // return apiHelper.get(`/tweets/${userId}`, {9 // headers: { Authorization: `Bearer ${getToken()}` }10 // })11 return apiHelper.get(`/tweets`, {12 headers: { Authorization: `Bearer ${getToken()}` },13 })14 },15 ReplyList({ tweetId }) {16 // é裡 return çææ¯ä¸å Promise17 return apiHelper.get(`/tweets/${tweetId}`, {18 headers: { Authorization: `Bearer ${getToken()}` },19 })20 },21 AdminMain() {22 return apiHelper.get(`admin/tweets`, {23 headers: { Authorization: `Bearer ${getToken()}` },24 })25 },26 AdminUsers() {27 return apiHelper.get(`/admin/users`, {28 headers: { Authorization: `Bearer ${getToken()}` },29 })30 },31 get({ userId }) {32 return apiHelper.get(`/users/${userId}`, {33 headers: { Authorization: `Bearer ${getToken()}` },34 })35 },36 updateUserInfo({ userId, account, name, email, password, checkPassword }) {37 return apiHelper.put(38 `/users/${userId}/account`,39 { account, email, name, password, checkPassword },40 {41 headers: { Authorization: `Bearer ${getToken()}` },42 }43 )44 },45 userSetUp({ account, email, password, checkPassword, name }) {46 return apiHelper.post(`/users`, {47 account,48 email,49 password,50 checkPassword,51 name,52 })53 },54 // userSetUp({ formData }) {55 // return apiHelper.post(`/users`, { formData })56 // }57 tweet({ description }) {58 return apiHelper.post(59 `/tweets`,60 { description },61 {62 headers: { Authorization: `Bearer ${getToken()}` },63 }64 )65 },66 reply({ tweetId, comment }) {67 return apiHelper.post(68 `/tweets/${tweetId}/replies`,69 { comment },70 {71 headers: { Authorization: `Bearer ${getToken()}` },72 }73 )74 },75 addLike({ tweetId }) {76 return apiHelper.post(`/tweets/${tweetId}/like`, null, {77 headers: { Authorization: `Bearer ${getToken()}` },78 })79 },80 deleteLike({ tweetId }) {81 return apiHelper.post(`/tweets/${tweetId}/unlike`, null, {82 headers: { Authorization: `Bearer ${getToken()}` },83 })84 },85 getTweets({ userId }) {86 return apiHelper.get(`/users/${userId}/tweets`, {87 headers: { Authorization: `Bearer ${getToken()}` },88 })89 },90 getLikes({ userId }) {91 return apiHelper.get(`/users/${userId}/likes`, {92 headers: { Authorization: `Bearer ${getToken()}` },93 })94 },95 getTweetsReplies({ userId }) {96 return apiHelper.get(`/users/${userId}/replied_tweets`, {97 headers: { Authorization: `Bearer ${getToken()}` },98 })99 },100 getFollowers({ userId }) {101 return apiHelper.get(`/users/${userId}/followers`, {102 headers: { Authorization: `Bearer ${getToken()}` },103 })104 },105 getFollowings({ userId }) {106 return apiHelper.get(`/users/${userId}/followings`, {107 headers: { Authorization: `Bearer ${getToken()}` },108 })109 },110 getUsersTop() {111 return apiHelper.get('/users/top', {112 headers: { Authorization: `Bearer ${getToken()}` },113 })114 },115 addFollow({ id }) {116 return apiHelper.post(117 '/followships',118 { id },119 {120 headers: { Authorization: `Bearer ${getToken()}` },121 }122 )123 },124 deleteFollow({ userId }) {125 return apiHelper.delete(`/followships/${userId}`, {126 headers: { Authorization: `Bearer ${getToken()}` },127 })128 },129 // editProfile({ userId, name, introduction, avatar, cover }) {130 // return apiHelper.put(131 // `/users/${userId}`,132 // { name, introduction, avatar, cover },133 // {134 // headers: {135 // Authorization: `Bearer ${getToken()}`,136 // },137 // }138 // )139 // },140 editProfile({ userId, formData }) {141 return apiHelper.put(142 `/users/${userId}`,143 formData,144 {145 headers: {146 Authorization: `Bearer ${getToken()}`,147 },148 }149 )150 },151 deleteTweet({ TweetId }) {152 return apiHelper.delete(`/admin/tweets/${TweetId}`, {153 headers: { Authorization: `Bearer ${getToken()}` },154 })155 },...
lexer.js
Source:lexer.js
...14 var lexer = sslexer.lexer(null);15 test.equal(lexer.nextToken(), null);16}1718function getToken(text, value, type, test) {19 var lexer = sslexer.lexer(text);20 var token = lexer.nextToken();21 test.ok(token);22 test.equal(token.value, value);23 test.equal(token.type, type);24 test.equal(lexer.nextToken(), null);25};2627exports['Get names'] = function (test) {28 getToken('foo', 'foo', TokenType.Name, test);29 getToken('foo123', 'foo123', TokenType.Name, test);30 getToken('foo_123', 'foo_123', TokenType.Name, test);31 getToken('_foo', '_foo', TokenType.Name, test);32}3334exports['Get integer'] = function (test) {35 getToken('123', '123', TokenType.Integer, test);36 getToken('1234567890', '1234567890', TokenType.Integer, test);37}3839exports['Get real'] = function (test) {40 getToken('123.45', '123.45', TokenType.Real, test);41 getToken('1234567890.12', '1234567890.12', TokenType.Real, test);42}4344exports['Skip spaces'] = function (test) {45 getToken(' foo ', 'foo', TokenType.Name, test);46 getToken(' 123 ', '123', TokenType.Integer, test);47}4849exports['Get simple double quoted string'] = function (test) {50 getToken('"foo"', 'foo', TokenType.String, test);51 getToken('"123"', '123', TokenType.String, test);52}5354exports['Get simple single quoted string'] = function (test) {55 getToken("'foo'", 'foo', TokenType.String, test);56 getToken("'123'", '123', TokenType.String, test);57}5859exports['Unclosed string'] = function (test) {60 test.throws(function() {61 var lexer = sslexer.lexer('"foo');62 lexer.nextToken();63 },64 function(err) {65 test.ok(err);66 test.equal(err, 'unclosed string');67 return true;68 });69}7071exports['New line'] = function (test) {72 getToken('\n', '\n', TokenType.NewLine, test);73 getToken('\r\n', '\r\n', TokenType.NewLine, test);74 getToken('\r', '\r', TokenType.NewLine, test);75}7677exports['Separators'] = function (test) {78 getToken('.', '.', TokenType.Separator, test);79 getToken(',', ',', TokenType.Separator, test);80 getToken('(', '(', TokenType.Separator, test);81 getToken(')', ')', TokenType.Separator, test);82}8384exports['Square Brackets as Separators'] = function (test) {85 getToken('[', '[', TokenType.Separator, test);86 getToken(']', ']', TokenType.Separator, test);87}8889exports['Operators'] = function (test) {90 getToken('+', '+', TokenType.Operator, test);91 getToken('-', '-', TokenType.Operator, test);92 getToken('*', '*', TokenType.Operator, test);93 getToken('/', '/', TokenType.Operator, test);94}9596exports['Comparison Operators'] = function (test) {97 getToken('==', '==', TokenType.Operator, test);98 getToken('!=', '!=', TokenType.Operator, test);99 getToken('<', '<', TokenType.Operator, test);100 getToken('>', '>', TokenType.Operator, test);101 getToken('<=', '<=', TokenType.Operator, test);102 getToken('>=', '>=', TokenType.Operator, test);103}104105exports['Assigments'] = function (test) {106 getToken('=', '=', TokenType.Assignment, test);107 getToken('+=', '+=', TokenType.Assignment, test);108 getToken('-=', '-=', TokenType.Assignment, test);109 getToken('*=', '*=', TokenType.Assignment, test);110 getToken('/=', '/=', TokenType.Assignment, test);
...
App.js
Source:App.js
...24 });25 function setToken(tokenString) {26 sessionStorage.setItem('token', tokenString);27 }28 function getToken() {29 return sessionStorage.getItem('token');30 }31 function checkLoginStatus() {32 Auth.currentAuthenticatedUser()33 .then(user => {34 setToken(user.username);35 updateSignedIn(true);36 updateFormType('signedIn');37 })38 .catch(err => {39 console.log(err);40 });;41 }42 return (...
Using AI Code Generation
1var Cucumber = require('cucumber');2var cucumberGherkin = new Cucumber.Gherkin();3var token = cucumberGherkin.getToken();4console.log(token);5var Cucumber = require('cucumber');6var cucumberGherkin = new Cucumber.Gherkin();7var gherkin = cucumberGherkin.getGherkin();8console.log(gherkin);9var Cucumber = require('cucumber');10var cucumberGherkin = new Cucumber.Gherkin();11var gherkin = cucumberGherkin.getGherkin();12console.log(gherkin);13var Cucumber = require('cucumber');14var cucumberGherkin = new Cucumber.Gherkin();15var tag = cucumberGherkin.getTag();16console.log(tag);17var Cucumber = require('cucumber');18var cucumberGherkin = new Cucumber.Gherkin();19var tag = cucumberGherkin.getTag();20console.log(tag);21var Cucumber = require('cucumber');22var cucumberGherkin = new Cucumber.Gherkin();23var feature = cucumberGherkin.getFeature();24console.log(feature);25var Cucumber = require('cucumber');26var cucumberGherkin = new Cucumber.Gherkin();27var feature = cucumberGherkin.getFeature();28console.log(feature);29var Cucumber = require('cucumber');30var cucumberGherkin = new Cucumber.Gherkin();31var scenario = cucumberGherkin.getScenario();32console.log(scenario);33var Cucumber = require('cucumber');
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!