Skip to content

Commit c8b5277

Browse files
Rename index() to insert()
1 parent 4ecc253 commit c8b5277

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44
### Added
5+
- CLIENT: Rename method index() to insert()
56
- CLIENT: Create requester and main method
67

78
## [0.3] - 2016-09-15

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Official Arduino client for [SlicingDice](http://www.slicingdice.com/), Data War
88

99
If you are new to SlicingDice, check our [quickstart guide](http://panel.slicingdice.com/docs/#quickstart-guide) and learn to use it in 15 minutes.
1010

11-
Please refer to the [SlicingDice official documentation](http://panel.slicingdice.com/docs/) for more information on [analytics databases](http://panel.slicingdice.com/docs/#analytics-concepts), [data modeling](http://panel.slicingdice.com/docs/#data-modeling), [indexing](http://panel.slicingdice.com/docs/#data-indexing), [querying](http://panel.slicingdice.com/docs/#data-querying), [limitations](http://panel.slicingdice.com/docs/#current-slicingdice-limitations) and [API details](http://panel.slicingdice.com/docs/#api-details).
11+
Please refer to the [SlicingDice official documentation](http://panel.slicingdice.com/docs/) for more information on [analytics databases](http://panel.slicingdice.com/docs/#analytics-concepts), [data modeling](http://panel.slicingdice.com/docs/#data-modeling), [inserting](http://panel.slicingdice.com/docs/#data-inserting), [querying](http://panel.slicingdice.com/docs/#data-querying), [limitations](http://panel.slicingdice.com/docs/#current-slicingdice-limitations) and [API details](http://panel.slicingdice.com/docs/#api-details).
1212

1313
### Note
1414

15-
SlicingDice's Arduino client currently supports only indexing commands. Let us
15+
SlicingDice's Arduino client currently supports only data insert commands. Let us
1616
know if you application requires Arduino to query data from SlicingDice
1717
and we'll make sure to add this feature to our backlog.
1818

@@ -47,17 +47,17 @@ void setup() {
4747
Ethernet.begin(mac, ip, dns, gateway, subnet);
4848
}
4949

50-
// Send an indexation command to Slicing Dice API and print the result
50+
// Send an insert command to Slicing Dice API and print the result
5151
void loop() {
5252
StaticJsonBuffer<200> jsonBuffer;
53-
JsonObject& queryIndex = jsonBuffer.createObject();
54-
JsonObject& nestedQueryIndex = queryIndex.createNestedObject("user1@slicingdice.com");
55-
nestedQueryIndex["age"] = 22;
53+
JsonObject& data = jsonBuffer.createObject();
54+
JsonObject& nestedInsertion = data.createNestedObject("user1@slicingdice.com");
55+
nestedInsertion["age"] = 22;
5656
// Auto create non-existent fields
57-
queryIndex["auto-create-fields"] = true;
57+
data["auto-create-fields"] = true;
5858

59-
// Index object
60-
sd.index(queryIndex);
59+
// Insert object
60+
sd.insert(data);
6161

6262
// Print result for debugging
6363
Serial.print("Status code: ");
@@ -72,12 +72,12 @@ Whether you want to test the client installation or simply check more examples o
7272

7373
## Reference
7474

75-
`SlicingDice` encapsulates logic for sending requests to the [index endpoint](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-index).
75+
`SlicingDice` encapsulates logic for sending requests to the [insert endpoint](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-insert).
7676

7777
### Attributes
7878

79-
* `statusCode (int)` - HTTP status code after indexing to SlicingDice. Should be `200` in ordinary circumstances or one of the HTTP requests defined at the [API errors](http://panel.slicingdice.com/docs/#api-details-api-errors) section.
80-
* `response (String)` - Response after indexing data. Useful for debugging purposes.
79+
* `statusCode (int)` - HTTP status code after inserting to SlicingDice. Should be `200` in ordinary circumstances or one of the HTTP requests defined at the [API errors](http://panel.slicingdice.com/docs/#api-details-api-errors) section.
80+
* `response (String)` - Response after inserting data. Useful for debugging purposes.
8181

8282
### Constructors
8383

@@ -87,8 +87,8 @@ Whether you want to test the client installation or simply check more examples o
8787
* `host (const char*)` - (Default: api.slicingdice.com) [Connection endpoint](http://panel.slicingdice.com/docs/#api-details-api-connection-connection-endpoints) to use when generating requests to SlicingDice.
8888
* `port (int)` - (Default: 80) Port to connect to when generating requests. Particularly useful when connect to `http://localhost`.
8989

90-
### `void index(JsonObject& query)`
91-
Index data to existing entities or create new entities, if necessary. This method corresponds to a [POST request at /index](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-index).
90+
### `void insert(JsonObject& query)`
91+
Insert data to existing entities or create new entities, if necessary. This method corresponds to a [POST request at /insert](http://panel.slicingdice.com/docs/#api-details-api-endpoints-post-insert).
9292

9393
#### Request example
9494

@@ -117,17 +117,17 @@ void setup() {
117117
Ethernet.begin(mac, ip, dns, gateway, subnet);
118118
}
119119

120-
// Send an indexation command to Slicing Dice API and print the result
120+
// Send an insertation command to Slicing Dice API and print the result
121121
void loop() {
122122
StaticJsonBuffer<200> jsonBuffer;
123-
JsonObject& queryIndex = jsonBuffer.createObject();
124-
JsonObject& nestedQueryIndex = queryIndex.createNestedObject("user1@slicingdice.com");
125-
nestedQueryIndex["age"] = 22;
123+
JsonObject& data = jsonBuffer.createObject();
124+
JsonObject& nestedInsertion = data.createNestedObject("user1@slicingdice.com");
125+
nestedInsertion["age"] = 22;
126126
// Auto create non-existent fields
127-
queryIndex["auto-create-fields"] = true;
127+
data["auto-create-fields"] = true;
128128

129-
// Index object
130-
sd.index(queryIndex);
129+
// Insert object
130+
sd.insert(data);
131131

132132
// Print result for debugging
133133
Serial.print("Status code: ");
@@ -142,8 +142,8 @@ void loop() {
142142
Status code: 200
143143
{
144144
"status": "success",
145-
"indexed-entities": 1,
146-
"indexed-fields": 1,
145+
"inserted-entities": 1,
146+
"inserted-fields": 1,
147147
"took": 0.023
148148
}
149149
```

SlicingDice.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ void SlicingDice::construct(String apiUserKey, const char* customHost, int custo
1111
useProduction = production;
1212
}
1313

14-
/* Index data on Slicing Dice API
14+
/* Insert data on Slicing Dice API
1515
*
1616
* query - the query to send to Slicing Dice API
1717
*/
18-
void SlicingDice::index(JsonObject& query) {
18+
void SlicingDice::insert(JsonObject& query) {
1919
char queryConverted[query.measureLength() + 1];
2020
query.printTo(queryConverted, sizeof(queryConverted));
2121
makeRequest(queryConverted);
@@ -37,7 +37,7 @@ void SlicingDice::makeRequest(const char* query){
3737
testEndPoint = String("test/");
3838
}
3939

40-
client.println("POST /v1/" + testEndPoint + "index HTTP/1.1");
40+
client.println("POST /v1/" + testEndPoint + "insert HTTP/1.1");
4141
client.println(F("Content-Type: application/json"));
4242
String hostString = String(host);
4343
client.println("Host: " + hostString);

SlicingDice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SlicingDice {
99
public:
1010
SlicingDice(String apiUserKey, boolean useProduction = false, const char* customHost = "api.slicingdice.com", int customPort=80);
1111

12-
void index(JsonObject& query);
12+
void insert(JsonObject& data);
1313
int statusCode;
1414
String response;
1515

tests_and_examples/Simple.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ void setup() {
2222
Ethernet.begin(mac, ip, dns, gateway, subnet);
2323
}
2424

25-
// Send an indexation command to Slicing Dice API and print the result
25+
// Send an insert command to Slicing Dice API and print the result
2626
void loop() {
2727
StaticJsonBuffer<200> jsonBuffer;
28-
JsonObject& queryIndex = jsonBuffer.createObject();
29-
JsonObject& nestedQueryIndex = queryIndex.createNestedObject("user1@slicingdice.com");
30-
nestedQueryIndex["age"] = 22;
31-
queryIndex["auto-create-fields"] = true;
32-
sd.index(queryIndex);
28+
JsonObject& insertion = jsonBuffer.createObject();
29+
JsonObject& nestedQueryInsertion = insertion.createNestedObject("user1@slicingdice.com");
30+
nestedQueryInsertion["age"] = 22;
31+
insertion["auto-create-fields"] = true;
32+
sd.insert(insertion);
3333
Serial.print("Status code: ");
3434
Serial.println(sd.statusCode);
3535
Serial.println(sd.response);

0 commit comments

Comments
 (0)