<commit_before><?php

namespace EasyPost;

/**
 * @package EasyPost
 * @property string $id
 * @property string $object
 * @property CreditCard primary_payment_method
 * @property CreditCard secondary_payment_method
 */
class PaymentMethod extends EasypostResource
{
    /**
     * Retrieve all payment methods.
     *
     * @param mixed $params
     * @param string $apiKey
     * @return mixed
     */
    public static function all($params = null, $apiKey = null)
    {
        return self::_all(get_class(), $params, $apiKey);
    }
}<commit_msg>add missing conditional statement to check if there is a payment method. (#178)<commit_after><?php

namespace EasyPost;

/**
 * @package EasyPost
 * @property string $id
 * @property string $object
 * @property CreditCard primary_payment_method
 * @property CreditCard secondary_payment_method
 */
class PaymentMethod extends EasypostResource
{
    /**
     * Retrieve all payment methods.
     *
     * @param mixed $params
     * @param string $apiKey
     * @return mixed
     */
    public static function all($params = null, $apiKey = null)
    {
        $response = self::_all(get_class(), $params, $apiKey);

        if ($response->id == null) {
            throw new Error('Billing has not been setup for this user. Please add a payment method.');
        }
        return $response;
    }
}
{'fraction_non_alphanumeric': 0.10814814814814815, 'fraction_numerical': 0.0022222222222222222, 'mean_word_length': 2.997041420118343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '4097528', 'n_tokens_mistral': 381, 'n_tokens_neox': 378, 'n_words': 120}