overleaf/services/web/app/coffee/Features/BrandVariations/BrandVariationsHandler.coffee
Paulo Reis 00a489a000 Fetch brand variation details for branded projects; inject details into the editor page front-end.
Test brand variation details.

Rename BrandVariationsController to BrandVariationsHandler.

Use the V1 API helper.

Do not swallow errors when fetching brand details for project load.

Fix indentation.
2018-10-19 10:47:02 +01:00

16 lines
738 B
CoffeeScript

settings = require "settings-sharelatex"
logger = require "logger-sharelatex"
V1Api = require "../V1/V1Api"
module.exports = BrandVariationsHandler =
getBrandVariationById: (brandVariationId, callback = (error, brandVariationDetails) ->)->
if !brandVariationId? or brandVariationId == ""
return callback(new Error("Branding variation id not provided"))
logger.log brandVariationId: brandVariationId, "fetching brand variation details from v1"
V1Api.request {
uri: "/api/v2/brand_variations/#{brandVariationId}"
}, (error, response, brandVariationDetails) ->
if error?
logger.err { brandVariationId, error}, "error getting brand variation details"
return callback(error)
callback(null, brandVariationDetails)