losant_rest 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rbenv-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +237 -0
- data/Rakefile +12 -0
- data/docs/_schemas.md +6348 -0
- data/docs/accessToken.md +107 -0
- data/docs/accessTokens.md +68 -0
- data/docs/application.md +107 -0
- data/docs/applicationKey.md +115 -0
- data/docs/applicationKeys.md +81 -0
- data/docs/applications.md +76 -0
- data/docs/auth.md +104 -0
- data/docs/dashboard.md +107 -0
- data/docs/dashboards.md +76 -0
- data/docs/data.md +78 -0
- data/docs/device.md +300 -0
- data/docs/deviceRecipe.md +152 -0
- data/docs/deviceRecipes.md +81 -0
- data/docs/devices.md +117 -0
- data/docs/event.md +115 -0
- data/docs/events.md +153 -0
- data/docs/flow.md +261 -0
- data/docs/flows.md +81 -0
- data/docs/me.md +312 -0
- data/docs/org.md +279 -0
- data/docs/orgs.md +75 -0
- data/docs/webhook.md +115 -0
- data/docs/webhooks.md +81 -0
- data/examples/auth.rb +32 -0
- data/examples/list_devices.rb +45 -0
- data/lib/losant_rest/access_token.rb +122 -0
- data/lib/losant_rest/access_tokens.rb +80 -0
- data/lib/losant_rest/application.rb +122 -0
- data/lib/losant_rest/application_key.rb +128 -0
- data/lib/losant_rest/application_keys.rb +98 -0
- data/lib/losant_rest/applications.rb +94 -0
- data/lib/losant_rest/auth.rb +122 -0
- data/lib/losant_rest/client.rb +132 -0
- data/lib/losant_rest/dashboard.rb +122 -0
- data/lib/losant_rest/dashboards.rb +94 -0
- data/lib/losant_rest/data.rb +89 -0
- data/lib/losant_rest/device.rb +336 -0
- data/lib/losant_rest/device_recipe.rb +169 -0
- data/lib/losant_rest/device_recipes.rb +98 -0
- data/lib/losant_rest/devices.rb +139 -0
- data/lib/losant_rest/error.rb +12 -0
- data/lib/losant_rest/event.rb +128 -0
- data/lib/losant_rest/events.rb +183 -0
- data/lib/losant_rest/flow.rb +290 -0
- data/lib/losant_rest/flows.rb +98 -0
- data/lib/losant_rest/me.rb +362 -0
- data/lib/losant_rest/org.rb +314 -0
- data/lib/losant_rest/orgs.rb +92 -0
- data/lib/losant_rest/utils.rb +22 -0
- data/lib/losant_rest/version.rb +3 -0
- data/lib/losant_rest/webhook.rb +128 -0
- data/lib/losant_rest/webhooks.rb +98 -0
- data/lib/losant_rest.rb +43 -0
- data/losant_rest.gemspec +25 -0
- data/schemas/accessToken.json +52 -0
- data/schemas/accessTokenPatch.json +19 -0
- data/schemas/accessTokenPost.json +32 -0
- data/schemas/accessTokens.json +65 -0
- data/schemas/application.json +65 -0
- data/schemas/applicationKey.json +68 -0
- data/schemas/applicationKeyPatch.json +18 -0
- data/schemas/applicationKeyPost.json +36 -0
- data/schemas/applicationKeys.json +110 -0
- data/schemas/applicationPatch.json +16 -0
- data/schemas/applicationPost.json +23 -0
- data/schemas/applications.json +103 -0
- data/schemas/authedDevice.json +34 -0
- data/schemas/authedUser.json +18 -0
- data/schemas/dashboard.json +95 -0
- data/schemas/dashboardPatch.json +69 -0
- data/schemas/dashboardPost.json +76 -0
- data/schemas/dashboards.json +133 -0
- data/schemas/device.json +113 -0
- data/schemas/deviceCommand.json +20 -0
- data/schemas/deviceCommands.json +25 -0
- data/schemas/deviceCredentials.json +22 -0
- data/schemas/deviceLog.json +28 -0
- data/schemas/devicePatch.json +78 -0
- data/schemas/devicePost.json +81 -0
- data/schemas/deviceRecipe.json +106 -0
- data/schemas/deviceRecipeBulkCreate.json +15 -0
- data/schemas/deviceRecipeBulkCreatePost.json +19 -0
- data/schemas/deviceRecipePatch.json +87 -0
- data/schemas/deviceRecipePost.json +90 -0
- data/schemas/deviceRecipes.json +148 -0
- data/schemas/deviceState.json +30 -0
- data/schemas/deviceStates.json +35 -0
- data/schemas/deviceTagFilter.json +19 -0
- data/schemas/devices.json +155 -0
- data/schemas/disableTwoFactorAuth.json +20 -0
- data/schemas/enableTwoFactorAuth.json +21 -0
- data/schemas/error.json +12 -0
- data/schemas/event.json +115 -0
- data/schemas/eventPatch.json +20 -0
- data/schemas/eventPost.json +39 -0
- data/schemas/events.json +165 -0
- data/schemas/flow.json +137 -0
- data/schemas/flowLog.json +46 -0
- data/schemas/flowPatch.json +107 -0
- data/schemas/flowPost.json +110 -0
- data/schemas/flowStorageEntries.json +7 -0
- data/schemas/flowStorageEntry.json +16 -0
- data/schemas/flows.json +179 -0
- data/schemas/githubLogin.json +14 -0
- data/schemas/lastValueData.json +34 -0
- data/schemas/lastValueQuery.json +36 -0
- data/schemas/me.json +173 -0
- data/schemas/mePatch.json +43 -0
- data/schemas/multiDeviceCommand.json +45 -0
- data/schemas/org.json +81 -0
- data/schemas/orgInvitePost.json +24 -0
- data/schemas/orgInvites.json +36 -0
- data/schemas/orgMemberPatch.json +23 -0
- data/schemas/orgPatch.json +16 -0
- data/schemas/orgPost.json +19 -0
- data/schemas/orgs.json +119 -0
- data/schemas/recentItem.json +27 -0
- data/schemas/recentItemList.json +36 -0
- data/schemas/success.json +12 -0
- data/schemas/timeSeriesData.json +89 -0
- data/schemas/timeSeriesQuery.json +64 -0
- data/schemas/userCredentials.json +25 -0
- data/schemas/virtualButtonPress.json +14 -0
- data/schemas/webhook.json +52 -0
- data/schemas/webhookPatch.json +29 -0
- data/schemas/webhookPost.json +32 -0
- data/schemas/webhooks.json +94 -0
- data/test/basic_test.rb +67 -0
- data/test/test_helper.rb +14 -0
- metadata +239 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c00f2713b0820ca3b059e735ecfacdbbf3587f80
|
|
4
|
+
data.tar.gz: 368a50fbd34057937155bcbfbcd0b93374dc948f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c9f795186f951323494463a3034016ceaf27431e7471f0b712bcf7f9305a673ac3cc7d61d1562a905fe81d695d64fe8287e7faf78b039c760e3916a1e1bcaad7
|
|
7
|
+
data.tar.gz: 7ccb33ee4592955cde6d094e01a2a7bba6aa50b32b36a65bd22be538d66d6491f7aaac0b48e38b13300949f208408c85b88f1983f36fdb4d0960c67cd8bcb18d
|
data/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
*~
|
|
2
|
+
\#*
|
|
3
|
+
.\#*
|
|
4
|
+
.DS_Store
|
|
5
|
+
*_flymake.*
|
|
6
|
+
*.LCK
|
|
7
|
+
.bundle
|
|
8
|
+
vendor/bundle
|
|
9
|
+
bin
|
|
10
|
+
*.gem
|
|
11
|
+
*.rbc
|
|
12
|
+
.bundle
|
|
13
|
+
.config
|
|
14
|
+
.yardoc
|
|
15
|
+
_yardoc
|
|
16
|
+
coverage
|
|
17
|
+
pkg
|
|
18
|
+
rdoc
|
|
19
|
+
spec/reports
|
|
20
|
+
test/tmp
|
|
21
|
+
test/version_tmp
|
|
22
|
+
tmp
|
|
23
|
+
Gemfile.lock
|
data/.rbenv-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Losant IoT, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Losant Ruby REST API Client
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/Losant/losant-rest-ruby)
|
|
4
|
+
|
|
5
|
+
The [Losant](https://www.losant.com>) REST API client provides a simple way to
|
|
6
|
+
use the comprehensive Losant API. You can authenticate either as a Losant
|
|
7
|
+
device or with your user account, and have access to all the functionality
|
|
8
|
+
of the Losant platform.
|
|
9
|
+
|
|
10
|
+
This client works with Ruby 2.1 and higher. It uses
|
|
11
|
+
[HTTParty](https://github.com/jnunemaker/httparty) under the
|
|
12
|
+
covers for the actual HTTP communication.
|
|
13
|
+
|
|
14
|
+
<br/>
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
The latest stable version is available in RubyGems and can be installed using
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
gem install losant_rest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
<br/>
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
Below is a high-level example of using the Losant Ruby REST API client to
|
|
29
|
+
authenticate against the Losant Platform and report state for a device.
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require "losant_rest"
|
|
33
|
+
|
|
34
|
+
response = LosantRest.auth.authenticate_device(credentials: {
|
|
35
|
+
deviceId: "my-device-id",
|
|
36
|
+
key: "my-app-access-key",
|
|
37
|
+
secret: "my-app-access-secret"
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
LosantRest.auth_token = response["token"]
|
|
41
|
+
app_id = response["applicationId"]
|
|
42
|
+
|
|
43
|
+
state = { data: { temperature: AnalogSensor.read } }
|
|
44
|
+
response = LosantRest.device.send_state(deviceId: "my-device-id",
|
|
45
|
+
applicationId: app_id, deviceState: state)
|
|
46
|
+
|
|
47
|
+
puts response
|
|
48
|
+
# { "success" => true }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
<br/>
|
|
52
|
+
|
|
53
|
+
## API Documentation
|
|
54
|
+
|
|
55
|
+
### LosantRest
|
|
56
|
+
|
|
57
|
+
LosantRest is the wrapping module, but it also acts as a singleton [Client](#losantrestclient)
|
|
58
|
+
instance. So if you only need a single client instance, you do not need to
|
|
59
|
+
instantiate one yourself - the LosantRest module will act exactly like an
|
|
60
|
+
instance of LosantRest::Client.
|
|
61
|
+
|
|
62
|
+
<br/>
|
|
63
|
+
|
|
64
|
+
### LosantRest::Client
|
|
65
|
+
|
|
66
|
+
A client is a single api instance. By default, it is unauthenticated, but can
|
|
67
|
+
be given an access token to perform authenticated requests.
|
|
68
|
+
|
|
69
|
+
#### Initializer
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
LosantRest::Client.new(auth_token: nil, url: "https://api.losant.com")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The ``Client()`` initializer takes the following arguments:
|
|
76
|
+
|
|
77
|
+
* auth_token
|
|
78
|
+
The access token to be used for authentication - by default there is no
|
|
79
|
+
access token. An access token can be acquired through either of the
|
|
80
|
+
[Auth](docs/auth.md) methods.
|
|
81
|
+
|
|
82
|
+
* url
|
|
83
|
+
The url of the Losant API - by default <https://api.losant.com>.
|
|
84
|
+
|
|
85
|
+
#### Accessors
|
|
86
|
+
|
|
87
|
+
* auth_token
|
|
88
|
+
The auth token can be accessed or changed after Client creation
|
|
89
|
+
through this accessor.
|
|
90
|
+
|
|
91
|
+
* url
|
|
92
|
+
The api base url can be accessed or changed after Client creation
|
|
93
|
+
through this accessor.
|
|
94
|
+
|
|
95
|
+
#### Resources
|
|
96
|
+
|
|
97
|
+
Each of the following is a method on the client object, and returns a wrapper
|
|
98
|
+
for the actions against that particular resource. See each resource
|
|
99
|
+
documentation file for more information.
|
|
100
|
+
|
|
101
|
+
* [application_key](docs/applicationKey.md)
|
|
102
|
+
Contains all the actions that can be performed against a single
|
|
103
|
+
[Application Key](https://docs.losant.com/applications/access-keys/) -
|
|
104
|
+
for instance, getting info on a single key or revoking a key.
|
|
105
|
+
|
|
106
|
+
* [application_keys](docs/applicationKeys.md)
|
|
107
|
+
Contains all of the actions that can be performed against the collection of
|
|
108
|
+
[Application Keys](https://docs.losant.com/applications/access-keys/) belonging
|
|
109
|
+
to an Application - such as listing all keys or creating a new key.
|
|
110
|
+
|
|
111
|
+
* [application](docs/application.md)
|
|
112
|
+
Contains all of the actions that can be performed against a single
|
|
113
|
+
[Application](https://docs.losant.com/applications/overview/),
|
|
114
|
+
which include things like getting info on an application or
|
|
115
|
+
modifying an application.
|
|
116
|
+
|
|
117
|
+
* [applications](docs/applications.md)
|
|
118
|
+
Contains all of the actions that can be performed against the set of
|
|
119
|
+
[Applications](https://docs.losant.com/applications/overview/) that the
|
|
120
|
+
currently authenticated user has access to - such as
|
|
121
|
+
listing the applications or creating a new application.
|
|
122
|
+
|
|
123
|
+
* [auth](docs/auth.md)
|
|
124
|
+
Contains the actions used for authenticating against the api, either as a
|
|
125
|
+
user or as a device. The result of authentication calls contain the auth_token
|
|
126
|
+
needed for authenticated calls - see the examples for more details.
|
|
127
|
+
|
|
128
|
+
* [dashboard](docs/dashboard.md)
|
|
129
|
+
Contains all of the actions that can be performed against a single
|
|
130
|
+
[Dashboard](https://docs.losant.com/dashboards/overview/),
|
|
131
|
+
which include things like getting info on a dashboard or
|
|
132
|
+
modifying a dashboard.
|
|
133
|
+
|
|
134
|
+
* [dashboards](docs/dashboards.md)
|
|
135
|
+
Contains all of the actions that can be performed against the set of
|
|
136
|
+
[Dashboards](https://docs.losant.com/dashboards/overview/) that the
|
|
137
|
+
currently authenticated user has access to - such as
|
|
138
|
+
listing the dashboards or creating a new dashboard.
|
|
139
|
+
|
|
140
|
+
* [data](docs/data.md)
|
|
141
|
+
Contains the actions for querying against historical Device
|
|
142
|
+
data across an Application.
|
|
143
|
+
|
|
144
|
+
* [device](docs/device.md)
|
|
145
|
+
Contains all the actions that can be performed against a single
|
|
146
|
+
[Device](https://docs.losant.com/devices/overview/) -
|
|
147
|
+
for instance, getting info on a single device or reporting the current
|
|
148
|
+
state of a device.
|
|
149
|
+
|
|
150
|
+
* [devices](docs/devices.md)
|
|
151
|
+
Contains all of the actions that can be performed against the collection of
|
|
152
|
+
[Devices](https://docs.losant.com/devices/overview/) belonging
|
|
153
|
+
to an Application - such as listing all devices or sending a command to a set
|
|
154
|
+
of devices.
|
|
155
|
+
|
|
156
|
+
* [device_recipe](docs/deviceRecipe.md)
|
|
157
|
+
Contains all the actions that can be performed against a single
|
|
158
|
+
[Device Recipe](https://docs.losant.com/devices/device-recipes/), which
|
|
159
|
+
include things like removing a device recipe or creating a device
|
|
160
|
+
from a device recipe.
|
|
161
|
+
|
|
162
|
+
* [device_recipes](docs/deviceRecipes.md)
|
|
163
|
+
Contains all the actions that can be performed against the collection of
|
|
164
|
+
[Device Recipes](https://docs.losant.com/devices/device-recipes/) belonging
|
|
165
|
+
to an Application - such as listing recipes or creating a new recipe.
|
|
166
|
+
|
|
167
|
+
* [event](docs/event.md)
|
|
168
|
+
Contains all the actions that can be performed against a single
|
|
169
|
+
[Event](https://docs.losant.com/events/overview/), such as commenting on
|
|
170
|
+
or changing the state of an event.
|
|
171
|
+
|
|
172
|
+
* [events](docs/events.md)
|
|
173
|
+
Contains all the actions that can be performed against the collection of
|
|
174
|
+
[Events](https://docs.losant.com/events/overview/) belonging
|
|
175
|
+
to an Application - such as listing open events or creating a new event.
|
|
176
|
+
|
|
177
|
+
* [flow](docs/flow.md)
|
|
178
|
+
Contains all the actions that can be performed against a single
|
|
179
|
+
[Workflow](https://docs.losant.com/workflows/overview/), such as enabling or
|
|
180
|
+
disabling a workflow, or triggering a virtual button in the workflow.
|
|
181
|
+
|
|
182
|
+
* [flows](docs/flows.md)
|
|
183
|
+
Contains all the actions that can be performed against the collection of
|
|
184
|
+
[Workflows](https://docs.losant.com/workflows/overview/) belonging
|
|
185
|
+
to an Application - such as listing the workflows or creating a new workflow.
|
|
186
|
+
|
|
187
|
+
* [me](docs/me.md)
|
|
188
|
+
Contains the actions for operating against the currently authenticated
|
|
189
|
+
[User](https://docs.losant.com/user-accounts/overview/) such as changing
|
|
190
|
+
the password or linking against external services.
|
|
191
|
+
|
|
192
|
+
* [org](docs/org.md)
|
|
193
|
+
Contains all the actions that can be performed against a single
|
|
194
|
+
[Organization](https://docs.losant.com/organizations/overview/), things like
|
|
195
|
+
inviting a user to the organization, or modifying the organization.
|
|
196
|
+
|
|
197
|
+
* [orgs](docs/orgs.md)
|
|
198
|
+
Contains all of the actions that can be performed against the set of
|
|
199
|
+
[Organizations](https://docs.losant.com/organizations/overview/) that the
|
|
200
|
+
currently authenticated user has access to - such as
|
|
201
|
+
listing the organizations or creating a new organization.
|
|
202
|
+
|
|
203
|
+
* [webhook](docs/webhook.md)
|
|
204
|
+
Contains all the actions that can be performed against a single
|
|
205
|
+
[Webhook](https://docs.losant.com/applications/webhooks/), for instance
|
|
206
|
+
modifying the verification settings or removing the webhook.
|
|
207
|
+
|
|
208
|
+
* [webhooks](docs/webhooks.md)
|
|
209
|
+
Contains all the actions that can be performed against the collection of
|
|
210
|
+
[Webhooks](https://docs.losant.com/applications/webhooks/) belonging
|
|
211
|
+
to an Application - such as listing the webhooks or creating a new webhook.
|
|
212
|
+
|
|
213
|
+
<br/>
|
|
214
|
+
|
|
215
|
+
### LosantRest::ResponseError
|
|
216
|
+
|
|
217
|
+
When the Losant API returns a unsuccessful response, an instance of
|
|
218
|
+
ResponseError is thrown.
|
|
219
|
+
|
|
220
|
+
#### Accessors
|
|
221
|
+
|
|
222
|
+
* code
|
|
223
|
+
The status code returned from the Losant API.
|
|
224
|
+
|
|
225
|
+
* type
|
|
226
|
+
The type of error that occured, such as "Validation" or "Authorization".
|
|
227
|
+
|
|
228
|
+
* message
|
|
229
|
+
A more detailed message about the particulars of the error.
|
|
230
|
+
|
|
231
|
+
<br/>
|
|
232
|
+
|
|
233
|
+
*****
|
|
234
|
+
|
|
235
|
+
Copyright (c) 2016 Losant IoT, Inc
|
|
236
|
+
|
|
237
|
+
<https://www.losant.com>
|
data/Rakefile
ADDED