jmulford-bw / Java-V2-Messaging-SDK

0 stars 1 forks source link

Use a builder to send a message #9

Open fuchsnj opened 5 years ago

fuchsnj commented 5 years ago

A builder should be used to send a message since there are a ton of options.

The end result should look something like

BandwidthMessageClient client; = //initialized somewhere else
client.sendMessageBuilder()
   .from("+13334445555") //required
   .to("+12223334444") //to can take a single number, or any Java Collection
   .text("asdfasdf") // optional (MMS doesn't require text)
   .applicationId("a-asdfasd") //required
   .media("http://example.com")// overloaded to take several different inputs. String/URL/URI / Collection
   .tag("some string")//optional
   .send()

Assuming this is a synchronous request, send() should return a parsed response object (Not a String as it currently is). You can get most of this for "free" by using an Immutables object.

https://immutables.github.io/