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.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rbenv-version +1 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE +21 -0
  7. data/README.md +237 -0
  8. data/Rakefile +12 -0
  9. data/docs/_schemas.md +6348 -0
  10. data/docs/accessToken.md +107 -0
  11. data/docs/accessTokens.md +68 -0
  12. data/docs/application.md +107 -0
  13. data/docs/applicationKey.md +115 -0
  14. data/docs/applicationKeys.md +81 -0
  15. data/docs/applications.md +76 -0
  16. data/docs/auth.md +104 -0
  17. data/docs/dashboard.md +107 -0
  18. data/docs/dashboards.md +76 -0
  19. data/docs/data.md +78 -0
  20. data/docs/device.md +300 -0
  21. data/docs/deviceRecipe.md +152 -0
  22. data/docs/deviceRecipes.md +81 -0
  23. data/docs/devices.md +117 -0
  24. data/docs/event.md +115 -0
  25. data/docs/events.md +153 -0
  26. data/docs/flow.md +261 -0
  27. data/docs/flows.md +81 -0
  28. data/docs/me.md +312 -0
  29. data/docs/org.md +279 -0
  30. data/docs/orgs.md +75 -0
  31. data/docs/webhook.md +115 -0
  32. data/docs/webhooks.md +81 -0
  33. data/examples/auth.rb +32 -0
  34. data/examples/list_devices.rb +45 -0
  35. data/lib/losant_rest/access_token.rb +122 -0
  36. data/lib/losant_rest/access_tokens.rb +80 -0
  37. data/lib/losant_rest/application.rb +122 -0
  38. data/lib/losant_rest/application_key.rb +128 -0
  39. data/lib/losant_rest/application_keys.rb +98 -0
  40. data/lib/losant_rest/applications.rb +94 -0
  41. data/lib/losant_rest/auth.rb +122 -0
  42. data/lib/losant_rest/client.rb +132 -0
  43. data/lib/losant_rest/dashboard.rb +122 -0
  44. data/lib/losant_rest/dashboards.rb +94 -0
  45. data/lib/losant_rest/data.rb +89 -0
  46. data/lib/losant_rest/device.rb +336 -0
  47. data/lib/losant_rest/device_recipe.rb +169 -0
  48. data/lib/losant_rest/device_recipes.rb +98 -0
  49. data/lib/losant_rest/devices.rb +139 -0
  50. data/lib/losant_rest/error.rb +12 -0
  51. data/lib/losant_rest/event.rb +128 -0
  52. data/lib/losant_rest/events.rb +183 -0
  53. data/lib/losant_rest/flow.rb +290 -0
  54. data/lib/losant_rest/flows.rb +98 -0
  55. data/lib/losant_rest/me.rb +362 -0
  56. data/lib/losant_rest/org.rb +314 -0
  57. data/lib/losant_rest/orgs.rb +92 -0
  58. data/lib/losant_rest/utils.rb +22 -0
  59. data/lib/losant_rest/version.rb +3 -0
  60. data/lib/losant_rest/webhook.rb +128 -0
  61. data/lib/losant_rest/webhooks.rb +98 -0
  62. data/lib/losant_rest.rb +43 -0
  63. data/losant_rest.gemspec +25 -0
  64. data/schemas/accessToken.json +52 -0
  65. data/schemas/accessTokenPatch.json +19 -0
  66. data/schemas/accessTokenPost.json +32 -0
  67. data/schemas/accessTokens.json +65 -0
  68. data/schemas/application.json +65 -0
  69. data/schemas/applicationKey.json +68 -0
  70. data/schemas/applicationKeyPatch.json +18 -0
  71. data/schemas/applicationKeyPost.json +36 -0
  72. data/schemas/applicationKeys.json +110 -0
  73. data/schemas/applicationPatch.json +16 -0
  74. data/schemas/applicationPost.json +23 -0
  75. data/schemas/applications.json +103 -0
  76. data/schemas/authedDevice.json +34 -0
  77. data/schemas/authedUser.json +18 -0
  78. data/schemas/dashboard.json +95 -0
  79. data/schemas/dashboardPatch.json +69 -0
  80. data/schemas/dashboardPost.json +76 -0
  81. data/schemas/dashboards.json +133 -0
  82. data/schemas/device.json +113 -0
  83. data/schemas/deviceCommand.json +20 -0
  84. data/schemas/deviceCommands.json +25 -0
  85. data/schemas/deviceCredentials.json +22 -0
  86. data/schemas/deviceLog.json +28 -0
  87. data/schemas/devicePatch.json +78 -0
  88. data/schemas/devicePost.json +81 -0
  89. data/schemas/deviceRecipe.json +106 -0
  90. data/schemas/deviceRecipeBulkCreate.json +15 -0
  91. data/schemas/deviceRecipeBulkCreatePost.json +19 -0
  92. data/schemas/deviceRecipePatch.json +87 -0
  93. data/schemas/deviceRecipePost.json +90 -0
  94. data/schemas/deviceRecipes.json +148 -0
  95. data/schemas/deviceState.json +30 -0
  96. data/schemas/deviceStates.json +35 -0
  97. data/schemas/deviceTagFilter.json +19 -0
  98. data/schemas/devices.json +155 -0
  99. data/schemas/disableTwoFactorAuth.json +20 -0
  100. data/schemas/enableTwoFactorAuth.json +21 -0
  101. data/schemas/error.json +12 -0
  102. data/schemas/event.json +115 -0
  103. data/schemas/eventPatch.json +20 -0
  104. data/schemas/eventPost.json +39 -0
  105. data/schemas/events.json +165 -0
  106. data/schemas/flow.json +137 -0
  107. data/schemas/flowLog.json +46 -0
  108. data/schemas/flowPatch.json +107 -0
  109. data/schemas/flowPost.json +110 -0
  110. data/schemas/flowStorageEntries.json +7 -0
  111. data/schemas/flowStorageEntry.json +16 -0
  112. data/schemas/flows.json +179 -0
  113. data/schemas/githubLogin.json +14 -0
  114. data/schemas/lastValueData.json +34 -0
  115. data/schemas/lastValueQuery.json +36 -0
  116. data/schemas/me.json +173 -0
  117. data/schemas/mePatch.json +43 -0
  118. data/schemas/multiDeviceCommand.json +45 -0
  119. data/schemas/org.json +81 -0
  120. data/schemas/orgInvitePost.json +24 -0
  121. data/schemas/orgInvites.json +36 -0
  122. data/schemas/orgMemberPatch.json +23 -0
  123. data/schemas/orgPatch.json +16 -0
  124. data/schemas/orgPost.json +19 -0
  125. data/schemas/orgs.json +119 -0
  126. data/schemas/recentItem.json +27 -0
  127. data/schemas/recentItemList.json +36 -0
  128. data/schemas/success.json +12 -0
  129. data/schemas/timeSeriesData.json +89 -0
  130. data/schemas/timeSeriesQuery.json +64 -0
  131. data/schemas/userCredentials.json +25 -0
  132. data/schemas/virtualButtonPress.json +14 -0
  133. data/schemas/webhook.json +52 -0
  134. data/schemas/webhookPatch.json +29 -0
  135. data/schemas/webhookPost.json +32 -0
  136. data/schemas/webhooks.json +94 -0
  137. data/test/basic_test.rb +67 -0
  138. data/test/test_helper.rb +14 -0
  139. metadata +239 -0
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "name": {
6
+ "type": "string",
7
+ "minLength": 1,
8
+ "maxLength": 255
9
+ },
10
+ "responseCode": {
11
+ "type": "integer",
12
+ "minimum": 100,
13
+ "maximum": 599
14
+ },
15
+ "verificationType": {
16
+ "type": "string",
17
+ "enum": [
18
+ "facebook",
19
+ "fitbit",
20
+ "none"
21
+ ]
22
+ },
23
+ "verificationCode": {
24
+ "type": "string",
25
+ "maxLength": 32767
26
+ }
27
+ },
28
+ "required": [
29
+ "name"
30
+ ],
31
+ "additionalProperties": false
32
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "items": {
6
+ "type": "array",
7
+ "items": {
8
+ "title": "Webhook",
9
+ "description": "Schema for a single Webhook",
10
+ "type": "object",
11
+ "properties": {
12
+ "id": {
13
+ "type": "string",
14
+ "pattern": "^[A-Fa-f\\d]{24}$"
15
+ },
16
+ "webhookId": {
17
+ "type": "string",
18
+ "pattern": "^[A-Fa-f\\d]{24}$"
19
+ },
20
+ "applicationId": {
21
+ "type": "string",
22
+ "pattern": "^[A-Fa-f\\d]{24}$"
23
+ },
24
+ "creationDate": {
25
+ "type": "string",
26
+ "format": "date-time"
27
+ },
28
+ "lastUpdated": {
29
+ "type": "string",
30
+ "format": "date-time"
31
+ },
32
+ "name": {
33
+ "type": "string",
34
+ "minLength": 1,
35
+ "maxLength": 255
36
+ },
37
+ "token": {
38
+ "type": "string",
39
+ "minLength": 1
40
+ },
41
+ "responseCode": {
42
+ "type": "integer",
43
+ "minimum": 100,
44
+ "maximum": 599
45
+ },
46
+ "verificationType": {
47
+ "type": "string",
48
+ "enum": [
49
+ "facebook",
50
+ "fitbit",
51
+ "none"
52
+ ]
53
+ },
54
+ "verificationCode": {
55
+ "type": "string",
56
+ "maxLength": 32767
57
+ }
58
+ }
59
+ }
60
+ },
61
+ "count": {
62
+ "type": "integer"
63
+ },
64
+ "totalCount": {
65
+ "type": "integer"
66
+ },
67
+ "perPage": {
68
+ "type": "integer"
69
+ },
70
+ "page": {
71
+ "type": "integer"
72
+ },
73
+ "filter": {
74
+ "type": "string"
75
+ },
76
+ "filterField": {
77
+ "type": "string"
78
+ },
79
+ "sortField": {
80
+ "type": "string"
81
+ },
82
+ "sortDirection": {
83
+ "type": "string",
84
+ "enum": [
85
+ "asc",
86
+ "desc"
87
+ ]
88
+ },
89
+ "applicationId": {
90
+ "type": "string",
91
+ "pattern": "^[A-Fa-f\\d]{24}$"
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,67 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class BasicTest < MiniTest::Test
4
+ describe "test basic functionality" do
5
+
6
+ it "should correctly make an auth call" do
7
+ stub_request(:post,
8
+ "https://api.losant.com/auth/user?_actions=false&_embedded=true&_links=true")
9
+ .with(body: '{"email":"myemail@myemail.com","password":"mypassword"}',
10
+ headers: { "Accept" => "application/json" }).
11
+ to_return(body: '{ "userId": "theUserId", "token": "an auth token string"}',
12
+ status: 200, headers: { "Content-Type" => "application/json" });
13
+
14
+ client = LosantRest::Client.new
15
+
16
+ response = client.auth.authenticate_user(credentials: {
17
+ email: "myemail@myemail.com",
18
+ password: "mypassword"
19
+ })
20
+ assert_equal response, { "userId" => "theUserId", "token" => "an auth token string" }
21
+ end
22
+
23
+ it "should correctly make a call with a token" do
24
+ stub_request(:get,
25
+ "https://api.losant.com/applications?_actions=false&_embedded=true&_links=true")
26
+ .with(headers: { "Accept" => "application/json", "Authorization" => "Bearer my token" }).
27
+ to_return(body: '{ "count": 0, "items": [] }',
28
+ status: 200, headers: { "Content-Type" => "application/json" });
29
+
30
+ client = LosantRest::Client.new(auth_token: "my token")
31
+
32
+ response = client.applications.get
33
+ assert_equal response, { "count" => 0, "items" => [] }
34
+ end
35
+
36
+ it "should correctly make calls with nested query params" do
37
+ stub_request(:get,
38
+ "https://api.losant.com/applications/appId/devices?_actions=false&_links=true&_embedded=true&tagFilter[0][key]=key2&tagFilter[1][key]=key1&tagFilter[1][value]=value1&tagFilter[2][value]=value2")
39
+ .with(headers: { "Accept" => "application/json", "Authorization" => "Bearer my token" }).
40
+ to_return(body: '{ "count": 0, "items": [] }',
41
+ status: 200, headers: { "Content-Type" => "application/json" });
42
+
43
+ client = LosantRest::Client.new(auth_token: "my token")
44
+
45
+ response = client.devices.get(applicationId: "appId", tagFilter: [
46
+ { key: "key2" },
47
+ { key: "key1", value: "value1" },
48
+ { value: "value2" },
49
+ ])
50
+ assert_equal response, { "count" => 0, "items" => [] }
51
+ end
52
+
53
+ it "should correctly make a call with the singleton" do
54
+ stub_request(:get,
55
+ "https://api.losant.com/applications?_actions=false&_embedded=true&_links=true")
56
+ .with(headers: { "Accept" => "application/json", "Authorization" => "Bearer my token" }).
57
+ to_return(body: '{ "count": 0, "items": [] }',
58
+ status: 200, headers: { "Content-Type" => "application/json" });
59
+
60
+ LosantRest.client.auth_token = "my token"
61
+
62
+ response = LosantRest.applications.get
63
+ assert_equal response, { "count" => 0, "items" => [] }
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+
3
+ gem "minitest"
4
+ require "minitest/autorun"
5
+ require "minitest/spec"
6
+ require "minitest/mock"
7
+ require "webmock/minitest"
8
+ require "losant_rest"
9
+
10
+ class MiniTest::Test
11
+ def setup
12
+ WebMock.disable_net_connect!
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,239 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: losant_rest
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Kuehl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ description: Easily use the Losant IoT Platform through its REST API with Ruby
70
+ email:
71
+ - hello@losant.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rbenv-version"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - docs/_schemas.md
84
+ - docs/accessToken.md
85
+ - docs/accessTokens.md
86
+ - docs/application.md
87
+ - docs/applicationKey.md
88
+ - docs/applicationKeys.md
89
+ - docs/applications.md
90
+ - docs/auth.md
91
+ - docs/dashboard.md
92
+ - docs/dashboards.md
93
+ - docs/data.md
94
+ - docs/device.md
95
+ - docs/deviceRecipe.md
96
+ - docs/deviceRecipes.md
97
+ - docs/devices.md
98
+ - docs/event.md
99
+ - docs/events.md
100
+ - docs/flow.md
101
+ - docs/flows.md
102
+ - docs/me.md
103
+ - docs/org.md
104
+ - docs/orgs.md
105
+ - docs/webhook.md
106
+ - docs/webhooks.md
107
+ - examples/auth.rb
108
+ - examples/list_devices.rb
109
+ - lib/losant_rest.rb
110
+ - lib/losant_rest/access_token.rb
111
+ - lib/losant_rest/access_tokens.rb
112
+ - lib/losant_rest/application.rb
113
+ - lib/losant_rest/application_key.rb
114
+ - lib/losant_rest/application_keys.rb
115
+ - lib/losant_rest/applications.rb
116
+ - lib/losant_rest/auth.rb
117
+ - lib/losant_rest/client.rb
118
+ - lib/losant_rest/dashboard.rb
119
+ - lib/losant_rest/dashboards.rb
120
+ - lib/losant_rest/data.rb
121
+ - lib/losant_rest/device.rb
122
+ - lib/losant_rest/device_recipe.rb
123
+ - lib/losant_rest/device_recipes.rb
124
+ - lib/losant_rest/devices.rb
125
+ - lib/losant_rest/error.rb
126
+ - lib/losant_rest/event.rb
127
+ - lib/losant_rest/events.rb
128
+ - lib/losant_rest/flow.rb
129
+ - lib/losant_rest/flows.rb
130
+ - lib/losant_rest/me.rb
131
+ - lib/losant_rest/org.rb
132
+ - lib/losant_rest/orgs.rb
133
+ - lib/losant_rest/utils.rb
134
+ - lib/losant_rest/version.rb
135
+ - lib/losant_rest/webhook.rb
136
+ - lib/losant_rest/webhooks.rb
137
+ - losant_rest.gemspec
138
+ - schemas/accessToken.json
139
+ - schemas/accessTokenPatch.json
140
+ - schemas/accessTokenPost.json
141
+ - schemas/accessTokens.json
142
+ - schemas/application.json
143
+ - schemas/applicationKey.json
144
+ - schemas/applicationKeyPatch.json
145
+ - schemas/applicationKeyPost.json
146
+ - schemas/applicationKeys.json
147
+ - schemas/applicationPatch.json
148
+ - schemas/applicationPost.json
149
+ - schemas/applications.json
150
+ - schemas/authedDevice.json
151
+ - schemas/authedUser.json
152
+ - schemas/dashboard.json
153
+ - schemas/dashboardPatch.json
154
+ - schemas/dashboardPost.json
155
+ - schemas/dashboards.json
156
+ - schemas/device.json
157
+ - schemas/deviceCommand.json
158
+ - schemas/deviceCommands.json
159
+ - schemas/deviceCredentials.json
160
+ - schemas/deviceLog.json
161
+ - schemas/devicePatch.json
162
+ - schemas/devicePost.json
163
+ - schemas/deviceRecipe.json
164
+ - schemas/deviceRecipeBulkCreate.json
165
+ - schemas/deviceRecipeBulkCreatePost.json
166
+ - schemas/deviceRecipePatch.json
167
+ - schemas/deviceRecipePost.json
168
+ - schemas/deviceRecipes.json
169
+ - schemas/deviceState.json
170
+ - schemas/deviceStates.json
171
+ - schemas/deviceTagFilter.json
172
+ - schemas/devices.json
173
+ - schemas/disableTwoFactorAuth.json
174
+ - schemas/enableTwoFactorAuth.json
175
+ - schemas/error.json
176
+ - schemas/event.json
177
+ - schemas/eventPatch.json
178
+ - schemas/eventPost.json
179
+ - schemas/events.json
180
+ - schemas/flow.json
181
+ - schemas/flowLog.json
182
+ - schemas/flowPatch.json
183
+ - schemas/flowPost.json
184
+ - schemas/flowStorageEntries.json
185
+ - schemas/flowStorageEntry.json
186
+ - schemas/flows.json
187
+ - schemas/githubLogin.json
188
+ - schemas/lastValueData.json
189
+ - schemas/lastValueQuery.json
190
+ - schemas/me.json
191
+ - schemas/mePatch.json
192
+ - schemas/multiDeviceCommand.json
193
+ - schemas/org.json
194
+ - schemas/orgInvitePost.json
195
+ - schemas/orgInvites.json
196
+ - schemas/orgMemberPatch.json
197
+ - schemas/orgPatch.json
198
+ - schemas/orgPost.json
199
+ - schemas/orgs.json
200
+ - schemas/recentItem.json
201
+ - schemas/recentItemList.json
202
+ - schemas/success.json
203
+ - schemas/timeSeriesData.json
204
+ - schemas/timeSeriesQuery.json
205
+ - schemas/userCredentials.json
206
+ - schemas/virtualButtonPress.json
207
+ - schemas/webhook.json
208
+ - schemas/webhookPatch.json
209
+ - schemas/webhookPost.json
210
+ - schemas/webhooks.json
211
+ - test/basic_test.rb
212
+ - test/test_helper.rb
213
+ homepage: https://github.com/Losant/losant-rest-ruby
214
+ licenses:
215
+ - MIT
216
+ metadata: {}
217
+ post_install_message:
218
+ rdoc_options: []
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '2.1'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ requirements: []
232
+ rubyforge_project:
233
+ rubygems_version: 2.6.4
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: Provides a simple ruby wrapper around the Losant REST API
237
+ test_files:
238
+ - test/basic_test.rb
239
+ - test/test_helper.rb