Skip to content

Commit f623825

Browse files
committed
Make changes according to review
1 parent 1101ef6 commit f623825

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

SlicingDice.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ SlicingDice::SlicingDice(String apiUserKey) {
55
host = "api.slicingdice.com";
66
port = 80;
77
apiKey = apiUserKey;
8-
test = 0;
8+
useProduction = true;
99
}
1010

1111
SlicingDice::SlicingDice(String apiUserKey, const char* customHost) {
1212
host = customHost;
1313
port = 80;
1414
apiKey = apiUserKey;
15-
test = 0;
15+
useProduction = true;
1616
}
1717

1818
SlicingDice::SlicingDice(String apiUserKey, const char* customHost, int customPort) {
1919
host = customHost;
2020
port = customPort;
2121
apiKey = apiUserKey;
22-
test = 0;
22+
useProduction = true;
2323
}
2424

25-
SlicingDice::SlicingDice(String apiUserKey, const char* customHost, int customPort, int customTest) {
25+
SlicingDice::SlicingDice(String apiUserKey, const char* customHost, int customPort, boolean production) {
2626
host = customHost;
2727
port = customPort;
2828
apiKey = apiUserKey;
29-
test = customTest;
29+
useProduction = production;
3030
}
3131

3232
/* Index data on Slicing Dice API
@@ -51,11 +51,12 @@ void SlicingDice::makeRequest(const char* query){
5151

5252
String testEndPoint = String("");
5353

54-
if (test == 1) {
54+
if (!useProduction) {
5555
testEndPoint = String("test/");
5656
}
5757

5858
client.println("POST /v1/" + testEndPoint + "index HTTP/1.1");
59+
Serial.println("POST /v1/" + testEndPoint + "index HTTP/1.1");
5960
client.println(F("Content-Type: application/json"));
6061
String hostString = String(host);
6162
client.println("Host: " + hostString);

SlicingDice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SlicingDice {
1010
SlicingDice(String apiUserKey);
1111
SlicingDice(String apiUserKey, const char* customHost);
1212
SlicingDice(String apiUserKey, const char* customHost, int customPort);
13-
SlicingDice(String apiUserKey, const char* customHost, int customPort, int customTest);
13+
SlicingDice(String apiUserKey, const char* customHost, int customPort, boolean production);
1414

1515
void index(JsonObject& query);
1616
int statusCode;
@@ -23,6 +23,6 @@ class SlicingDice {
2323
String apiKey;
2424
const char* host;
2525
int port;
26-
int test;
26+
boolean useProduction;
2727
EthernetClient client;
2828
};

tests_and_examples/Simple.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#include <ArduinoJson.h>
33

44
// Demo API key, if you need a new demo API key visit: https://panel.slicingdice.com/docs/#api-details-api-connection-api-keys-demo-key
5-
String apiKey = String("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vNTZtIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MjE3LCJjbGllbnRfaWQiOjEwfQ.rKHWahhcTN8Hvhns8-O2_KwjC_b3SFHd3kqZLyDMrfc");
5+
String apiKey = String("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfX3NhbHQiOiJkZW1vMThtIiwicGVybWlzc2lvbl9sZXZlbCI6MywicHJvamVjdF9pZCI6MTc5LCJjbGllbnRfaWQiOjEwfQ.OTb6REW9JtYF9wVUZhXajq4wheU5ULNbM5iEmMCYhhM");
66
const char* host = "api.slicingdice.com";
77
int port = 80;
8-
// test = 1 indicates that will use test end-point, 0 indicates will use production end-point
9-
int test = 1;
10-
SlicingDice sd = SlicingDice(apiKey, host, port, test);
8+
// if false will use test end-point, otherwise production end-point
9+
int useProduction = false;
10+
SlicingDice sd = SlicingDice(apiKey, host, port, useProduction);
1111

1212
void setup() {
1313
// Open serial communications and wait for port to open:

0 commit comments

Comments
 (0)