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

Add type cast for ref_data when parameter is string #70

Merged

Conversation

rodolfobandeira
Copy link
Collaborator

Follow up on your comment @dblock

subject { client.ref_data_isin('US0378331005') }

it 'converts ISIN from string to Array and do not errors out' do
expect { subject }.not_to raise_error
Copy link
Owner

Choose a reason for hiding this comment

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

This test doesn't test that the API actually works, aka that it returns the ISIN for the value you provide. Use an existing VCR that asks for 1 array item, aka we want 2 tests that it works the same way for "US0378331005" and for ["US0378331005"].

Copy link
Owner

Choose a reason for hiding this comment

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

Also probably want to highlight in README both examples (you can pass 1 value or an array of values).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Please check the latest commit

Copy link
Owner

@dblock dblock Apr 11, 2020

Choose a reason for hiding this comment

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

I still have an issue with expect { subject }.not_to raise_error, it's a test that says "make sure it doesn't throw an exception", which is weird. We expect all our calls not to throw errors ;) I'd remove it and make sure the values returned are actually correct (just like all tests).

Copy link
Owner

Choose a reason for hiding this comment

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

Also noticed that we have a nested block with different VCRs, the whole spec should look like this:

describe '#ref_data_isin' do
   context 'with one asin', vcr: { cassette_name: 'ref-data/isin' } 
   context 'with multiple asins', vcr: ...
   context 'with invalid asins', vcr: ...
end

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dblock done. What do you think now?

README.md Outdated
@@ -381,6 +381,9 @@ Converts ISIN to IEX Cloud symbols.
```ruby
symbols = client.ref_data_isin(['US0378331005'])

# You can also pass single elements as string:
Copy link
Owner

Choose a reason for hiding this comment

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

I am going to nitpick. It's not clear that you can pass an array of ISINs here because the sample has an array of 1.

I think you want both examples and not a comment.

Convert ISIN to IEX Cloud symbols.

example with 1

The API also lets you convert multiple ISINs to IEX Cloud symbols.

example with many

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@dblock
Copy link
Owner

dblock commented Oct 3, 2020

Rebase, update my nitpicks and let's merge this?

@rodolfobandeira rodolfobandeira force-pushed the add-type-safe-for-ref-data-endpoint branch from 6c6a411 to 56be92d Compare October 9, 2020 02:45
@rodolfobandeira
Copy link
Collaborator Author

@dblock Apologizes for the long time I had left this PR hanging there.
Thanks for the reminder! I believe all the nitpicks were addressed but please let me know if you'd like to recommend anything else.

Cheers

Copy link
Owner

@dblock dblock left a comment

Choose a reason for hiding this comment

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

minor changelog things please

CHANGELOG.md Outdated
@@ -9,6 +10,7 @@
* [#71](https://github.com/dblock/iex-ruby-client/pull/71): Added `symbols` resource - [@ryosuke-endo](https://github.com/ryosuke-endo).
* [#69](https://github.com/dblock/iex-ruby-client/pull/69): Fixed `ref_data_isin` request - [@bguban](https://github.com/bguban).
* [#72](https://github.com/dblock/iex-ruby-client/pull/72): Cache `Faraday::Connection` for persistent adapters - [@dblock](https://github.com/dblock).
* [#69](https://github.com/dblock/iex-ruby-client/pull/69): Fixed ref_data_isin request - [@bguban](https://github.com/bguban).
Copy link
Owner

Choose a reason for hiding this comment

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

this line sneaked in here, remove

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Removed

CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
### 1.2.1 (Next)

* [#82](https://github.com/dblock/iex-ruby-client/pull/82): Added `config.referer` to set HTTP `Referer` header. This enables IEX's "Manage domains" domain locking for tokens - [@agrberg](https://github.com/agrberg).
* [#70](https://github.com/dblock/iex-ruby-client/pull/70): Add type safe cast when ref_data_isin parameter is string - [@rodolfobandeira](https://github.com/rodolfobandeira).
Copy link
Owner

Choose a reason for hiding this comment

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

maybe 'Added support for ref_data_isin taking a single String parameter", it's unclear what a type safe cast means here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Totally agree.
Done

@dblock dblock merged commit 7cc76b7 into dblock:master Oct 9, 2020
@rodolfobandeira rodolfobandeira deleted the add-type-safe-for-ref-data-endpoint branch October 10, 2020 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants