All files / src/resources/customers payments.js

100% Statements 12/12
83.33% Branches 5/6
100% Functions 3/3
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                                              3x   3x 3x     3x                       3x   3x 2x     3x                     4x   3x 2x     3x      
import omit from 'lodash/omit';
 
import CustomersResource from './base';
import Payment from '../../models/payment';
 
/**
 * The `customers_payments` resource
 * @static {string} resource
 * @static {Object} model
 * @since 1.1.1
 */
export default class CustomersPayments extends CustomersResource {
  static resource = 'customers_payments';
  static model = Payment;
 
  /**
   * Create a customer payment
   * @param {Object} [data]
   * @param {function} [cb]
   * @returns {Promise.<T>}
   * @since 1.1.1
   */
  create(data, cb) {
    this.setParent(data);
 
    Eif (typeof data === 'object') {
      data = omit(data, 'customerId'); // eslint-disable-line no-param-reassign
    }
 
    return super.create(data, cb);
  }
 
  /**
   * Get a customer payment
   * @param {number} id
   * @param {Object} [params]
   * @param {function} [cb]
   * @returns {Promise.<T>}
   * @since 1.1.1
   */
  get(id, params, cb) {
    this.setParent(params);
 
    if (typeof params === 'object') {
      params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
    }
 
    return super.get(id, params, cb);
  }
 
  /**
   * Get all of a customer's payments
   * @param {Object} [params]
   * @param {function} [cb]
   * @returns {Promise.<T>}
   * @since 1.1.1
   */
  all(params, cb) {
    this.setParent(params);
 
    if (typeof params === 'object') {
      params = omit(params, 'customerId'); // eslint-disable-line no-param-reassign
    }
 
    return super.all(params, cb);
  }
}