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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Orgs Resource
|
|
4
|
+
class Orgs
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the organizations associated with the current user
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate
|
|
14
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
|
15
|
+
# * {string} page - Which page of results to return
|
|
16
|
+
# * {string} perPage - How many items to return per page
|
|
17
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
|
|
18
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
19
|
+
# * {boolean} _actions - Return resource actions in response
|
|
20
|
+
# * {boolean} _links - Return resource link in response
|
|
21
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
22
|
+
#
|
|
23
|
+
# Responses:
|
|
24
|
+
# * 200 - Collection of organizations (https://api.losant.com/#/definitions/orgs)
|
|
25
|
+
#
|
|
26
|
+
# Errors:
|
|
27
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
28
|
+
def get(params = {})
|
|
29
|
+
params = Utils.symbolize_hash_keys(params)
|
|
30
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
31
|
+
headers = {}
|
|
32
|
+
body = nil
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
|
36
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
|
37
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
|
38
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
|
39
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
40
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
41
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
42
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
43
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
44
|
+
|
|
45
|
+
path = "/orgs"
|
|
46
|
+
|
|
47
|
+
@client.request(
|
|
48
|
+
method: :get,
|
|
49
|
+
path: path,
|
|
50
|
+
query: query_params,
|
|
51
|
+
headers: headers,
|
|
52
|
+
body: body)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Create a new organization
|
|
56
|
+
#
|
|
57
|
+
# Parameters:
|
|
58
|
+
# * {hash} organization - New organization information (https://api.losant.com/#/definitions/orgPost)
|
|
59
|
+
# * {boolean} _actions - Return resource actions in response
|
|
60
|
+
# * {boolean} _links - Return resource link in response
|
|
61
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
62
|
+
#
|
|
63
|
+
# Responses:
|
|
64
|
+
# * 201 - Successfully created organization (https://api.losant.com/#/definitions/org)
|
|
65
|
+
#
|
|
66
|
+
# Errors:
|
|
67
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
68
|
+
def post(params = {})
|
|
69
|
+
params = Utils.symbolize_hash_keys(params)
|
|
70
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
71
|
+
headers = {}
|
|
72
|
+
body = nil
|
|
73
|
+
|
|
74
|
+
raise ArgumentError.new("organization is required") unless params.has_key?(:organization)
|
|
75
|
+
|
|
76
|
+
body = params[:organization] if params.has_key?(:organization)
|
|
77
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
78
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
79
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
80
|
+
|
|
81
|
+
path = "/orgs"
|
|
82
|
+
|
|
83
|
+
@client.request(
|
|
84
|
+
method: :post,
|
|
85
|
+
path: path,
|
|
86
|
+
query: query_params,
|
|
87
|
+
headers: headers,
|
|
88
|
+
body: body)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
class Utils
|
|
3
|
+
def self.symbolize_hash_keys(hash)
|
|
4
|
+
Hash[hash.dup.map { |k, v| [k.to_sym, v] }]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.fix_query_arrays(value)
|
|
8
|
+
if value.respond_to?(:to_ary)
|
|
9
|
+
value = value.to_ary.map.with_index.to_a.to_h.invert
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
if value.respond_to?(:to_hash)
|
|
13
|
+
value = value.to_hash
|
|
14
|
+
value.each do |k, v|
|
|
15
|
+
value[k] = fix_query_arrays(v)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
value
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Webhook Resource
|
|
4
|
+
class Webhook
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Deletes a webhook
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} webhookId - ID associated with the webhook
|
|
15
|
+
# * {boolean} _actions - Return resource actions in response
|
|
16
|
+
# * {boolean} _links - Return resource link in response
|
|
17
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
18
|
+
#
|
|
19
|
+
# Responses:
|
|
20
|
+
# * 200 - If webhook was successfully deleted (https://api.losant.com/#/definitions/success)
|
|
21
|
+
#
|
|
22
|
+
# Errors:
|
|
23
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
24
|
+
# * 404 - Error if webhook was not found (https://api.losant.com/#/definitions/error)
|
|
25
|
+
def delete(params = {})
|
|
26
|
+
params = Utils.symbolize_hash_keys(params)
|
|
27
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
28
|
+
headers = {}
|
|
29
|
+
body = nil
|
|
30
|
+
|
|
31
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
32
|
+
raise ArgumentError.new("webhookId is required") unless params.has_key?(:webhookId)
|
|
33
|
+
|
|
34
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
35
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
36
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
37
|
+
|
|
38
|
+
path = "/applications/#{params[:applicationId]}/webhooks/#{params[:webhookId]}"
|
|
39
|
+
|
|
40
|
+
@client.request(
|
|
41
|
+
method: :delete,
|
|
42
|
+
path: path,
|
|
43
|
+
query: query_params,
|
|
44
|
+
headers: headers,
|
|
45
|
+
body: body)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Retrieves information on a webhook
|
|
49
|
+
#
|
|
50
|
+
# Parameters:
|
|
51
|
+
# * {string} applicationId - ID associated with the application
|
|
52
|
+
# * {string} webhookId - ID associated with the webhook
|
|
53
|
+
# * {boolean} _actions - Return resource actions in response
|
|
54
|
+
# * {boolean} _links - Return resource link in response
|
|
55
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
56
|
+
#
|
|
57
|
+
# Responses:
|
|
58
|
+
# * 200 - Webhook information (https://api.losant.com/#/definitions/webhook)
|
|
59
|
+
#
|
|
60
|
+
# Errors:
|
|
61
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
62
|
+
# * 404 - Error if webhook was not found (https://api.losant.com/#/definitions/error)
|
|
63
|
+
def get(params = {})
|
|
64
|
+
params = Utils.symbolize_hash_keys(params)
|
|
65
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
66
|
+
headers = {}
|
|
67
|
+
body = nil
|
|
68
|
+
|
|
69
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
70
|
+
raise ArgumentError.new("webhookId is required") unless params.has_key?(:webhookId)
|
|
71
|
+
|
|
72
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
73
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
74
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
75
|
+
|
|
76
|
+
path = "/applications/#{params[:applicationId]}/webhooks/#{params[:webhookId]}"
|
|
77
|
+
|
|
78
|
+
@client.request(
|
|
79
|
+
method: :get,
|
|
80
|
+
path: path,
|
|
81
|
+
query: query_params,
|
|
82
|
+
headers: headers,
|
|
83
|
+
body: body)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Updates information about a webhook
|
|
87
|
+
#
|
|
88
|
+
# Parameters:
|
|
89
|
+
# * {string} applicationId - ID associated with the application
|
|
90
|
+
# * {string} webhookId - ID associated with the webhook
|
|
91
|
+
# * {hash} webhook - Object containing new properties of the webhook (https://api.losant.com/#/definitions/webhookPatch)
|
|
92
|
+
# * {boolean} _actions - Return resource actions in response
|
|
93
|
+
# * {boolean} _links - Return resource link in response
|
|
94
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
95
|
+
#
|
|
96
|
+
# Responses:
|
|
97
|
+
# * 200 - Updated webhook information (https://api.losant.com/#/definitions/webhook)
|
|
98
|
+
#
|
|
99
|
+
# Errors:
|
|
100
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
101
|
+
# * 404 - Error if webhook was not found (https://api.losant.com/#/definitions/error)
|
|
102
|
+
def patch(params = {})
|
|
103
|
+
params = Utils.symbolize_hash_keys(params)
|
|
104
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
105
|
+
headers = {}
|
|
106
|
+
body = nil
|
|
107
|
+
|
|
108
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
109
|
+
raise ArgumentError.new("webhookId is required") unless params.has_key?(:webhookId)
|
|
110
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
|
111
|
+
|
|
112
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
|
113
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
114
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
115
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
116
|
+
|
|
117
|
+
path = "/applications/#{params[:applicationId]}/webhooks/#{params[:webhookId]}"
|
|
118
|
+
|
|
119
|
+
@client.request(
|
|
120
|
+
method: :patch,
|
|
121
|
+
path: path,
|
|
122
|
+
query: query_params,
|
|
123
|
+
headers: headers,
|
|
124
|
+
body: body)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Webhooks Resource
|
|
4
|
+
class Webhooks
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the webhooks for an application
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate
|
|
15
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
|
16
|
+
# * {string} page - Which page of results to return
|
|
17
|
+
# * {string} perPage - How many items to return per page
|
|
18
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
|
|
19
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
20
|
+
# * {boolean} _actions - Return resource actions in response
|
|
21
|
+
# * {boolean} _links - Return resource link in response
|
|
22
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
23
|
+
#
|
|
24
|
+
# Responses:
|
|
25
|
+
# * 200 - Collection of webhooks (https://api.losant.com/#/definitions/webhooks)
|
|
26
|
+
#
|
|
27
|
+
# Errors:
|
|
28
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
29
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
30
|
+
def get(params = {})
|
|
31
|
+
params = Utils.symbolize_hash_keys(params)
|
|
32
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
33
|
+
headers = {}
|
|
34
|
+
body = nil
|
|
35
|
+
|
|
36
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
37
|
+
|
|
38
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
|
39
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
|
40
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
|
41
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
|
42
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
43
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
44
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
45
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
46
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
47
|
+
|
|
48
|
+
path = "/applications/#{params[:applicationId]}/webhooks"
|
|
49
|
+
|
|
50
|
+
@client.request(
|
|
51
|
+
method: :get,
|
|
52
|
+
path: path,
|
|
53
|
+
query: query_params,
|
|
54
|
+
headers: headers,
|
|
55
|
+
body: body)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Create a new webhook for an application
|
|
59
|
+
#
|
|
60
|
+
# Parameters:
|
|
61
|
+
# * {string} applicationId - ID associated with the application
|
|
62
|
+
# * {hash} webhook - New webhook information (https://api.losant.com/#/definitions/webhookPost)
|
|
63
|
+
# * {boolean} _actions - Return resource actions in response
|
|
64
|
+
# * {boolean} _links - Return resource link in response
|
|
65
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
66
|
+
#
|
|
67
|
+
# Responses:
|
|
68
|
+
# * 201 - Successfully created webhook (https://api.losant.com/#/definitions/webhook)
|
|
69
|
+
#
|
|
70
|
+
# Errors:
|
|
71
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
72
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
73
|
+
def post(params = {})
|
|
74
|
+
params = Utils.symbolize_hash_keys(params)
|
|
75
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
76
|
+
headers = {}
|
|
77
|
+
body = nil
|
|
78
|
+
|
|
79
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
80
|
+
raise ArgumentError.new("webhook is required") unless params.has_key?(:webhook)
|
|
81
|
+
|
|
82
|
+
body = params[:webhook] if params.has_key?(:webhook)
|
|
83
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
84
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
85
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
86
|
+
|
|
87
|
+
path = "/applications/#{params[:applicationId]}/webhooks"
|
|
88
|
+
|
|
89
|
+
@client.request(
|
|
90
|
+
method: :post,
|
|
91
|
+
path: path,
|
|
92
|
+
query: query_params,
|
|
93
|
+
headers: headers,
|
|
94
|
+
body: body)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
end
|
data/lib/losant_rest.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require_relative "losant_rest/version"
|
|
2
|
+
require_relative "losant_rest/error"
|
|
3
|
+
require_relative "losant_rest/utils"
|
|
4
|
+
require_relative "losant_rest/access_token"
|
|
5
|
+
require_relative "losant_rest/access_tokens"
|
|
6
|
+
require_relative "losant_rest/application"
|
|
7
|
+
require_relative "losant_rest/application_key"
|
|
8
|
+
require_relative "losant_rest/application_keys"
|
|
9
|
+
require_relative "losant_rest/applications"
|
|
10
|
+
require_relative "losant_rest/auth"
|
|
11
|
+
require_relative "losant_rest/dashboard"
|
|
12
|
+
require_relative "losant_rest/dashboards"
|
|
13
|
+
require_relative "losant_rest/data"
|
|
14
|
+
require_relative "losant_rest/device"
|
|
15
|
+
require_relative "losant_rest/device_recipe"
|
|
16
|
+
require_relative "losant_rest/device_recipes"
|
|
17
|
+
require_relative "losant_rest/devices"
|
|
18
|
+
require_relative "losant_rest/event"
|
|
19
|
+
require_relative "losant_rest/events"
|
|
20
|
+
require_relative "losant_rest/flow"
|
|
21
|
+
require_relative "losant_rest/flows"
|
|
22
|
+
require_relative "losant_rest/me"
|
|
23
|
+
require_relative "losant_rest/org"
|
|
24
|
+
require_relative "losant_rest/orgs"
|
|
25
|
+
require_relative "losant_rest/webhook"
|
|
26
|
+
require_relative "losant_rest/webhooks"
|
|
27
|
+
require_relative "losant_rest/client"
|
|
28
|
+
|
|
29
|
+
module LosantRest
|
|
30
|
+
|
|
31
|
+
def self.client
|
|
32
|
+
@client ||= Client.new
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.method_missing(sym, *args, &block)
|
|
36
|
+
self.client.__send__(sym, *args, &block)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
40
|
+
self.client.respond_to?(method_name, include_private)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
data/losant_rest.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
$LOAD_PATH.push(File.expand_path("../lib", __FILE__))
|
|
2
|
+
require "losant_rest/version"
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.name = "losant_rest"
|
|
6
|
+
gem.authors = ["Michael Kuehl"]
|
|
7
|
+
gem.email = ["hello@losant.com"]
|
|
8
|
+
gem.summary = %q{Provides a simple ruby wrapper around the Losant REST API}
|
|
9
|
+
gem.description = %q{Easily use the Losant IoT Platform through its REST API with Ruby}
|
|
10
|
+
gem.homepage = "https://github.com/Losant/losant-rest-ruby"
|
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
14
|
+
gem.require_paths = ["lib"]
|
|
15
|
+
gem.version = LosantRest::VERSION
|
|
16
|
+
gem.licenses = ["MIT"]
|
|
17
|
+
|
|
18
|
+
gem.required_ruby_version = ">= 2.1"
|
|
19
|
+
|
|
20
|
+
gem.add_dependency "httparty", "~> 0.13.0"
|
|
21
|
+
|
|
22
|
+
gem.add_development_dependency "minitest", "~> 5.9"
|
|
23
|
+
gem.add_development_dependency "rake", "~> 11"
|
|
24
|
+
gem.add_development_dependency "webmock", "~> 2.1"
|
|
25
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"id": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
8
|
+
},
|
|
9
|
+
"accessTokenId": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
12
|
+
},
|
|
13
|
+
"userId": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
16
|
+
},
|
|
17
|
+
"name": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"maxLength": 255
|
|
21
|
+
},
|
|
22
|
+
"creationDate": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"format": "date-time"
|
|
25
|
+
},
|
|
26
|
+
"lastUpdated": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"format": "date-time"
|
|
29
|
+
},
|
|
30
|
+
"expirationDate": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date-time"
|
|
33
|
+
},
|
|
34
|
+
"scope": {
|
|
35
|
+
"type": "array",
|
|
36
|
+
"items": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"status": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": [
|
|
43
|
+
"active",
|
|
44
|
+
"inactive"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"token": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"minLength": 1
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
"status": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"enum": [
|
|
13
|
+
"active",
|
|
14
|
+
"inactive"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"additionalProperties": false
|
|
19
|
+
}
|
|
@@ -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
|
+
"expirationDate": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"format": "date-time"
|
|
13
|
+
},
|
|
14
|
+
"scope": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"status": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": [
|
|
23
|
+
"active",
|
|
24
|
+
"inactive"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": [
|
|
30
|
+
"name"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"items": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"title": "Access Token",
|
|
9
|
+
"description": "Schema for a single Access Token",
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"id": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
15
|
+
},
|
|
16
|
+
"accessTokenId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
19
|
+
},
|
|
20
|
+
"userId": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
23
|
+
},
|
|
24
|
+
"name": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"minLength": 1,
|
|
27
|
+
"maxLength": 255
|
|
28
|
+
},
|
|
29
|
+
"creationDate": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"format": "date-time"
|
|
32
|
+
},
|
|
33
|
+
"lastUpdated": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"format": "date-time"
|
|
36
|
+
},
|
|
37
|
+
"expirationDate": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"format": "date-time"
|
|
40
|
+
},
|
|
41
|
+
"scope": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"status": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": [
|
|
50
|
+
"active",
|
|
51
|
+
"inactive"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"token": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 1
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"count": {
|
|
62
|
+
"type": "integer"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"id": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
8
|
+
},
|
|
9
|
+
"applicationId": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
12
|
+
},
|
|
13
|
+
"creationDate": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"format": "date-time"
|
|
16
|
+
},
|
|
17
|
+
"lastUpdated": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "date-time"
|
|
20
|
+
},
|
|
21
|
+
"ownerId": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"pattern": "^[A-Fa-f\\d]{24}$"
|
|
24
|
+
},
|
|
25
|
+
"ownerType": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": [
|
|
28
|
+
"user",
|
|
29
|
+
"organization"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"name": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"minLength": 1,
|
|
35
|
+
"maxLength": 255
|
|
36
|
+
},
|
|
37
|
+
"description": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"maxLength": 32767
|
|
40
|
+
},
|
|
41
|
+
"summary": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"deviceCount": {
|
|
45
|
+
"type": "number"
|
|
46
|
+
},
|
|
47
|
+
"flowCount": {
|
|
48
|
+
"type": "number"
|
|
49
|
+
},
|
|
50
|
+
"webhookCount": {
|
|
51
|
+
"type": "number"
|
|
52
|
+
},
|
|
53
|
+
"eventCount": {
|
|
54
|
+
"type": "number"
|
|
55
|
+
},
|
|
56
|
+
"keyCount": {
|
|
57
|
+
"type": "number"
|
|
58
|
+
},
|
|
59
|
+
"deviceRecipeCount": {
|
|
60
|
+
"type": "number"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|