<commit_before>import is from 'check-types';

import Pagarme from './pagarme';
import Request from './request';

let request;

class Plan {
	constructor(plan) {
		if (is.undefined(Pagarme.getApiKey())) {
			throw new Error();
		}

		Object.assign(this, plan);
		request = new Request();
	}

	create() {
        if (is.undefined(this.amount)) {
            throw new Error();
        }

        if (is.undefined(this.days)) {
            throw new Error(); 
        }

        if (is.undefined(this.name)) {
            throw new Error();
        }

        if (is.not.undefined(this.id)) {
            throw new Error();
        }

        return request
            .post('plans', this)
            .then(plan => {
                Object.assign(this, plan)
                return plan;
            });
	}

	findAll(query) {
		return request
			.get('plans', query);	
	}

	find(id) {
        id = id || this.id;

        if (is.undefined(id)) {
            throw new Error();
        }

        return request
            .get('plans/' + id, this)
            .then(plan => {
                Object.assign(this, plan)
                return plan;
            });

	}

	update(properties) {
        return request
            .put('plans/' + this.id, properties);    
	}
}

export default Plan;<commit_msg>Fix plan identation<commit_after>import is from 'check-types';

import Pagarme from './pagarme';
import Request from './request';

let request;

class Plan {
    constructor(plan) {
        if (is.undefined(Pagarme.getApiKey())) {
            throw new Error();
        }

        Object.assign(this, plan);
        request = new Request();
    }

    create() {
        if (is.undefined(this.amount)) {
            throw new Error();
        }

        if (is.undefined(this.days)) {
            throw new Error(); 
        }

        if (is.undefined(this.name)) {
            throw new Error();
        }

        if (is.not.undefined(this.id)) {
            throw new Error();
        }

        return request.post('plans', this)
            .then(plan => {
                Object.assign(this, plan)
                return plan;
            });
    }

    findAll(query) {
        return request.get('plans', query);	
    }

    find(id) {
        id = id || this.id;

        if (is.undefined(id)) {
            throw new Error();
        }

        return request.get('plans/' + id, this)
            .then(plan => {
                Object.assign(this, plan)
                return plan;
            });

    }

    update(properties) {
        return request.put('plans/' + this.id, properties);    
    }
}

export default Plan;
{'fraction_non_alphanumeric': 0.13626040878122633, 'fraction_numerical': 0.0, 'mean_word_length': 1.4631873252562908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3541800', 'n_tokens_mistral': 807, 'n_tokens_neox': 760, 'n_words': 177}