-{ extend } = require 'underscore'
-metaphysics = require '../../../lib/metaphysics'
 Artwork = require '../../models/artwork'
 Fair = require '../../models/fair'
+PendingOrder = require '../../models/pending_order'
+get = require 'lodash.get'
+metaphysics = require '../../../lib/metaphysics'
 request = require 'superagent'
-PendingOrder = require '../../models/pending_order'
+sd = require('sharify').data
 splitTest = require '../../components/split_test/index.coffee'
+{ extend } = require 'underscore'
 
 query = """
   query artwork($id: String!) {

      res.locals.sd.PARAMS = req.params
      res.locals.sd.INCLUDE_SAILTHRU = data.artwork?.fair?
      res.locals.sd.QUERY = req.query
      res.render 'index', data

    .catch next

@acquire = (req, res, next) ->

    else
      res.status 403
      next new Error 'Not authorized to download this image'

# Helpers
fetchMeData = (query, user, saleId) ->
  new Promise (resolve, reject) ->
    metaphysics
      method: 'post'
      query: query,
      req:
        user: user
      variables:
        sale_id: saleId
    .then (response) ->
      resolve(response)
    .catch (error) ->
      reject(error)
