Class: NewDemoApiClient::GroupClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::GroupClient
- Defined in:
- lib/test_sdk/group/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Add a user role to a group.
-
#get(group_id:, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Get a group by its ID.
-
#get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Lookup a group by its domain.
- #initialize(request_client:) ⇒ NewDemoApiClient::GroupClient constructor
-
#list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser
Get all users in a group.
-
#remove_user(user_id:, group_id:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Remove a user from a group.
-
#search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser
Get all users in a group.
-
#update(group_id:, name: nil, domain: nil, thumbnail_url: nil, analysis_email: nil, data_api_access: nil, account_manager_id: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Update a group.
-
#update_user_roles(user_id:, group_id:, role_ids:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Update the roles of a user in a group.
-
#upload_group_avatar(group_id:, image:, request_options: nil) ⇒ NewDemoApiClient::GroupResponse
Upload an avatar for a group.
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::GroupClient
18 19 20 |
# File 'lib/test_sdk/group/client.rb', line 18 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::RequestClient (readonly)
14 15 16 |
# File 'lib/test_sdk/group/client.rb', line 14 def request_client @request_client end |
Instance Method Details
#create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Add a user role to a group.
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/test_sdk/group/client.rb', line 274 def create_user_role(user_id:, group_id:, role_id: nil, role_name: nil, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), role_id: role_id, role_name: role_name }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{user_id}/user/#{group_id}" end NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body) end |
#get(group_id:, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Get a group by its ID.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/test_sdk/group/client.rb', line 75 def get(group_id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}" end NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body) end |
#get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Lookup a group by its domain.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/test_sdk/group/client.rb', line 38 def get_by_domain(domain:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "domain": domain, "sort_by": sort_by, "sort_order": sort_order, "page": page, "page_size": page_size }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group" end NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body) end |
#list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser
Get all users in a group.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/test_sdk/group/client.rb', line 156 def list_users(group_id:, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "sort_by": sort_by, "sort_order": sort_order, "page": page, "page_size": page_size }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/user/all" end NewDemoApiClient::PaginatedResponseGroupUser.from_json(json_object: response.body) end |
#remove_user(user_id:, group_id:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Remove a user from a group.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/test_sdk/group/client.rb', line 345 def remove_user(user_id:, group_id:, request_options: nil) response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{user_id}/user/#{group_id}" end NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body) end |
#search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) ⇒ NewDemoApiClient::PaginatedResponseGroupUser
Get all users in a group.
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/test_sdk/group/client.rb', line 198 def search_users(group_id:, name: nil, email: nil, sort_by: nil, sort_order: nil, page: nil, page_size: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "name": name, "email": email, "sort_by": sort_by, "sort_order": sort_order, "page": page, "page_size": page_size }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/user/search" end NewDemoApiClient::PaginatedResponseGroupUser.from_json(json_object: response.body) end |
#update(group_id:, name: nil, domain: nil, thumbnail_url: nil, analysis_email: nil, data_api_access: nil, account_manager_id: nil, request_options: nil) ⇒ NewDemoApiClient::GroupWithUsersResponse
Update a group.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/test_sdk/group/client.rb', line 113 def update(group_id:, name: nil, domain: nil, thumbnail_url: nil, analysis_email: nil, data_api_access: nil, account_manager_id: nil, request_options: nil) response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), name: name, domain: domain, thumbnail_url: thumbnail_url, analysis_email: analysis_email, data_api_access: data_api_access, account_manager_id: account_manager_id }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}" end NewDemoApiClient::GroupWithUsersResponse.from_json(json_object: response.body) end |
#update_user_roles(user_id:, group_id:, role_ids:, request_options: nil) ⇒ NewDemoApiClient::UserRoleResponse
Update the roles of a user in a group.
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/test_sdk/group/client.rb', line 314 def update_user_roles(user_id:, group_id:, role_ids:, request_options: nil) response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), role_ids: role_ids }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{user_id}/user/#{group_id}" end NewDemoApiClient::UserRoleResponse.from_json(json_object: response.body) end |
#upload_group_avatar(group_id:, image:, request_options: nil) ⇒ NewDemoApiClient::GroupResponse
Upload an avatar for a group.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/test_sdk/group/client.rb', line 238 def upload_group_avatar(group_id:, image:, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), image: NewDemoApiClient::FileUtilities.as_faraday_multipart(file_like: image) }.compact req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/avatar" end NewDemoApiClient::GroupResponse.from_json(json_object: response.body) end |