Skip to content

Commit

Permalink
bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
kickthedragon committed Sep 20, 2016
2 parents 9221c07 + d13d8a5 commit 858df48
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "fractal-api"
version = "0.3.0"
version = "0.3.1"
authors = [
"Iban Eguia <iban@fractal.global>",
"Eric Remigino <eric@fractal.global>",
Expand Down
28 changes: 27 additions & 1 deletion src/v1/transaction.rs
Expand Up @@ -5,7 +5,8 @@ use hyper::header::{Headers, Authorization};
use rustc_serialize::json;

use utils::{WalletAddress, Amount};
use dto::{FromDTO, GenerateTransactionDTO, TransactionDTO, PendingTransactionDTO, ResponseDTO};
use dto::{FromDTO, GenerateTransactionDTO, TransactionDTO, PendingTransactionDTO,
AuthenticationCodeDTO, ResponseDTO};

use super::{Client, VoidDTO};

Expand Down Expand Up @@ -93,6 +94,31 @@ impl Client {
}
}

/// Authenticates the pending transaction
pub fn authenticate_transaction<S: AsRef<str>>(&self,
access_token: &AccessToken,
transaction_key: S,
code: u32)
-> Result<()> {
let user_id = access_token.get_user_id();
if user_id.is_some() && !access_token.has_expired() {
let mut headers = Headers::new();
headers.set(Authorization(access_token.get_token()));
let dto = AuthenticationCodeDTO { code: code };
let _ = try!(self.send_request(Method::Post,
format!("{}authenticate_transaction/{}",
self.url,
transaction_key.as_ref()),
headers,
Some(&dto)));

Ok(())
} else {
Err(Error::Forbidden(String::from("the token must be an unexpired user token")))
}
}


/// Checks if the given wallet address is a valid wallet address and returns its associated
/// user id
pub fn get_user_id_from_wallet_address<S: AsRef<str>>(&self,
Expand Down

0 comments on commit 858df48

Please sign in to comment.