Skip to content

Commit

Permalink
update version and readme, add constructor for custom agent
Browse files Browse the repository at this point in the history
  • Loading branch information
xemwebe committed Jun 17, 2024
1 parent cf6bceb commit e75e70d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "yahoo_finance_api"
version = "2.1.0"
version = "2.2.0"
authors = ["Mark Beinker <[email protected]>", "Claus Matzinger <[email protected]>"]
edition = "2018"
description = "A rust adapter for the yahoo! finance API to fetch histories of market data quotes."
Expand Down
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Release 2.2.0
+ specify user agent instead of default
+ add new method `build_with_agent(self, user_agent: &str)` to allow use of custom agent
+ constructor may fail now, returning a Result

## Release 2.1.0
+ enable to retreive asset metadata
+ enable to fetch capital gains available on Mutual Funds
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ impl Default for YahooConnector {

impl YahooConnectorBuilder {
pub fn build(self) -> Result<YahooConnector, YahooError> {
let client = Client::builder()
.user_agent( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36")
.build()?;
self.build_with_agent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36")
}

pub fn build_with_agent(self, user_agent: &str) -> Result<YahooConnector, YahooError> {
let client = Client::builder().user_agent(user_agent).build()?;

Ok(YahooConnector {
client,
Expand Down

0 comments on commit e75e70d

Please sign in to comment.