11#include " SlicingDice.h"
22
33
4- SlicingDice::SlicingDice (const char * apiUserKey) {
4+ SlicingDice::SlicingDice (String apiUserKey) {
55 host = " api.slicingdice.com" ;
66 port = 80 ;
77 apiKey = apiUserKey;
88 test = 0 ;
99}
1010
11- SlicingDice::SlicingDice (const char * apiUserKey, const char * customHost) {
11+ SlicingDice::SlicingDice (String apiUserKey, const char * customHost) {
1212 host = customHost;
1313 port = 80 ;
1414 apiKey = apiUserKey;
1515 test = 0 ;
1616}
1717
18- SlicingDice::SlicingDice (const char * apiUserKey, const char * customHost, int customPort) {
18+ SlicingDice::SlicingDice (String apiUserKey, const char * customHost, int customPort) {
1919 host = customHost;
2020 port = customPort;
2121 apiKey = apiUserKey;
2222 test = 0 ;
2323}
2424
25- SlicingDice::SlicingDice (const char * apiUserKey, const char * customHost, int customPort, int customTest) {
25+ SlicingDice::SlicingDice (String apiUserKey, const char * customHost, int customPort, int customTest) {
2626 host = customHost;
2727 port = customPort;
2828 apiKey = apiUserKey;
@@ -49,19 +49,21 @@ void SlicingDice::makeRequest(const char* query){
4949 client.connect (host, port);
5050 }
5151
52- client.print (F (" POST /v1/" ));
52+ String testEndPoint = String (" " );
53+
5354 if (test == 1 ) {
54- client. print (" test/" );
55+ testEndPoint = String (" test/" );
5556 }
56- client.println (F (" index/ HTTP/1.1" ));
57+
58+ client.println (" POST /v1/" + testEndPoint + " index HTTP/1.1" );
5759 client.println (F (" Content-Type: application/json" ));
58- client.print (F (" Authorization: " ));
59- client.println (apiKey);
60+ client.println (" Authorization: " + apiKey);
6061 client.println (F (" Connection: close" ));
61- client.print (F (" Content-Length: " ));
62- client.println (strlen (query));
62+
63+ String actualLength = String (strlen (query));
64+ client.println (" Content-Length: " + actualLength);
6365 client.println ();
64- client.print (query);
66+ client.println (query);
6567 readResponse ();
6668 client.stop ();
6769}
0 commit comments