losant_rest 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,6 +46,45 @@ module LosantRest
46
46
  body: body)
47
47
  end
48
48
 
49
+ # Authenticates a solution user using the provided credentials
50
+ #
51
+ # Parameters:
52
+ # * {hash} credentials - Solution user authentication credentials (https://api.losant.com/#/definitions/solutionUserCredentials)
53
+ # * {string} losantdomain - Domain scope of request (rarely needed)
54
+ # * {boolean} _actions - Return resource actions in response
55
+ # * {boolean} _links - Return resource link in response
56
+ # * {boolean} _embedded - Return embedded resources in response
57
+ #
58
+ # Responses:
59
+ # * 200 - Successful authentication (https://api.losant.com/#/definitions/authedSolutionUser)
60
+ #
61
+ # Errors:
62
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
63
+ # * 401 - Unauthorized error if authentication fails (https://api.losant.com/#/definitions/error)
64
+ def authenticate_solution_user(params = {})
65
+ params = Utils.symbolize_hash_keys(params)
66
+ query_params = { _actions: false, _links: true, _embedded: true }
67
+ headers = {}
68
+ body = nil
69
+
70
+ raise ArgumentError.new("credentials is required") unless params.has_key?(:credentials)
71
+
72
+ body = params[:credentials] if params.has_key?(:credentials)
73
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
74
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
75
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
76
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
77
+
78
+ path = "/auth/solutionUser"
79
+
80
+ @client.request(
81
+ method: :post,
82
+ path: path,
83
+ query: query_params,
84
+ headers: headers,
85
+ body: body)
86
+ end
87
+
49
88
  # Authenticates a user using the provided credentials
50
89
  #
51
90
  # Parameters:
@@ -5,7 +5,7 @@ module LosantRest
5
5
  #
6
6
  # User API for accessing Losant data
7
7
  #
8
- # Built For Version 1.4.0
8
+ # Built For Version 1.4.3
9
9
  class Client
10
10
  attr_accessor :auth_token, :url
11
11
 
@@ -98,6 +98,22 @@ module LosantRest
98
98
  @orgs ||= Orgs.new(self)
99
99
  end
100
100
 
101
+ def solution
102
+ @solution ||= Solution.new(self)
103
+ end
104
+
105
+ def solution_user
106
+ @solution_user ||= SolutionUser.new(self)
107
+ end
108
+
109
+ def solution_users
110
+ @solution_users ||= SolutionUsers.new(self)
111
+ end
112
+
113
+ def solutions
114
+ @solutions ||= Solutions.new(self)
115
+ end
116
+
101
117
  def webhook
102
118
  @webhook ||= Webhook.new(self)
103
119
  end
@@ -112,7 +128,7 @@ module LosantRest
112
128
 
113
129
  headers["Accept"] = "application/json"
114
130
  headers["Content-Type"] = "application/json"
115
- headers["Accept-Version"] = "^1.4.0"
131
+ headers["Accept-Version"] = "^1.4.3"
116
132
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
117
133
  path = self.url + options.fetch(:path, "")
118
134
 
@@ -0,0 +1,134 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Solution Resource
4
+ class Solution
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Deletes a solution
11
+ #
12
+ # Parameters:
13
+ # * {string} orgId - ID associated with the organization
14
+ # * {string} solutionId - ID associated with the solution
15
+ # * {string} losantdomain - Domain scope of request (rarely needed)
16
+ # * {boolean} _actions - Return resource actions in response
17
+ # * {boolean} _links - Return resource link in response
18
+ # * {boolean} _embedded - Return embedded resources in response
19
+ #
20
+ # Responses:
21
+ # * 200 - If solution was successfully deleted (https://api.losant.com/#/definitions/success)
22
+ #
23
+ # Errors:
24
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
25
+ # * 404 - Error if solution was not found (https://api.losant.com/#/definitions/error)
26
+ def delete(params = {})
27
+ params = Utils.symbolize_hash_keys(params)
28
+ query_params = { _actions: false, _links: true, _embedded: true }
29
+ headers = {}
30
+ body = nil
31
+
32
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
33
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
34
+
35
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
36
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
37
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
38
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
39
+
40
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}"
41
+
42
+ @client.request(
43
+ method: :delete,
44
+ path: path,
45
+ query: query_params,
46
+ headers: headers,
47
+ body: body)
48
+ end
49
+
50
+ # Retrieves information on a solution
51
+ #
52
+ # Parameters:
53
+ # * {string} orgId - ID associated with the organization
54
+ # * {string} solutionId - ID associated with the solution
55
+ # * {string} losantdomain - Domain scope of request (rarely needed)
56
+ # * {boolean} _actions - Return resource actions in response
57
+ # * {boolean} _links - Return resource link in response
58
+ # * {boolean} _embedded - Return embedded resources in response
59
+ #
60
+ # Responses:
61
+ # * 200 - Solution information (https://api.losant.com/#/definitions/solution)
62
+ #
63
+ # Errors:
64
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
65
+ # * 404 - Error if solution was not found (https://api.losant.com/#/definitions/error)
66
+ def get(params = {})
67
+ params = Utils.symbolize_hash_keys(params)
68
+ query_params = { _actions: false, _links: true, _embedded: true }
69
+ headers = {}
70
+ body = nil
71
+
72
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
73
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
74
+
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 = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}"
81
+
82
+ @client.request(
83
+ method: :get,
84
+ path: path,
85
+ query: query_params,
86
+ headers: headers,
87
+ body: body)
88
+ end
89
+
90
+ # Updates information about a solution
91
+ #
92
+ # Parameters:
93
+ # * {string} orgId - ID associated with the organization
94
+ # * {string} solutionId - ID associated with the solution
95
+ # * {hash} solution - Object containing new properties of the solution (https://api.losant.com/#/definitions/solutionPatch)
96
+ # * {string} losantdomain - Domain scope of request (rarely needed)
97
+ # * {boolean} _actions - Return resource actions in response
98
+ # * {boolean} _links - Return resource link in response
99
+ # * {boolean} _embedded - Return embedded resources in response
100
+ #
101
+ # Responses:
102
+ # * 200 - Updated solution information (https://api.losant.com/#/definitions/solution)
103
+ #
104
+ # Errors:
105
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
106
+ # * 404 - Error if solution was not found (https://api.losant.com/#/definitions/error)
107
+ def patch(params = {})
108
+ params = Utils.symbolize_hash_keys(params)
109
+ query_params = { _actions: false, _links: true, _embedded: true }
110
+ headers = {}
111
+ body = nil
112
+
113
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
114
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
115
+ raise ArgumentError.new("solution is required") unless params.has_key?(:solution)
116
+
117
+ body = params[:solution] if params.has_key?(:solution)
118
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
119
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
120
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
121
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
122
+
123
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}"
124
+
125
+ @client.request(
126
+ method: :patch,
127
+ path: path,
128
+ query: query_params,
129
+ headers: headers,
130
+ body: body)
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,140 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Solution User Resource
4
+ class SolutionUser
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Deletes a solution user
11
+ #
12
+ # Parameters:
13
+ # * {string} orgId - ID associated with the organization
14
+ # * {string} solutionId - ID associated with the solution
15
+ # * {string} solutionUserId - ID associated with the solution user
16
+ # * {string} losantdomain - Domain scope of request (rarely needed)
17
+ # * {boolean} _actions - Return resource actions in response
18
+ # * {boolean} _links - Return resource link in response
19
+ # * {boolean} _embedded - Return embedded resources in response
20
+ #
21
+ # Responses:
22
+ # * 200 - If solution user was successfully deleted (https://api.losant.com/#/definitions/success)
23
+ #
24
+ # Errors:
25
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
26
+ # * 404 - Error if solution user was not found (https://api.losant.com/#/definitions/error)
27
+ def delete(params = {})
28
+ params = Utils.symbolize_hash_keys(params)
29
+ query_params = { _actions: false, _links: true, _embedded: true }
30
+ headers = {}
31
+ body = nil
32
+
33
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
34
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
35
+ raise ArgumentError.new("solutionUserId is required") unless params.has_key?(:solutionUserId)
36
+
37
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
38
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
39
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
40
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
41
+
42
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}/users/#{params[:solutionUserId]}"
43
+
44
+ @client.request(
45
+ method: :delete,
46
+ path: path,
47
+ query: query_params,
48
+ headers: headers,
49
+ body: body)
50
+ end
51
+
52
+ # Retrieves information on a solution user
53
+ #
54
+ # Parameters:
55
+ # * {string} orgId - ID associated with the organization
56
+ # * {string} solutionId - ID associated with the solution
57
+ # * {string} solutionUserId - ID associated with the solution user
58
+ # * {string} losantdomain - Domain scope of request (rarely needed)
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
+ # * 200 - Solution user information (https://api.losant.com/#/definitions/solutionUser)
65
+ #
66
+ # Errors:
67
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
68
+ # * 404 - Error if solution user was not found (https://api.losant.com/#/definitions/error)
69
+ def get(params = {})
70
+ params = Utils.symbolize_hash_keys(params)
71
+ query_params = { _actions: false, _links: true, _embedded: true }
72
+ headers = {}
73
+ body = nil
74
+
75
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
76
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
77
+ raise ArgumentError.new("solutionUserId is required") unless params.has_key?(:solutionUserId)
78
+
79
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
80
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
81
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
82
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
83
+
84
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}/users/#{params[:solutionUserId]}"
85
+
86
+ @client.request(
87
+ method: :get,
88
+ path: path,
89
+ query: query_params,
90
+ headers: headers,
91
+ body: body)
92
+ end
93
+
94
+ # Updates information about a solution user
95
+ #
96
+ # Parameters:
97
+ # * {string} orgId - ID associated with the organization
98
+ # * {string} solutionId - ID associated with the solution
99
+ # * {string} solutionUserId - ID associated with the solution user
100
+ # * {hash} solutionUser - Object containing new properties of the solution user (https://api.losant.com/#/definitions/solutionUserPatch)
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
+ # * 200 - Updated solution user information (https://api.losant.com/#/definitions/solutionUser)
108
+ #
109
+ # Errors:
110
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
111
+ # * 404 - Error if solution user was not found (https://api.losant.com/#/definitions/error)
112
+ def patch(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("orgId is required") unless params.has_key?(:orgId)
119
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
120
+ raise ArgumentError.new("solutionUserId is required") unless params.has_key?(:solutionUserId)
121
+ raise ArgumentError.new("solutionUser is required") unless params.has_key?(:solutionUser)
122
+
123
+ body = params[:solutionUser] if params.has_key?(:solutionUser)
124
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
125
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
126
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
127
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
128
+
129
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}/users/#{params[:solutionUserId]}"
130
+
131
+ @client.request(
132
+ method: :patch,
133
+ path: path,
134
+ query: query_params,
135
+ headers: headers,
136
+ body: body)
137
+ end
138
+
139
+ end
140
+ end
@@ -0,0 +1,104 @@
1
+ module LosantRest
2
+
3
+ # Class containing all the actions for the Solution Users Resource
4
+ class SolutionUsers
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Returns the users for the solution
11
+ #
12
+ # Parameters:
13
+ # * {string} orgId - ID associated with the organization
14
+ # * {string} solutionId - ID associated with the solution
15
+ # * {string} sortField - Field to sort the results by. Accepted values are: email, firstName, lastName, id, creationDate, lastLogin
16
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
17
+ # * {string} page - Which page of results to return
18
+ # * {string} perPage - How many items to return per page
19
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: email, firstName, lastName
20
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
21
+ # * {string} losantdomain - Domain scope of request (rarely needed)
22
+ # * {boolean} _actions - Return resource actions in response
23
+ # * {boolean} _links - Return resource link in response
24
+ # * {boolean} _embedded - Return embedded resources in response
25
+ #
26
+ # Responses:
27
+ # * 200 - Collection of solution users (https://api.losant.com/#/definitions/solutionUsers)
28
+ #
29
+ # Errors:
30
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
31
+ def get(params = {})
32
+ params = Utils.symbolize_hash_keys(params)
33
+ query_params = { _actions: false, _links: true, _embedded: true }
34
+ headers = {}
35
+ body = nil
36
+
37
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
38
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
39
+
40
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
41
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
42
+ query_params[:page] = params[:page] if params.has_key?(:page)
43
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
44
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
45
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
46
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
47
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
48
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
49
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
50
+
51
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}/users"
52
+
53
+ @client.request(
54
+ method: :get,
55
+ path: path,
56
+ query: query_params,
57
+ headers: headers,
58
+ body: body)
59
+ end
60
+
61
+ # Create a new solution user
62
+ #
63
+ # Parameters:
64
+ # * {string} orgId - ID associated with the organization
65
+ # * {string} solutionId - ID associated with the solution
66
+ # * {hash} solutionUser - New solution user information (https://api.losant.com/#/definitions/solutionUserPost)
67
+ # * {string} losantdomain - Domain scope of request (rarely needed)
68
+ # * {boolean} _actions - Return resource actions in response
69
+ # * {boolean} _links - Return resource link in response
70
+ # * {boolean} _embedded - Return embedded resources in response
71
+ #
72
+ # Responses:
73
+ # * 201 - Successfully created solution user (https://api.losant.com/#/definitions/solutionUser)
74
+ #
75
+ # Errors:
76
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
77
+ def post(params = {})
78
+ params = Utils.symbolize_hash_keys(params)
79
+ query_params = { _actions: false, _links: true, _embedded: true }
80
+ headers = {}
81
+ body = nil
82
+
83
+ raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
84
+ raise ArgumentError.new("solutionId is required") unless params.has_key?(:solutionId)
85
+ raise ArgumentError.new("solutionUser is required") unless params.has_key?(:solutionUser)
86
+
87
+ body = params[:solutionUser] if params.has_key?(:solutionUser)
88
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
89
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
90
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
91
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
92
+
93
+ path = "/orgs/#{params[:orgId]}/solutions/#{params[:solutionId]}/users"
94
+
95
+ @client.request(
96
+ method: :post,
97
+ path: path,
98
+ query: query_params,
99
+ headers: headers,
100
+ body: body)
101
+ end
102
+
103
+ end
104
+ end