-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from electricimp/develop
Develop
- Loading branch information
Showing
10 changed files
with
1,194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.DS_Store | ||
*.wrench | ||
*.out | ||
.build_api_key.json | ||
*.swp | ||
src/vars.nut | ||
.impconfig | ||
agent.out.nut | ||
device.out.nut | ||
**/builds | ||
utilities.nut | ||
finished |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"modelId": "w5xn66HzrlkK" /* Test Model C */, | ||
"devices": [ | ||
"20000c2a690a2944" /* C */ | ||
], | ||
"agentFile": false, | ||
"deviceFile": false, | ||
"stopOnFailure": false, | ||
"timeout": 30, | ||
"tests": [ | ||
"*.test.nut", | ||
"tests/**/*.test.nut" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- '5.5' | ||
|
||
before_script: | ||
- npm i -g imptest@latest | ||
|
||
script: | ||
- imptest test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// MIT License | ||
// | ||
// Copyright 2017 Electric Imp | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO | ||
// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES | ||
// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
const AWSSNS_ACTION_CONFIRM_SUBSCRIPTION = "ConfirmSubscription"; | ||
const AWSSNS_ACTION_LIST_SUBSCRIPTIONS = "ListSubscriptions"; | ||
const AWSSNS_ACTION_LIST_SUBSCRIPTIONS_BY_TOPIC = "ListSubscriptionsByTopic"; | ||
const AWSSNS_ACTION_LIST_TOPICS = "ListTopics"; | ||
const AWSSNS_ACTION_PUBLISH = "Publish"; | ||
const AWSSNS_ACTION_SUBSCRIBE = "Subscribe"; | ||
const AWSSNS_ACTION_UNSUBSCRIBE = "Unsubscribe"; | ||
|
||
class AWSSNS { | ||
|
||
static VERSION = "1.0.0"; | ||
|
||
_awsRequest = null; | ||
|
||
// Parameters: | ||
// region AWS region | ||
// accessKeyId AWS access key Id | ||
// secretAccessKey AWS secret access key | ||
constructor(region, accessKeyId, secretAccessKey) { | ||
if ("AWSRequestV4" in getroottable()) { | ||
_awsRequest = AWSRequestV4("sns", region, accessKeyId, secretAccessKey); | ||
} else { | ||
throw("This class requires AWSRequestV4 - please make sure it is loaded."); | ||
} | ||
} | ||
|
||
// Performs the specified action | ||
// | ||
// Parameters: | ||
// params table of parameters to be sent as part of the request | ||
// cb callback function to be called when response received from aws | ||
function action(action, params, cb) { | ||
local headers = {"Content-Type": "application/x-www-form-urlencoded"}; | ||
local body = { | ||
"Action": action, | ||
"Version": "2010-03-31" | ||
}; | ||
foreach (k,v in params) { | ||
body[k] <- v; | ||
} | ||
_awsRequest.post("/", headers, http.urlencode(body), cb); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MIT License | ||
|
||
Copyright 2017 Electric Imp | ||
|
||
SPDX-License-Identifier: MIT | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO | ||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES | ||
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
Oops, something went wrong.