braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 98 forks source link

toString methods are missing #57

Open uwemaurer opened 6 years ago

uwemaurer commented 6 years ago

the library would be much easier to work with if there were toString() methods on the classes

crookedneighbor commented 6 years ago

Thanks for the feedback, we'll take it into consideration. Adding this is not on our current roadmap, but I can see how it would be useful.

As always, PRs are welcome!

kmichalak commented 6 years ago

What in your opinion is the best approach of implementing toString() methods for SDK classes? Should it be some JSON like structure that represents all object properties or something more sophisticated, like for example this

Transaction@182f0db={
    amount: "100.88",
    creditCard: CreditCard@152ffda={
        cardType: "AMEX".
        customerId: "123",
        subscriptions: []
    }
}

What should be a date/time format of a string representation? @uwemaurer Is there some subset of classes in the library that should have toString() method, or you rather thought about adding it to all of them?

uwemaurer commented 6 years ago

Just the IDE generated toString() implementation is fine. For the date format you can just call the date objects toString() method.

The response classes which are returned by the API are most important to have a toString() method.

kmichalak commented 6 years ago

If such implementation of toString() method is fine for you, I'll prepare some PR in a couple of days.

jaypatel512 commented 6 years ago

Hey all !

Just a quick update. We have taken this into consideration. We are fancying the idea of using lombok library to do the heavy lifting for us. Currently, the idea is to use it for toString method only, but hopefully more in future, if things go out well. We are still testing a bunch of changes, and making sure it will not cause a breaking change to us. We will keep you posted.

kmichalak commented 6 years ago

Thanks for notification. As this is curretnly in progress, then no additional changes/pull requests will be needed from my side?

jaypatel512 commented 6 years ago

A quick update. We have not forgotten you. We are running into issues using lombok with Java 7. We are working our way trying to fix that, and making a lot of new features from lombok available for our library. Apologies for the delay.

atuttle commented 3 years ago

I am very interested in this feature (and/or #80).

I am using Braintree in a language that runs on top of Java, but I am not a java developer so unfortunately I can't offer any hope of a PR. We need to store the charge response in our database for record-keeping, but the SDK returns java objects that are not serializable. The toString() method simply prints the class name, e.g. com.braintreegateway.Result@1c1538d2 and nothing more.

I can spelunk through the response methods and cobble together my own native-data representation of the result and then serialize that, but the number of possibilities that would need to be accounted for in the variations of response contents would be very high (for example, responses can be significantly different between charges made with cc/venmo/paypal/google pay/apple pay).

hollabaq86 commented 2 years ago

for internal notekeeping, ticket 631