sergiors / iugu

4 stars 1 forks source link

Refactor Charge Class #3

Open ronaldooliveiradevbr opened 7 years ago

ronaldooliveiradevbr commented 7 years ago

Hey, @sergiors ! What's up?

I've been wondering, what if we inject PaymentMethod into Charge Class as a dependency? Although Iugu's API doesn't support all payment methods names (it only supports 'bank_slip' at the moment), it looks consistent to me to require it inside Charge. Besides, we could improve Iugu Class to consume other resources like creating Customers and Customer's payment methods (i.e. credit cards tokens for recurring payments), and so on. Also, maybe we could come up with a Interface for Charge and other resources. Something like:

`

interface ResourceInterface
{
    public function getEndpoint() : string;
}

class Charge implements ResourceInterface
{
    ...

    const ENDPOINT;

    public function getEndpoint() : string
    {
        return self::ENDPOINT;
    }

    ...

}

`

Any thoughts?

Thanks! =)