parser/server.js

import { JsonApiServer } from '../json_api'

/**
 * Facilitates interaction with the parser server.
 *
 * @class
 */
export class ParserServer extends JsonApiServer {
  /**
   * Create a new parser server instance.
   *
   * @constructor
   * @param {ShelfNetwork} sdk Parent SDK instance.
   * @param {string} serverUrl parser URL.
   * @param {Object} opts
   * @param {boolean} [opts.allowHttp] Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
   * @param {Object} [opts.proxy] Proxy configuration. Look [axios docs](https://github.com/axios/axios#request-config) for more info
   * @param {Object} [opts.httpBasicAuth] HTTP basic auth credentials. Look [axios docs](https://github.com/axios/axios#request-config) for more info.
   * @param {Object} [opts.customHeaders] Custom headers for request.
   * @param {boolean} [opts.withCredentials] Indicates whether or not cross-site Access-Control requests should be made using credentials.
   * @param {string} [opts.responseType='json'] Indicates the type of data that the server will respond with options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'.
   */
  constructor (sdk, serverUrl, opts = {}) {
    opts.alias = 'copart'
    super(sdk, serverUrl, opts)
  }

  /**
   * Get copart lot details.
   *
   * @param {Number} id Copart lot ID.
   *
   * @return {Promise.<JsonApiResponse>} Parser response.
   */
  async getLotDetails (id) {
    return this._makeCallBuilder()
      .appendUrlSegment(['lots', id, 'details'])
      .get()
  }
}