Skip to content

Commit 6a1063f

Browse files
committed
Make improvements to the code
1 parent f623825 commit 6a1063f

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

SlicingDice.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22

33

44
SlicingDice::SlicingDice(String apiUserKey) {
5-
host = "api.slicingdice.com";
6-
port = 80;
7-
apiKey = apiUserKey;
8-
useProduction = true;
5+
construct(apiUserKey, "api.slicingdice.com", 80, true);
96
}
107

118
SlicingDice::SlicingDice(String apiUserKey, const char* customHost) {
12-
host = customHost;
13-
port = 80;
14-
apiKey = apiUserKey;
15-
useProduction = true;
9+
construct(apiUserKey, customHost, 80, true);
1610
}
1711

1812
SlicingDice::SlicingDice(String apiUserKey, const char* customHost, int customPort) {
19-
host = customHost;
20-
port = customPort;
21-
apiKey = apiUserKey;
22-
useProduction = true;
13+
construct(apiUserKey, customHost, customPort, true);
2314
}
2415

2516
SlicingDice::SlicingDice(String apiUserKey, const char* customHost, int customPort, boolean production) {
17+
construct(apiUserKey, customHost, customPort, production);
18+
}
19+
20+
void SlicingDice::construct(String apiUserKey, const char* customHost, int customPort, boolean production) {
2621
host = customHost;
2722
port = customPort;
2823
apiKey = apiUserKey;
@@ -56,7 +51,6 @@ void SlicingDice::makeRequest(const char* query){
5651
}
5752

5853
client.println("POST /v1/" + testEndPoint + "index HTTP/1.1");
59-
Serial.println("POST /v1/" + testEndPoint + "index HTTP/1.1");
6054
client.println(F("Content-Type: application/json"));
6155
String hostString = String(host);
6256
client.println("Host: " + hostString);

SlicingDice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class SlicingDice {
1818

1919
private:
2020
void makeRequest(const char* query);
21+
void construct(String apiUserKey, const char* customHost, int customPort, boolean production);
2122
void readResponse();
2223

2324
String apiKey;

0 commit comments

Comments
 (0)