Skip to content

Commit

Permalink
Merge pull request #2 from electricimp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Pavel Petroshenko authored Oct 6, 2017
2 parents ba32f58 + 2cc95be commit 99b90f4
Show file tree
Hide file tree
Showing 10 changed files with 1,194 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
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
14 changes: 14 additions & 0 deletions .imptest
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"
]
}
10 changes: 10 additions & 0 deletions .travis.yml
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
67 changes: 67 additions & 0 deletions AWSSNS.agent.lib.nut
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);
}
}
23 changes: 23 additions & 0 deletions LICENSE
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.
Loading

0 comments on commit 99b90f4

Please sign in to comment.