Skip to content

Pick daily leetcode problem #66

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

Merged
merged 3 commits into from
May 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add graphql query for getting the Daily Problem
  • Loading branch information
152334H committed May 16, 2022
commit f15b50275ba56761f7eb1f7107f9d89a93b51d1e
33 changes: 33 additions & 0 deletions src/plugins/leetcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,39 @@ impl LeetCode {
.await
}

/// Get daily problem
pub async fn get_question_daily(self) -> Result<Response, Error> {
trace!("Requesting daily problem...");
let url = &self.conf.sys.urls.get("graphql").ok_or(Error::NoneError)?;
let mut json: Json = HashMap::new();
json.insert("operationName", "daily".to_string());
json.insert(
"query",
vec![
"query daily {",
" activeDailyCodingChallengeQuestion {",
" question {",
" questionFrontendId",
" }",
" }",
"}",
]
.join("\n"),
);

Req {
default_headers: self.default_headers,
refer: None,
info: false,
json: Some(json),
mode: Mode::Post,
name: "get_question_daily",
url: (*url).to_string(),
}
.send(&self.client)
.await
}

/// Get specific problem detail
pub async fn get_question_detail(self, slug: &str) -> Result<Response, Error> {
trace!("Requesting {} detail...", &slug);
Expand Down