development
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | reqwest::{Client, StatusCode}, |
| 3 | smbcloud_model::error_codes::{ErrorCode, ErrorResponse}, |
| 4 | smbcloud_network::environment::Environment, |
| 5 | smbcloud_networking::{ |
| 6 | constants::PATH_USERS_SIGN_OUT, smb_base_url_builder, smb_client::SmbClient, |
| 7 | }, |
| 8 | }; |
| 9 | |
| 10 | pub async fn logout( |
| 11 | env: Environment, |
| 12 | client: (&SmbClient, &str), |
| 13 | access_token: String, |
| 14 | ) -> Result<(), ErrorResponse> { |
| 15 | let response = match Client::new() |
| 16 | .delete(build_smb_logout_url(env, client)) |
| 17 | .header("Authorization", access_token) |
| 18 | .header("Accept", "application/json") |
| 19 | .header("Content-Type", "application/x-www-form-urlencoded") |
| 20 | .send() |
| 21 | .await |
| 22 | { |
| 23 | Ok(response) => response, |
| 24 | Err(_) => { |
| 25 | return Err(ErrorResponse::Error { |
| 26 | error_code: ErrorCode::Unknown, |
| 27 | message: ErrorCode::Unknown.message(None).to_string(), |
| 28 | }); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | match response.status() { |
| 33 | StatusCode::OK => Ok(()), |
| 34 | _ => Err(ErrorResponse::Error { |
| 35 | error_code: ErrorCode::Unauthorized, |
| 36 | message: ErrorCode::Unauthorized.message(None).to_string(), |
| 37 | }), |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | fn build_smb_logout_url(env: Environment, client: (&SmbClient, &str)) -> String { |
| 42 | let mut url_builder = smb_base_url_builder(env, client); |
| 43 | url_builder.add_route(PATH_USERS_SIGN_OUT); |
| 44 | url_builder.build() |
| 45 | } |