Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operations #46

Merged
merged 3 commits into from
Apr 5, 2024
Merged

Operations #46

merged 3 commits into from
Apr 5, 2024

Conversation

LeonardTibben
Copy link
Contributor

endpoints for

  • get all operations
  • get single operation
  • get operation for account

I was planning on doing every operation enpoint but the pr is already getting too big.

There is also some code formatting in this pr which increases the amount of files changed a lot but is otherwise uninteresting.

Copy link
Collaborator

@tluijken tluijken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je bent er bijna denk ik.

Comment on lines 100 to 117
let mut query = String::new();
if let Some(account_id) = &self.account_id {
query.push_str(&format!("accounts/{}&", account_id));
}
if let Some(cursor) = self.cursor {
query.push_str(&format!("cursor={}&", cursor));
}
if let Some(limit) = self.limit {
query.push_str(&format!("limit={}&", limit));
}
if let Some(order) = &self.order {
query.push_str(&format!("order={:?}&", order));
}
if let Some(include_failed) = &self.include_failed {
query.push_str(&format!("include_failed={:?}&", include_failed));
}

query.trim_end_matches('&').to_string()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut query = String::new();
if let Some(account_id) = &self.account_id {
query.push_str(&format!("accounts/{}&", account_id));
}
if let Some(cursor) = self.cursor {
query.push_str(&format!("cursor={}&", cursor));
}
if let Some(limit) = self.limit {
query.push_str(&format!("limit={}&", limit));
}
if let Some(order) = &self.order {
query.push_str(&format!("order={:?}&", order));
}
if let Some(include_failed) = &self.include_failed {
query.push_str(&format!("include_failed={:?}&", include_failed));
}
query.trim_end_matches('&').to_string()
vec![
self.cursor.as_ref().map(|c| format!("cursor={}", c)),
self.limit.as_ref().map(|l| format!("limit={}", l)),
self.order.as_ref().map(|o| format!("order={}", o)),
self.include_failed.as_ref().map(|i| format!("include_failed={}", i)),
]
.build_query_parameters()

src/operations/operations_for_account_request.rs Outdated Show resolved Hide resolved
Comment on lines 100 to 116
let mut query = String::new();
if let Some(ledger_sequence) = &self.ledger_sequence {
query.push_str(&format!("&ledger_sequence={}", ledger_sequence));
}
if let Some(cursor) = &self.cursor {
query.push_str(&format!("&cursor={}", cursor));
}
if let Some(limit) = &self.limit {
query.push_str(&format!("&limit={}", limit));
}
if let Some(order) = &self.order {
query.push_str(&format!("&order={}", order));
}
if let Some(include_failed) = &self.include_failed {
query.push_str(&format!("&include_failed={}", include_failed));
}
query
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut query = String::new();
if let Some(ledger_sequence) = &self.ledger_sequence {
query.push_str(&format!("&ledger_sequence={}", ledger_sequence));
}
if let Some(cursor) = &self.cursor {
query.push_str(&format!("&cursor={}", cursor));
}
if let Some(limit) = &self.limit {
query.push_str(&format!("&limit={}", limit));
}
if let Some(order) = &self.order {
query.push_str(&format!("&order={}", order));
}
if let Some(include_failed) = &self.include_failed {
query.push_str(&format!("&include_failed={}", include_failed));
}
query
vec![
self.cursor.as_ref().map(|c| format!("cursor={}", c)),
self.limit.as_ref().map(|l| format!("limit={}", l)),
self.order.as_ref().map(|o| format!("order={}", o)),
self.include_failed.as_ref().map(|i| format!("include_failed={}", i)),
]
.build_query_parameters()

Comment on lines 13 to 71
impl SingleOperationRequest<NoOperationId> {
pub fn new() -> Self {
SingleOperationRequest::default()
}

pub fn set_operation_id(self, operation_id: String) -> SingleOperationRequest<OperationId> {
SingleOperationRequest {
operation_id: OperationId(operation_id),
}
}
}

impl Request for SingleOperationRequest<OperationId> {
fn get_query_parameters(&self) -> String {
let mut query = String::new();
query.push_str(&format!("{}", self.operation_id.0));

query.trim_end_matches('&').to_string()
}

fn build_url(&self, base_url: &str) -> String {
format!(
"{}/{}/{}",
base_url,
super::OPERATIONS_PATH,
self.get_query_parameters()
)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier mag van mij nog wel iets documentatie bij.

response struct

operations per account request

added documentation

fee stats refactor

Updated percentage

new files

response struct

operations per account request

added documentation

duplicate fix

lib.rs documenation

small fix

added operations for ledgers test

simgle operation request documentation
@tluijken tluijken merged commit 61c2942 into develop Apr 5, 2024
2 checks passed
@tluijken tluijken deleted the operations branch April 5, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants