diff --git a/examples/Arduino Yun/test/Test.ino b/examples/Arduino Yun/test/Test.ino index 2225078..16d3888 100644 --- a/examples/Arduino Yun/test/Test.ino +++ b/examples/Arduino Yun/test/Test.ino @@ -44,8 +44,10 @@ void basicObjectTest() { del.setClassName("Temperature"); del.setObjectId(objectId); ParseResponse delResponse = del.send(); - String expectedResp = "{}\n"; - assert(expectedResp.equals(delResponse.getJSONBody())); + String expectedResp = "{}"; + String actualResp = String(delResponse.getJSONBody()); + actualResp.trim(); + assert(expectedResp.equals(actualResp)); delResponse.close(); Serial.println("test passed\n"); @@ -70,6 +72,20 @@ void objectDataTypesTest() { void queryTest() { Serial.println("query test"); + ParseObjectCreate create1; + create1.setClassName("Temperature"); + create1.add("temperature", 88.0); + create1.add("leverDown", true); + ParseResponse createResponse = create1.send(); + createResponse.close(); + + ParseObjectCreate create2; + create2.setClassName("Temperature"); + create2.add("temperature", 88.0); + create2.add("leverDown", false); + createResponse = create2.send(); + createResponse.close(); + ParseQuery query; query.setClassName("Temperature"); query.whereEqualTo("temperature", 88); @@ -96,12 +112,13 @@ void setup() { Bridge.begin(); // Initialize Serial - Serial.begin(9600); + Serial.begin(115200); while (!Serial); // wait for a serial connection // Initialize Parse Parse.begin("", ""); + Parse.setServerURL("https://my.server.somewhere/parse"); } void loop() { diff --git a/src/internal/ParseClient.h b/src/internal/ParseClient.h index 8819ce7..b0e856b 100644 --- a/src/internal/ParseClient.h +++ b/src/internal/ParseClient.h @@ -82,6 +82,17 @@ class ParseClient { */ void begin(const char *applicationId, const char *clientKey); + /*! \fn void setServerURL(const char *serverURL) + * \brief Set the installation object id for this client. + * + * Set the custom server url for this client. This needs to be called + * API request. + * + * \param serverURL The server URL to which client should connect. + * + */ + void setServerURL(const char *serverURL); + /*! \fn void setInstallationId(const char *installationId) * \brief Set the installation object id for this client. * @@ -146,7 +157,7 @@ class ParseClient { * \brief Directly call REST API in Parse. * * \param httpVerb - GET/DELETE/PUT/POST - * \param httpPath - the endpoint of REST API e.g. /1/installations + * \param httpPath - the endpoint of REST API e.g. /installations * \param requestBody - http request body in json format, leave it as "" for DELTE/GET requests * \param urlParams - leave it as "" unless to perform a Parse query, * use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2 @@ -160,7 +171,7 @@ class ParseClient { * \brief Directly call REST API in Parse. * * \param httpVerb - GET/DELETE/PUT/POST - * \param httpPath - the endpoint of REST API e.g. /1/installations + * \param httpPath - the endpoint of REST API e.g. /installations * \param requestBody - http request body in json format, leave it as "" for DELTE/GET requests * \param urlParams - leave it as "" unless to perform a Parse query, * use it to specify query condition e.g. where={"KEY1"":VALUE1}&limit=10&keys=KEY1,KEY2 diff --git a/src/internal/ParseRequest.cpp b/src/internal/ParseRequest.cpp index e9eaf84..9634995 100644 --- a/src/internal/ParseRequest.cpp +++ b/src/internal/ParseRequest.cpp @@ -24,7 +24,7 @@ ParseRequest::ParseRequest() { requestBody = "{"; - httpPath = "/1/"; + httpPath = "/"; isBodySet = false; } diff --git a/src/internal/yun/ParseClient.cpp b/src/internal/yun/ParseClient.cpp index 9d02935..bf0e7f9 100644 --- a/src/internal/yun/ParseClient.cpp +++ b/src/internal/yun/ParseClient.cpp @@ -49,6 +49,12 @@ void ParseClient::begin(const char *applicationId, const char *clientKey) { } } +void ParseClient::setServerURL(const char *serverURL) { + if (serverURL) { + Bridge.put("serverURL", serverURL); + } +} + void ParseClient::setInstallationId(const char *installationId) { strncpy(this->installationId, installationId, sizeof(this->installationId)); if (installationId) {