losant_rest 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,138 @@
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 Experience Templates Resource
26
+ class ExperienceTemplates
27
+
28
+ def initialize(client)
29
+ @client = client
30
+ end
31
+
32
+ # Returns the experience templates for an application
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.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, experienceTemplates.*, or experienceTemplates.get.
39
+ #
40
+ # Parameters:
41
+ # * {string} applicationId - ID associated with the application
42
+ # * {string} sortField - Field to sort the results by. Accepted values are: id, creationDate, name
43
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
44
+ # * {string} page - Which page of results to return
45
+ # * {string} perPage - How many items to return per page
46
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
47
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
48
+ # * {string} templateType - Filter templates to those only of the given type. Accepted values are: page, layout, component
49
+ # * {string} losantdomain - Domain scope of request (rarely needed)
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 - Collection of experience templates (https://api.losant.com/#/definitions/experienceTemplates)
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[:sortField] = params[:sortField] if params.has_key?(:sortField)
69
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
70
+ query_params[:page] = params[:page] if params.has_key?(:page)
71
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
72
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
73
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
74
+ query_params[:templateType] = params[:templateType] if params.has_key?(:templateType)
75
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
76
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
77
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
78
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
79
+
80
+ path = "/applications/#{params[:applicationId]}/experience/templates"
81
+
82
+ @client.request(
83
+ method: :get,
84
+ path: path,
85
+ query: query_params,
86
+ headers: headers,
87
+ body: body)
88
+ end
89
+
90
+ # Create a new experience template for an application
91
+ #
92
+ # Authentication:
93
+ # The client must be configured with a valid api
94
+ # access token to call this action. The token
95
+ # must include at least one of the following scopes:
96
+ # all.Application, all.Organization, all.User, experienceTemplates.*, or experienceTemplates.post.
97
+ #
98
+ # Parameters:
99
+ # * {string} applicationId - ID associated with the application
100
+ # * {hash} experienceTemplate - New experience template information (https://api.losant.com/#/definitions/experienceTemplatePost)
101
+ # * {string} losantdomain - Domain scope of request (rarely needed)
102
+ # * {boolean} _actions - Return resource actions in response
103
+ # * {boolean} _links - Return resource link in response
104
+ # * {boolean} _embedded - Return embedded resources in response
105
+ #
106
+ # Responses:
107
+ # * 201 - Successfully created experience template (https://api.losant.com/#/definitions/experienceTemplate)
108
+ #
109
+ # Errors:
110
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
111
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
112
+ def post(params = {})
113
+ params = Utils.symbolize_hash_keys(params)
114
+ query_params = { _actions: false, _links: true, _embedded: true }
115
+ headers = {}
116
+ body = nil
117
+
118
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
119
+ raise ArgumentError.new("experienceTemplate is required") unless params.has_key?(:experienceTemplate)
120
+
121
+ body = params[:experienceTemplate] if params.has_key?(:experienceTemplate)
122
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
123
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
124
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
125
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
126
+
127
+ path = "/applications/#{params[:applicationId]}/experience/templates"
128
+
129
+ @client.request(
130
+ method: :post,
131
+ path: path,
132
+ query: query_params,
133
+ headers: headers,
134
+ body: body)
135
+ end
136
+
137
+ end
138
+ end
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module LosantRest
24
- VERSION = "1.3.2"
24
+ VERSION = "1.3.3"
25
25
  end
data/lib/losant_rest.rb CHANGED
@@ -49,6 +49,8 @@ require_relative "losant_rest/experience_endpoint"
49
49
  require_relative "losant_rest/experience_endpoints"
50
50
  require_relative "losant_rest/experience_group"
51
51
  require_relative "losant_rest/experience_groups"
52
+ require_relative "losant_rest/experience_template"
53
+ require_relative "losant_rest/experience_templates"
52
54
  require_relative "losant_rest/experience_user"
53
55
  require_relative "losant_rest/experience_users"
54
56
  require_relative "losant_rest/flow"
@@ -101,6 +101,9 @@
101
101
  "experienceGroupCount": {
102
102
  "type": "number"
103
103
  },
104
+ "experienceTemplateCount": {
105
+ "type": "number"
106
+ },
104
107
  "experienceUserCount": {
105
108
  "type": "number"
106
109
  },
@@ -42,6 +42,8 @@
42
42
  "experienceEndpoints.*",
43
43
  "experienceGroup.*",
44
44
  "experienceGroups.*",
45
+ "experienceTemplate.*",
46
+ "experienceTemplates.*",
45
47
  "experienceUser.*",
46
48
  "experienceUsers.*",
47
49
  "integration.*",
@@ -120,6 +122,11 @@
120
122
  "experienceGroup.patch",
121
123
  "experienceGroups.get",
122
124
  "experienceGroups.post",
125
+ "experienceTemplate.delete",
126
+ "experienceTemplate.get",
127
+ "experienceTemplate.patch",
128
+ "experienceTemplates.get",
129
+ "experienceTemplates.post",
123
130
  "experienceUser.delete",
124
131
  "experienceUser.get",
125
132
  "experienceUser.patch",
@@ -108,6 +108,9 @@
108
108
  "experienceGroupCount": {
109
109
  "type": "number"
110
110
  },
111
+ "experienceTemplateCount": {
112
+ "type": "number"
113
+ },
111
114
  "experienceUserCount": {
112
115
  "type": "number"
113
116
  },
@@ -50,6 +50,7 @@
50
50
  "Event",
51
51
  "ExperienceEndpoint",
52
52
  "ExperienceGroup",
53
+ "ExperienceTemplate",
53
54
  "ExperienceUser",
54
55
  "Flow",
55
56
  "SolutionUser",
@@ -48,6 +48,7 @@
48
48
  "Event",
49
49
  "ExperienceEndpoint",
50
50
  "ExperienceGroup",
51
+ "ExperienceTemplate",
51
52
  "ExperienceUser",
52
53
  "Flow",
53
54
  "SolutionUser",
@@ -57,6 +57,7 @@
57
57
  "Event",
58
58
  "ExperienceEndpoint",
59
59
  "ExperienceGroup",
60
+ "ExperienceTemplate",
60
61
  "ExperienceUser",
61
62
  "Flow",
62
63
  "SolutionUser",
@@ -49,6 +49,56 @@
49
49
  "public": {
50
50
  "type": "boolean"
51
51
  },
52
+ "reportConfigs": {
53
+ "type": "array",
54
+ "max": 10,
55
+ "items": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": [
59
+ "cron",
60
+ "toEmail"
61
+ ],
62
+ "properties": {
63
+ "id": {
64
+ "type": "string",
65
+ "max": 14
66
+ },
67
+ "cron": {
68
+ "type": "string"
69
+ },
70
+ "toEmail": {
71
+ "type": "array",
72
+ "min": 1,
73
+ "max": 10,
74
+ "items": {
75
+ "type": "string",
76
+ "format": "email",
77
+ "maxLength": 1024
78
+ }
79
+ },
80
+ "subject": {
81
+ "type": "string",
82
+ "max": 255
83
+ },
84
+ "message": {
85
+ "type": "string",
86
+ "max": 32767
87
+ },
88
+ "theme": {
89
+ "type": "string",
90
+ "enum": [
91
+ "dark",
92
+ "light"
93
+ ]
94
+ },
95
+ "timezone": {
96
+ "type": "string",
97
+ "max": 255
98
+ }
99
+ }
100
+ }
101
+ },
52
102
  "blocks": {
53
103
  "type": "array",
54
104
  "items": {
@@ -52,6 +52,56 @@
52
52
  "additionalProperties": false
53
53
  }
54
54
  },
55
+ "reportConfigs": {
56
+ "type": "array",
57
+ "max": 10,
58
+ "items": {
59
+ "type": "object",
60
+ "additionalProperties": false,
61
+ "required": [
62
+ "cron",
63
+ "toEmail"
64
+ ],
65
+ "properties": {
66
+ "id": {
67
+ "type": "string",
68
+ "max": 14
69
+ },
70
+ "cron": {
71
+ "type": "string"
72
+ },
73
+ "toEmail": {
74
+ "type": "array",
75
+ "min": 1,
76
+ "max": 10,
77
+ "items": {
78
+ "type": "string",
79
+ "format": "email",
80
+ "maxLength": 1024
81
+ }
82
+ },
83
+ "subject": {
84
+ "type": "string",
85
+ "max": 255
86
+ },
87
+ "message": {
88
+ "type": "string",
89
+ "max": 32767
90
+ },
91
+ "theme": {
92
+ "type": "string",
93
+ "enum": [
94
+ "dark",
95
+ "light"
96
+ ]
97
+ },
98
+ "timezone": {
99
+ "type": "string",
100
+ "max": 255
101
+ }
102
+ }
103
+ }
104
+ },
55
105
  "description": {
56
106
  "type": "string",
57
107
  "maxLength": 32767
@@ -65,6 +65,56 @@
65
65
  "minimum": 5,
66
66
  "maximum": 600
67
67
  },
68
+ "reportConfigs": {
69
+ "type": "array",
70
+ "max": 10,
71
+ "items": {
72
+ "type": "object",
73
+ "additionalProperties": false,
74
+ "required": [
75
+ "cron",
76
+ "toEmail"
77
+ ],
78
+ "properties": {
79
+ "id": {
80
+ "type": "string",
81
+ "max": 14
82
+ },
83
+ "cron": {
84
+ "type": "string"
85
+ },
86
+ "toEmail": {
87
+ "type": "array",
88
+ "min": 1,
89
+ "max": 10,
90
+ "items": {
91
+ "type": "string",
92
+ "format": "email",
93
+ "maxLength": 1024
94
+ }
95
+ },
96
+ "subject": {
97
+ "type": "string",
98
+ "max": 255
99
+ },
100
+ "message": {
101
+ "type": "string",
102
+ "max": 32767
103
+ },
104
+ "theme": {
105
+ "type": "string",
106
+ "enum": [
107
+ "dark",
108
+ "light"
109
+ ]
110
+ },
111
+ "timezone": {
112
+ "type": "string",
113
+ "max": 255
114
+ }
115
+ }
116
+ }
117
+ },
68
118
  "public": {
69
119
  "type": "boolean"
70
120
  },
@@ -56,6 +56,56 @@
56
56
  "public": {
57
57
  "type": "boolean"
58
58
  },
59
+ "reportConfigs": {
60
+ "type": "array",
61
+ "max": 10,
62
+ "items": {
63
+ "type": "object",
64
+ "additionalProperties": false,
65
+ "required": [
66
+ "cron",
67
+ "toEmail"
68
+ ],
69
+ "properties": {
70
+ "id": {
71
+ "type": "string",
72
+ "max": 14
73
+ },
74
+ "cron": {
75
+ "type": "string"
76
+ },
77
+ "toEmail": {
78
+ "type": "array",
79
+ "min": 1,
80
+ "max": 10,
81
+ "items": {
82
+ "type": "string",
83
+ "format": "email",
84
+ "maxLength": 1024
85
+ }
86
+ },
87
+ "subject": {
88
+ "type": "string",
89
+ "max": 255
90
+ },
91
+ "message": {
92
+ "type": "string",
93
+ "max": 32767
94
+ },
95
+ "theme": {
96
+ "type": "string",
97
+ "enum": [
98
+ "dark",
99
+ "light"
100
+ ]
101
+ },
102
+ "timezone": {
103
+ "type": "string",
104
+ "max": 255
105
+ }
106
+ }
107
+ }
108
+ },
59
109
  "blocks": {
60
110
  "type": "array",
61
111
  "items": {