Class: Appwrite::Users
- Defined in:
- lib/appwrite/services/users.rb
Instance Method Summary collapse
-
#create(user_id:, email:, password:, name: nil) ⇒ User
Create a new user.
-
#delete(user_id:) ⇒ Object
Delete a user by its unique ID, thereby releasing it's ID.
-
#delete_session(user_id:, session_id:) ⇒ Object
Delete a user sessions by its unique ID.
-
#delete_sessions(user_id:) ⇒ Object
Delete all user's sessions by using the user's unique ID.
-
#get(user_id:) ⇒ User
Get a user by its unique ID.
-
#get_logs(user_id:, limit: nil, offset: nil) ⇒ LogList
Get the user activity logs list by its unique ID.
-
#get_memberships(user_id:) ⇒ MembershipList
Get the user membership list by its unique ID.
-
#get_prefs(user_id:) ⇒ Preferences
Get the user preferences by its unique ID.
-
#get_sessions(user_id:) ⇒ SessionList
Get the user sessions list by its unique ID.
-
#list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil) ⇒ UserList
Get a list of all the project's users.
-
#update_email(user_id:, email:) ⇒ User
Update the user email by its unique ID.
-
#update_email_verification(user_id:, email_verification:) ⇒ User
Update the user email verification status by its unique ID.
-
#update_name(user_id:, name:) ⇒ User
Update the user name by its unique ID.
-
#update_password(user_id:, password:) ⇒ User
Update the user password by its unique ID.
-
#update_phone(user_id:, number:) ⇒ User
Update the user phone by its unique ID.
-
#update_phone_verification(user_id:, phone_verification:) ⇒ User
Update the user phone verification status by its unique ID.
-
#update_prefs(user_id:, prefs:) ⇒ Preferences
Update the user preferences by its unique ID.
-
#update_status(user_id:, status:) ⇒ User
Update the user status by its unique ID.
Methods inherited from Service
Constructor Details
This class inherits a constructor from Appwrite::Service
Instance Method Details
#create(user_id:, email:, password:, name: nil) ⇒ User
Create a new user.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/appwrite/services/users.rb', line 51 def create(user_id:, email:, password:, name: nil) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end path = '/users' params = { userId: user_id, email: email, password: password, name: name, } headers = { "content-type": 'application/json', } @client.call( method: 'POST', path: path, headers: headers, params: params, response_type: Models::User ) end |
#delete(user_id:) ⇒ Object
Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus) endpoint instead.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/appwrite/services/users.rb', line 124 def delete(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'DELETE', path: path, headers: headers, params: params, ) end |
#delete_session(user_id:, session_id:) ⇒ Object
Delete a user sessions by its unique ID.
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/appwrite/services/users.rb', line 478 def delete_session(user_id:, session_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if session_id.nil? raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end path = '/users/{userId}/sessions/{sessionId}' .gsub('{userId}', user_id) .gsub('{sessionId}', session_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'DELETE', path: path, headers: headers, params: params, ) end |
#delete_sessions(user_id:) ⇒ Object
Delete all user's sessions by using the user's unique ID.
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/appwrite/services/users.rb', line 449 def delete_sessions(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}/sessions' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'DELETE', path: path, headers: headers, params: params, ) end |
#get(user_id:) ⇒ User
Get a user by its unique ID.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/appwrite/services/users.rb', line 91 def get(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::User ) end |
#get_logs(user_id:, limit: nil, offset: nil) ⇒ LogList
Get the user activity logs list by its unique ID.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/appwrite/services/users.rb', line 189 def get_logs(user_id:, limit: nil, offset: nil) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}/logs' .gsub('{userId}', user_id) params = { limit: limit, offset: offset, } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::LogList ) end |
#get_memberships(user_id:) ⇒ MembershipList
Get the user membership list by its unique ID.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/appwrite/services/users.rb', line 220 def get_memberships(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}/memberships' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::MembershipList ) end |
#get_prefs(user_id:) ⇒ Preferences
Get the user preferences by its unique ID.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/appwrite/services/users.rb', line 354 def get_prefs(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}/prefs' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::Preferences ) end |
#get_sessions(user_id:) ⇒ SessionList
Get the user sessions list by its unique ID.
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/appwrite/services/users.rb', line 420 def get_sessions(user_id:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end path = '/users/{userId}/sessions' .gsub('{userId}', user_id) params = { } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::SessionList ) end |
#list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil) ⇒ UserList
Get a list of all the project's users. You can use the query params to filter your results.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/appwrite/services/users.rb', line 18 def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil) path = '/users' params = { search: search, limit: limit, offset: offset, cursor: cursor, cursorDirection: cursor_direction, orderType: order_type, } headers = { "content-type": 'application/json', } @client.call( method: 'GET', path: path, headers: headers, params: params, response_type: Models::UserList ) end |
#update_email(user_id:, email:) ⇒ User
Update the user email by its unique ID.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/appwrite/services/users.rb', line 153 def update_email(user_id:, email:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end path = '/users/{userId}/email' .gsub('{userId}', user_id) params = { email: email, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_email_verification(user_id:, email_verification:) ⇒ User
Update the user email verification status by its unique ID.
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/appwrite/services/users.rb', line 548 def update_email_verification(user_id:, email_verification:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if email_verification.nil? raise Appwrite::Exception.new('Missing required parameter: "emailVerification"') end path = '/users/{userId}/verification' .gsub('{userId}', user_id) params = { emailVerification: email_verification, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_name(user_id:, name:) ⇒ User
Update the user name by its unique ID.
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/appwrite/services/users.rb', line 250 def update_name(user_id:, name:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end path = '/users/{userId}/name' .gsub('{userId}', user_id) params = { name: name, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_password(user_id:, password:) ⇒ User
Update the user password by its unique ID.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/appwrite/services/users.rb', line 285 def update_password(user_id:, password:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end path = '/users/{userId}/password' .gsub('{userId}', user_id) params = { password: password, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_phone(user_id:, number:) ⇒ User
Update the user phone by its unique ID.
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/appwrite/services/users.rb', line 320 def update_phone(user_id:, number:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end path = '/users/{userId}/phone' .gsub('{userId}', user_id) params = { number: number, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_phone_verification(user_id:, phone_verification:) ⇒ User
Update the user phone verification status by its unique ID.
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/appwrite/services/users.rb', line 583 def update_phone_verification(user_id:, phone_verification:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if phone_verification.nil? raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"') end path = '/users/{userId}/verification/phone' .gsub('{userId}', user_id) params = { phoneVerification: phone_verification, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |
#update_prefs(user_id:, prefs:) ⇒ Preferences
Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/appwrite/services/users.rb', line 386 def update_prefs(user_id:, prefs:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end path = '/users/{userId}/prefs' .gsub('{userId}', user_id) params = { prefs: prefs, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::Preferences ) end |
#update_status(user_id:, status:) ⇒ User
Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved.
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/appwrite/services/users.rb', line 513 def update_status(user_id:, status:) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end if status.nil? raise Appwrite::Exception.new('Missing required parameter: "status"') end path = '/users/{userId}/status' .gsub('{userId}', user_id) params = { status: status, } headers = { "content-type": 'application/json', } @client.call( method: 'PATCH', path: path, headers: headers, params: params, response_type: Models::User ) end |