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,122 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Access Token Resource
4
+ class AccessToken
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Deletes an accessToken
11
+ #
12
+ # Parameters:
13
+ # * {string} accessTokenId - ID associated with the accessToken
14
+ # * {boolean} _actions - Return resource actions in response
15
+ # * {boolean} _links - Return resource link in response
16
+ # * {boolean} _embedded - Return embedded resources in response
17
+ #
18
+ # Responses:
19
+ # * 200 - If accessToken was successfully deleted (https://api.losant.com/#/definitions/success)
20
+ #
21
+ # Errors:
22
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
23
+ # * 404 - Error if accessToken was not found (https://api.losant.com/#/definitions/error)
24
+ def delete(params = {})
25
+ params = Utils.symbolize_hash_keys(params)
26
+ query_params = { _actions: false, _links: true, _embedded: true }
27
+ headers = {}
28
+ body = nil
29
+
30
+ raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId)
31
+
32
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
33
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
34
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
35
+
36
+ path = "/access-tokens/#{params[:accessTokenId]}"
37
+
38
+ @client.request(
39
+ method: :delete,
40
+ path: path,
41
+ query: query_params,
42
+ headers: headers,
43
+ body: body)
44
+ end
45
+
46
+ # Retrieves information on an accessToken
47
+ #
48
+ # Parameters:
49
+ # * {string} accessTokenId - ID associated with the accessToken
50
+ # * {boolean} _actions - Return resource actions in response
51
+ # * {boolean} _links - Return resource link in response
52
+ # * {boolean} _embedded - Return embedded resources in response
53
+ #
54
+ # Responses:
55
+ # * 200 - Access token information (https://api.losant.com/#/definitions/accessToken)
56
+ #
57
+ # Errors:
58
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
59
+ # * 404 - Error if accessToken was not found (https://api.losant.com/#/definitions/error)
60
+ def get(params = {})
61
+ params = Utils.symbolize_hash_keys(params)
62
+ query_params = { _actions: false, _links: true, _embedded: true }
63
+ headers = {}
64
+ body = nil
65
+
66
+ raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId)
67
+
68
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
69
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
70
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
71
+
72
+ path = "/access-tokens/#{params[:accessTokenId]}"
73
+
74
+ @client.request(
75
+ method: :get,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
82
+ # Updates information about an accessToken
83
+ #
84
+ # Parameters:
85
+ # * {string} accessTokenId - ID associated with the accessToken
86
+ # * {hash} accessToken - Object containing new properties of the accessToken (https://api.losant.com/#/definitions/accessTokenPatch)
87
+ # * {boolean} _actions - Return resource actions in response
88
+ # * {boolean} _links - Return resource link in response
89
+ # * {boolean} _embedded - Return embedded resources in response
90
+ #
91
+ # Responses:
92
+ # * 200 - Updated accessToken information (https://api.losant.com/#/definitions/accessToken)
93
+ #
94
+ # Errors:
95
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
96
+ # * 404 - Error if accessToken was not found (https://api.losant.com/#/definitions/error)
97
+ def patch(params = {})
98
+ params = Utils.symbolize_hash_keys(params)
99
+ query_params = { _actions: false, _links: true, _embedded: true }
100
+ headers = {}
101
+ body = nil
102
+
103
+ raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId)
104
+ raise ArgumentError.new("accessToken is required") unless params.has_key?(:accessToken)
105
+
106
+ body = params[:accessToken] if params.has_key?(:accessToken)
107
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
108
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
109
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
110
+
111
+ path = "/access-tokens/#{params[:accessTokenId]}"
112
+
113
+ @client.request(
114
+ method: :patch,
115
+ path: path,
116
+ query: query_params,
117
+ headers: headers,
118
+ body: body)
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,80 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Access Tokens Resource
4
+ class AccessTokens
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Returns the accessTokens for a user
11
+ #
12
+ # Parameters:
13
+ # * {boolean} _actions - Return resource actions in response
14
+ # * {boolean} _links - Return resource link in response
15
+ # * {boolean} _embedded - Return embedded resources in response
16
+ #
17
+ # Responses:
18
+ # * 200 - Collection of accessTokens (https://api.losant.com/#/definitions/accessTokens)
19
+ #
20
+ # Errors:
21
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
22
+ def get(params = {})
23
+ params = Utils.symbolize_hash_keys(params)
24
+ query_params = { _actions: false, _links: true, _embedded: true }
25
+ headers = {}
26
+ body = nil
27
+
28
+
29
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
30
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
31
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
32
+
33
+ path = "/access-tokens"
34
+
35
+ @client.request(
36
+ method: :get,
37
+ path: path,
38
+ query: query_params,
39
+ headers: headers,
40
+ body: body)
41
+ end
42
+
43
+ # Create a new accessToken for a user
44
+ #
45
+ # Parameters:
46
+ # * {hash} accessToken - AccessToken information (https://api.losant.com/#/definitions/accessTokenPost)
47
+ # * {boolean} _actions - Return resource actions in response
48
+ # * {boolean} _links - Return resource link in response
49
+ # * {boolean} _embedded - Return embedded resources in response
50
+ #
51
+ # Responses:
52
+ # * 201 - The successfully created accessToken (https://api.losant.com/#/definitions/accessToken)
53
+ #
54
+ # Errors:
55
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
56
+ def post(params = {})
57
+ params = Utils.symbolize_hash_keys(params)
58
+ query_params = { _actions: false, _links: true, _embedded: true }
59
+ headers = {}
60
+ body = nil
61
+
62
+ raise ArgumentError.new("accessToken is required") unless params.has_key?(:accessToken)
63
+
64
+ body = params[:accessToken] if params.has_key?(:accessToken)
65
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
66
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
67
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
68
+
69
+ path = "/access-tokens"
70
+
71
+ @client.request(
72
+ method: :post,
73
+ path: path,
74
+ query: query_params,
75
+ headers: headers,
76
+ body: body)
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,122 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Application Resource
4
+ class Application
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Deletes an application
11
+ #
12
+ # Parameters:
13
+ # * {string} applicationId - ID of the associated application
14
+ # * {boolean} _actions - Return resource actions in response
15
+ # * {boolean} _links - Return resource link in response
16
+ # * {boolean} _embedded - Return embedded resources in response
17
+ #
18
+ # Responses:
19
+ # * 200 - If application was successfully deleted (https://api.losant.com/#/definitions/success)
20
+ #
21
+ # Errors:
22
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
23
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
24
+ def delete(params = {})
25
+ params = Utils.symbolize_hash_keys(params)
26
+ query_params = { _actions: false, _links: true, _embedded: true }
27
+ headers = {}
28
+ body = nil
29
+
30
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
31
+
32
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
33
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
34
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
35
+
36
+ path = "/applications/#{params[:applicationId]}"
37
+
38
+ @client.request(
39
+ method: :delete,
40
+ path: path,
41
+ query: query_params,
42
+ headers: headers,
43
+ body: body)
44
+ end
45
+
46
+ # Retrieves information on an application
47
+ #
48
+ # Parameters:
49
+ # * {string} applicationId - ID of the associated application
50
+ # * {boolean} _actions - Return resource actions in response
51
+ # * {boolean} _links - Return resource link in response
52
+ # * {boolean} _embedded - Return embedded resources in response
53
+ #
54
+ # Responses:
55
+ # * 200 - Application information (https://api.losant.com/#/definitions/application)
56
+ #
57
+ # Errors:
58
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
59
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
60
+ def get(params = {})
61
+ params = Utils.symbolize_hash_keys(params)
62
+ query_params = { _actions: false, _links: true, _embedded: true }
63
+ headers = {}
64
+ body = nil
65
+
66
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
67
+
68
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
69
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
70
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
71
+
72
+ path = "/applications/#{params[:applicationId]}"
73
+
74
+ @client.request(
75
+ method: :get,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
82
+ # Updates information about an application
83
+ #
84
+ # Parameters:
85
+ # * {string} applicationId - ID of the associated application
86
+ # * {hash} application - Object containing new application properties (https://api.losant.com/#/definitions/applicationPatch)
87
+ # * {boolean} _actions - Return resource actions in response
88
+ # * {boolean} _links - Return resource link in response
89
+ # * {boolean} _embedded - Return embedded resources in response
90
+ #
91
+ # Responses:
92
+ # * 200 - Updated application information (https://api.losant.com/#/definitions/application)
93
+ #
94
+ # Errors:
95
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
96
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
97
+ def patch(params = {})
98
+ params = Utils.symbolize_hash_keys(params)
99
+ query_params = { _actions: false, _links: true, _embedded: true }
100
+ headers = {}
101
+ body = nil
102
+
103
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
104
+ raise ArgumentError.new("application is required") unless params.has_key?(:application)
105
+
106
+ body = params[:application] if params.has_key?(:application)
107
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
108
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
109
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
110
+
111
+ path = "/applications/#{params[:applicationId]}"
112
+
113
+ @client.request(
114
+ method: :patch,
115
+ path: path,
116
+ query: query_params,
117
+ headers: headers,
118
+ body: body)
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,128 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Application Key Resource
4
+ class ApplicationKey
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Deletes an applicationKey
11
+ #
12
+ # Parameters:
13
+ # * {string} applicationId - ID associated with the application
14
+ # * {string} applicationKeyId - ID associated with the applicationKey
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 applicationKey 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 applicationKey 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("applicationKeyId is required") unless params.has_key?(:applicationKeyId)
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]}/keys/#{params[:applicationKeyId]}"
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 an applicationKey
49
+ #
50
+ # Parameters:
51
+ # * {string} applicationId - ID associated with the application
52
+ # * {string} applicationKeyId - ID associated with the applicationKey
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 - applicationKey information (https://api.losant.com/#/definitions/applicationKey)
59
+ #
60
+ # Errors:
61
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
62
+ # * 404 - Error if applicationKey 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("applicationKeyId is required") unless params.has_key?(:applicationKeyId)
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]}/keys/#{params[:applicationKeyId]}"
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 an applicationKey
87
+ #
88
+ # Parameters:
89
+ # * {string} applicationId - ID associated with the application
90
+ # * {string} applicationKeyId - ID associated with the applicationKey
91
+ # * {hash} applicationKey - Object containing new properties of the applicationKey (https://api.losant.com/#/definitions/applicationKeyPatch)
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 applicationKey information (https://api.losant.com/#/definitions/applicationKey)
98
+ #
99
+ # Errors:
100
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
101
+ # * 404 - Error if applicationKey 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("applicationKeyId is required") unless params.has_key?(:applicationKeyId)
110
+ raise ArgumentError.new("applicationKey is required") unless params.has_key?(:applicationKey)
111
+
112
+ body = params[:applicationKey] if params.has_key?(:applicationKey)
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]}/keys/#{params[:applicationKeyId]}"
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 Application Keys Resource
4
+ class ApplicationKeys
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Returns the applicationKeys 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: key, status, 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: key, status
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 applicationKeys (https://api.losant.com/#/definitions/applicationKeys)
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]}/keys"
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 applicationKey for an application
59
+ #
60
+ # Parameters:
61
+ # * {string} applicationId - ID associated with the application
62
+ # * {hash} applicationKey - ApplicationKey information (https://api.losant.com/#/definitions/applicationKeyPost)
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 applicationKey (https://api.losant.com/#/definitions/applicationKey)
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("applicationKey is required") unless params.has_key?(:applicationKey)
81
+
82
+ body = params[:applicationKey] if params.has_key?(:applicationKey)
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]}/keys"
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
@@ -0,0 +1,94 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Applications Resource
4
+ class Applications
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Returns the applications the current user has permission to see
11
+ #
12
+ # Parameters:
13
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, ownerId
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
+ # * {string} orgId - If not provided, return all applications. If provided but blank, only return applications belonging to the current user. If provided and an id, only return applications belonging to the given organization id.
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 applications (https://api.losant.com/#/definitions/applications)
26
+ #
27
+ # Errors:
28
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
29
+ def get(params = {})
30
+ params = Utils.symbolize_hash_keys(params)
31
+ query_params = { _actions: false, _links: true, _embedded: true }
32
+ headers = {}
33
+ body = nil
34
+
35
+
36
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
37
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
38
+ query_params[:page] = params[:page] if params.has_key?(:page)
39
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
40
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
41
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
42
+ query_params[:orgId] = params[:orgId] if params.has_key?(:orgId)
43
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
44
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
45
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
46
+
47
+ path = "/applications"
48
+
49
+ @client.request(
50
+ method: :get,
51
+ path: path,
52
+ query: query_params,
53
+ headers: headers,
54
+ body: body)
55
+ end
56
+
57
+ # Create a new application
58
+ #
59
+ # Parameters:
60
+ # * {hash} application - New application information (https://api.losant.com/#/definitions/applicationPost)
61
+ # * {boolean} _actions - Return resource actions in response
62
+ # * {boolean} _links - Return resource link in response
63
+ # * {boolean} _embedded - Return embedded resources in response
64
+ #
65
+ # Responses:
66
+ # * 201 - Successfully created application (https://api.losant.com/#/definitions/application)
67
+ #
68
+ # Errors:
69
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
70
+ def post(params = {})
71
+ params = Utils.symbolize_hash_keys(params)
72
+ query_params = { _actions: false, _links: true, _embedded: true }
73
+ headers = {}
74
+ body = nil
75
+
76
+ raise ArgumentError.new("application is required") unless params.has_key?(:application)
77
+
78
+ body = params[:application] if params.has_key?(:application)
79
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
80
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
81
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
82
+
83
+ path = "/applications"
84
+
85
+ @client.request(
86
+ method: :post,
87
+ path: path,
88
+ query: query_params,
89
+ headers: headers,
90
+ body: body)
91
+ end
92
+
93
+ end
94
+ end