From 8e85ceebaf8158ab0cc999d5889a320937282e58 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Fri, 30 Aug 2024 08:16:58 -0400 Subject: [PATCH] fixed up base64 encoding --- src/request.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/request.rs b/src/request.rs index e51bc3e..d08dbd0 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, process}; +use std::{collections::HashMap, process, string::String}; use base64::{engine::general_purpose::URL_SAFE, Engine as _}; use clap::ArgMatches; @@ -20,6 +20,7 @@ pub enum AuthenticationType { None, } +#[derive()] pub struct Request<'a> { pub client: Client, pub arg_value: &'a ArgMatches<'a>, @@ -69,22 +70,20 @@ impl<'a> Request<'a> { } } - pub fn auth_type(&self) { + pub fn auth_type(&self) -> String { + let key: &String = self.authentication.credentials.1.as_ref().unwrap(); match self.authentication.auth_type { - AuthenticationType::BasicAuth => { - URL_SAFE.encode(self.authentication.credentials.1.unwrap()) - } - AuthenticationType::ApiToken => self.authentication.credentials.1, + AuthenticationType::BasicAuth => URL_SAFE.encode(key), + AuthenticationType::ApiToken => key.to_string(), AuthenticationType::None => { + // TODO: make a custom error and error here instead of panicing // this shouldn't happen, ever panic!(); } } } - pub fn url_builder(&self) { - Ok() - } + pub fn url_builder(&self) -> String {} } impl Authentication {