losant_rest 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,7 +69,7 @@ puts result
69
69
  #### Authentication
70
70
  The client must be configured with a valid api access token to call this
71
71
  action. The token must include at least one of the following scopes:
72
- all.Application, all.Organization, all.User, flows.*, or flows.create.
72
+ all.Application, all.Organization, all.User, flows.*, or flows.post.
73
73
 
74
74
  #### Available Parameters
75
75
 
@@ -0,0 +1,130 @@
1
+ # Integration Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Integration resource, including the expected
5
+ parameters and the potential responses.
6
+
7
+ ##### Contents
8
+
9
+ * [Delete](#delete)
10
+ * [Get](#get)
11
+ * [Patch](#patch)
12
+
13
+ <br/>
14
+
15
+ ## Delete
16
+
17
+ Deletes an integration
18
+
19
+ ```ruby
20
+ result = client.integration.delete(
21
+ applicationId: my_application_id,
22
+ integrationId: my_integration_id)
23
+
24
+ puts result
25
+ ```
26
+
27
+ #### Authentication
28
+ The client must be configured with a valid api access token to call this
29
+ action. The token must include at least one of the following scopes:
30
+ all.Application, all.Organization, all.User, integration.*, or integration.delete.
31
+
32
+ #### Available Parameters
33
+
34
+ | Name | Type | Required | Description | Default | Example |
35
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
36
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
37
+ | integrationId | string | Y | ID associated with the integration | | 575ed78e7ae143cd83dc4aab |
38
+
39
+ #### Successful Responses
40
+
41
+ | Code | Type | Description |
42
+ | ---- | ---- | ----------- |
43
+ | 200 | [Success](_schemas.md#success) | If integration was successfully deleted |
44
+
45
+ #### Error Responses
46
+
47
+ | Code | Type | Description |
48
+ | ---- | ---- | ----------- |
49
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
50
+ | 404 | [Error](_schemas.md#error) | Error if integration was not found |
51
+
52
+ <br/>
53
+
54
+ ## Get
55
+
56
+ Retrieves information on an integration
57
+
58
+ ```ruby
59
+ result = client.integration.get(
60
+ applicationId: my_application_id,
61
+ integrationId: my_integration_id)
62
+
63
+ puts result
64
+ ```
65
+
66
+ #### Authentication
67
+ The client must be configured with a valid api access token to call this
68
+ action. The token must include at least one of the following scopes:
69
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, integration.*, or integration.get.
70
+
71
+ #### Available Parameters
72
+
73
+ | Name | Type | Required | Description | Default | Example |
74
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
75
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
76
+ | integrationId | string | Y | ID associated with the integration | | 575ed78e7ae143cd83dc4aab |
77
+
78
+ #### Successful Responses
79
+
80
+ | Code | Type | Description |
81
+ | ---- | ---- | ----------- |
82
+ | 200 | [Integrations](_schemas.md#integrations) | integration information |
83
+
84
+ #### Error Responses
85
+
86
+ | Code | Type | Description |
87
+ | ---- | ---- | ----------- |
88
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
89
+ | 404 | [Error](_schemas.md#error) | Error if integration was not found |
90
+
91
+ <br/>
92
+
93
+ ## Patch
94
+
95
+ Updates information about an integration
96
+
97
+ ```ruby
98
+ result = client.integration.patch(
99
+ applicationId: my_application_id,
100
+ integrationId: my_integration_id,
101
+ integration: my_integration)
102
+
103
+ puts result
104
+ ```
105
+
106
+ #### Authentication
107
+ The client must be configured with a valid api access token to call this
108
+ action. The token must include at least one of the following scopes:
109
+ all.Application, all.Organization, all.User, integration.*, or integration.patch.
110
+
111
+ #### Available Parameters
112
+
113
+ | Name | Type | Required | Description | Default | Example |
114
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
115
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
116
+ | integrationId | string | Y | ID associated with the integration | | 575ed78e7ae143cd83dc4aab |
117
+ | integration | [Integrations Patch](_schemas.md#integrations-patch) | Y | Object containing new properties of the integration | | [Integrations Patch Example](_schemas.md#integrations-patch-example) |
118
+
119
+ #### Successful Responses
120
+
121
+ | Code | Type | Description |
122
+ | ---- | ---- | ----------- |
123
+ | 200 | [Integrations](_schemas.md#integrations) | Updated integration information |
124
+
125
+ #### Error Responses
126
+
127
+ | Code | Type | Description |
128
+ | ---- | ---- | ----------- |
129
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
130
+ | 404 | [Error](_schemas.md#error) | Error if integration was not found |
@@ -0,0 +1,91 @@
1
+ # Integrations Actions
2
+
3
+ Details on the various actions that can be performed on the
4
+ Integrations resource, including the expected
5
+ parameters and the potential responses.
6
+
7
+ ##### Contents
8
+
9
+ * [Get](#get)
10
+ * [Post](#post)
11
+
12
+ <br/>
13
+
14
+ ## Get
15
+
16
+ Returns the integrations for an application
17
+
18
+ ```ruby
19
+ result = client.integrations.get(applicationId: my_application_id)
20
+
21
+ puts result
22
+ ```
23
+
24
+ #### Authentication
25
+ The client must be configured with a valid api access token to call this
26
+ action. The token must include at least one of the following scopes:
27
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, integrations.*, or integrations.get.
28
+
29
+ #### Available Parameters
30
+
31
+ | Name | Type | Required | Description | Default | Example |
32
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
33
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
34
+ | sortField | string | N | Field to sort the results by. Accepted values are: name, id, creationDate, integrationType | name | name |
35
+ | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | asc | asc |
36
+ | page | string | N | Which page of results to return | 0 | 0 |
37
+ | perPage | string | N | How many items to return per page | 1000 | 10 |
38
+ | filterField | string | N | Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, integrationType | | integrationType |
39
+ | filter | string | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | | my*integration |
40
+
41
+ #### Successful Responses
42
+
43
+ | Code | Type | Description |
44
+ | ---- | ---- | ----------- |
45
+ | 200 | [Integrations](_schemas.md#integrations) | Collection of integrations |
46
+
47
+ #### Error Responses
48
+
49
+ | Code | Type | Description |
50
+ | ---- | ---- | ----------- |
51
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
52
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
53
+
54
+ <br/>
55
+
56
+ ## Post
57
+
58
+ Create a new integration for an application
59
+
60
+ ```ruby
61
+ result = client.integrations.post(
62
+ applicationId: my_application_id,
63
+ integration: my_integration)
64
+
65
+ puts result
66
+ ```
67
+
68
+ #### Authentication
69
+ The client must be configured with a valid api access token to call this
70
+ action. The token must include at least one of the following scopes:
71
+ all.Application, all.Organization, all.User, integrations.*, or integrations.post.
72
+
73
+ #### Available Parameters
74
+
75
+ | Name | Type | Required | Description | Default | Example |
76
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
77
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
78
+ | integration | [Integrations Post](_schemas.md#integrations-post) | Y | New integration information | | [Integrations Post Example](_schemas.md#integrations-post-example) |
79
+
80
+ #### Successful Responses
81
+
82
+ | Code | Type | Description |
83
+ | ---- | ---- | ----------- |
84
+ | 201 | [Integrations](_schemas.md#integrations) | Successfully created integration |
85
+
86
+ #### Error Responses
87
+
88
+ | Code | Type | Description |
89
+ | ---- | ---- | ----------- |
90
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
91
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
@@ -49,6 +49,8 @@ require_relative "losant_rest/experience_user"
49
49
  require_relative "losant_rest/experience_users"
50
50
  require_relative "losant_rest/flow"
51
51
  require_relative "losant_rest/flows"
52
+ require_relative "losant_rest/integration"
53
+ require_relative "losant_rest/integrations"
52
54
  require_relative "losant_rest/me"
53
55
  require_relative "losant_rest/org"
54
56
  require_relative "losant_rest/org_invites"
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.5.7
30
+ # Built For Version 1.6.0
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -140,6 +140,14 @@ module LosantRest
140
140
  @flows ||= Flows.new(self)
141
141
  end
142
142
 
143
+ def integration
144
+ @integration ||= Integration.new(self)
145
+ end
146
+
147
+ def integrations
148
+ @integrations ||= Integrations.new(self)
149
+ end
150
+
143
151
  def me
144
152
  @me ||= Me.new(self)
145
153
  end
@@ -186,7 +194,7 @@ module LosantRest
186
194
 
187
195
  headers["Accept"] = "application/json"
188
196
  headers["Content-Type"] = "application/json"
189
- headers["Accept-Version"] = "^1.5.7"
197
+ headers["Accept-Version"] = "^1.6.0"
190
198
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
191
199
  path = self.url + options.fetch(:path, "")
192
200
 
@@ -93,7 +93,7 @@ module LosantRest
93
93
  # The client must be configured with a valid api
94
94
  # access token to call this action. The token
95
95
  # must include at least one of the following scopes:
96
- # all.Application, all.Organization, all.User, flows.*, or flows.create.
96
+ # all.Application, all.Organization, all.User, flows.*, or flows.post.
97
97
  #
98
98
  # Parameters:
99
99
  # * {string} applicationId - ID associated with the application
@@ -0,0 +1,174 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2017 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.
22
+
23
+ module LosantRest
24
+
25
+ # Class containing all the actions for the Integration Resource
26
+ class Integration
27
+
28
+ def initialize(client)
29
+ @client = client
30
+ end
31
+
32
+ # Deletes an integration
33
+ #
34
+ # Authentication:
35
+ # The client must be configured with a valid api
36
+ # access token to call this action. The token
37
+ # must include at least one of the following scopes:
38
+ # all.Application, all.Organization, all.User, integration.*, or integration.delete.
39
+ #
40
+ # Parameters:
41
+ # * {string} applicationId - ID associated with the application
42
+ # * {string} integrationId - ID associated with the integration
43
+ # * {string} losantdomain - Domain scope of request (rarely needed)
44
+ # * {boolean} _actions - Return resource actions in response
45
+ # * {boolean} _links - Return resource link in response
46
+ # * {boolean} _embedded - Return embedded resources in response
47
+ #
48
+ # Responses:
49
+ # * 200 - If integration was successfully deleted (https://api.losant.com/#/definitions/success)
50
+ #
51
+ # Errors:
52
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
53
+ # * 404 - Error if integration was not found (https://api.losant.com/#/definitions/error)
54
+ def delete(params = {})
55
+ params = Utils.symbolize_hash_keys(params)
56
+ query_params = { _actions: false, _links: true, _embedded: true }
57
+ headers = {}
58
+ body = nil
59
+
60
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
61
+ raise ArgumentError.new("integrationId is required") unless params.has_key?(:integrationId)
62
+
63
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
64
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
65
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
66
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
67
+
68
+ path = "/applications/#{params[:applicationId]}/integrations/#{params[:integrationId]}"
69
+
70
+ @client.request(
71
+ method: :delete,
72
+ path: path,
73
+ query: query_params,
74
+ headers: headers,
75
+ body: body)
76
+ end
77
+
78
+ # Retrieves information on an integration
79
+ #
80
+ # Authentication:
81
+ # The client must be configured with a valid api
82
+ # access token to call this action. The token
83
+ # must include at least one of the following scopes:
84
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, integration.*, or integration.get.
85
+ #
86
+ # Parameters:
87
+ # * {string} applicationId - ID associated with the application
88
+ # * {string} integrationId - ID associated with the integration
89
+ # * {string} losantdomain - Domain scope of request (rarely needed)
90
+ # * {boolean} _actions - Return resource actions in response
91
+ # * {boolean} _links - Return resource link in response
92
+ # * {boolean} _embedded - Return embedded resources in response
93
+ #
94
+ # Responses:
95
+ # * 200 - integration information (https://api.losant.com/#/definitions/integration)
96
+ #
97
+ # Errors:
98
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
99
+ # * 404 - Error if integration was not found (https://api.losant.com/#/definitions/error)
100
+ def get(params = {})
101
+ params = Utils.symbolize_hash_keys(params)
102
+ query_params = { _actions: false, _links: true, _embedded: true }
103
+ headers = {}
104
+ body = nil
105
+
106
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
107
+ raise ArgumentError.new("integrationId is required") unless params.has_key?(:integrationId)
108
+
109
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
110
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
111
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
112
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
113
+
114
+ path = "/applications/#{params[:applicationId]}/integrations/#{params[:integrationId]}"
115
+
116
+ @client.request(
117
+ method: :get,
118
+ path: path,
119
+ query: query_params,
120
+ headers: headers,
121
+ body: body)
122
+ end
123
+
124
+ # Updates information about an integration
125
+ #
126
+ # Authentication:
127
+ # The client must be configured with a valid api
128
+ # access token to call this action. The token
129
+ # must include at least one of the following scopes:
130
+ # all.Application, all.Organization, all.User, integration.*, or integration.patch.
131
+ #
132
+ # Parameters:
133
+ # * {string} applicationId - ID associated with the application
134
+ # * {string} integrationId - ID associated with the integration
135
+ # * {hash} integration - Object containing new properties of the integration (https://api.losant.com/#/definitions/integrationPatch)
136
+ # * {string} losantdomain - Domain scope of request (rarely needed)
137
+ # * {boolean} _actions - Return resource actions in response
138
+ # * {boolean} _links - Return resource link in response
139
+ # * {boolean} _embedded - Return embedded resources in response
140
+ #
141
+ # Responses:
142
+ # * 200 - Updated integration information (https://api.losant.com/#/definitions/integration)
143
+ #
144
+ # Errors:
145
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
146
+ # * 404 - Error if integration was not found (https://api.losant.com/#/definitions/error)
147
+ def patch(params = {})
148
+ params = Utils.symbolize_hash_keys(params)
149
+ query_params = { _actions: false, _links: true, _embedded: true }
150
+ headers = {}
151
+ body = nil
152
+
153
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
154
+ raise ArgumentError.new("integrationId is required") unless params.has_key?(:integrationId)
155
+ raise ArgumentError.new("integration is required") unless params.has_key?(:integration)
156
+
157
+ body = params[:integration] if params.has_key?(:integration)
158
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
159
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
160
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
161
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
162
+
163
+ path = "/applications/#{params[:applicationId]}/integrations/#{params[:integrationId]}"
164
+
165
+ @client.request(
166
+ method: :patch,
167
+ path: path,
168
+ query: query_params,
169
+ headers: headers,
170
+ body: body)
171
+ end
172
+
173
+ end
174
+ end