<commit_before>const request = require('request-promise');

class Postmates {
  constructor(customerId, apiKey) {
    if (!customerId) {
      throw new Error('Missing parameter, customerId');
    }
    if (!apiKey) {
      throw new Error('Missing parameter, apiKey');
    }
    this.customerId = customerId;
    this.apiKey = apiKey;
    this.baseUrl = 'https://api.postmates.com/';
  }
  query(method, endpoint, body) {
    const url = `${this.baseUrl}${endpoint}`;
    return request({
      url,
      method,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        Authorization: `Basic ${Buffer.from(`${this.apiKey}:`).toString('base64')}`,
      },
      formData: body,
      json: true,
    });
  }

  getDeliveryQuote(pickupAddress, dropoffAddress) {
    return this.query('POST', `/v1/customers/${this.customerId}/delivery_quotes`, {
      pickup_address: pickupAddress,
      dropoff_address: dropoffAddress,
    });
  }

  getDeliveryZones() {
    return this.query('GET', '/v1/delivery_zones');
  }

  createDelivery(delivery) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries`, {
      quote_id: delivery.quoteId,
      manifest: delivery.manifest,
      manifest_reference: delivery.manifestReference,
      pickup_name: delivery.pickupName,
      pickup_address: delivery.pickupAddress,
      pickup_phone_number: delivery.pickupPhoneNumber,
      pickup_business_name: delivery.pickupBusinessName,
      pickup_notes: delivery.pickupNotes,
      dropoff_name: delivery.dropoffName,
      dropoff_address: delivery.dropoffAddress,
      dropoff_phone_number: delivery.dropoffPhoneNumber,
      dropoff_business_name: delivery.dropoffBusinessName,
      dropoff_notes: delivery.dropoffNotes,
    });
  }

  listDeliveries() {
    return this.query('GET', `/v1/customers/${this.customerId}/deliveries`);
  }

  getDelivery(deliveryId) {
    return this.query('GET', `/v1/customers/${this.customerId}/deliveries/${deliveryId}`);
  }

  cancelDelivery(deliveryId) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries/${deliveryId}/cancel`);
  }

  addTipToDelivery(deliveryId, tipAmount) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries/${deliveryId}`, {
      tip_by_customer: tipAmount,
    });
  }
}

module.exports = Postmates;<commit_msg>use es6 exports and imports<commit_after>import * as request from 'request-promise';

class Postmates {
  constructor(customerId, apiKey) {
    if (!customerId) {
      throw new Error('Missing parameter, customerId');
    }
    if (!apiKey) {
      throw new Error('Missing parameter, apiKey');
    }
    this.customerId = customerId;
    this.apiKey = apiKey;
    this.baseUrl = 'https://api.postmates.com/';
  }
  query(method, endpoint, body) {
    const url = `${this.baseUrl}${endpoint}`;
    return request({
      url,
      method,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        Authorization: `Basic ${Buffer.from(`${this.apiKey}:`).toString('base64')}`,
      },
      formData: body,
      json: true,
    });
  }

  getDeliveryQuote(pickupAddress, dropoffAddress) {
    return this.query('POST', `/v1/customers/${this.customerId}/delivery_quotes`, {
      pickup_address: pickupAddress,
      dropoff_address: dropoffAddress,
    });
  }

  getDeliveryZones() {
    return this.query('GET', '/v1/delivery_zones');
  }

  createDelivery(delivery) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries`, {
      quote_id: delivery.quoteId,
      manifest: delivery.manifest,
      manifest_reference: delivery.manifestReference,
      pickup_name: delivery.pickupName,
      pickup_address: delivery.pickupAddress,
      pickup_phone_number: delivery.pickupPhoneNumber,
      pickup_business_name: delivery.pickupBusinessName,
      pickup_notes: delivery.pickupNotes,
      dropoff_name: delivery.dropoffName,
      dropoff_address: delivery.dropoffAddress,
      dropoff_phone_number: delivery.dropoffPhoneNumber,
      dropoff_business_name: delivery.dropoffBusinessName,
      dropoff_notes: delivery.dropoffNotes,
    });
  }

  listDeliveries() {
    return this.query('GET', `/v1/customers/${this.customerId}/deliveries`);
  }

  getDelivery(deliveryId) {
    return this.query('GET', `/v1/customers/${this.customerId}/deliveries/${deliveryId}`);
  }

  cancelDelivery(deliveryId) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries/${deliveryId}/cancel`);
  }

  addTipToDelivery(deliveryId, tipAmount) {
    return this.query('POST', `/v1/customers/${this.customerId}/deliveries/${deliveryId}`, {
      tip_by_customer: tipAmount,
    });
  }
}

export default Postmates;
{'fraction_non_alphanumeric': 0.1399662731871838, 'fraction_numerical': 0.004005059021922428, 'mean_word_length': 3.6337890625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '183078', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1543, 'n_words': 228}