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 assets, and exchanges API #7

Merged
merged 3 commits into from
Jun 11, 2018
Merged

Add assets, and exchanges API #7

merged 3 commits into from
Jun 11, 2018

Conversation

peter279k
Copy link
Member

@peter279k peter279k commented Jun 7, 2018

@josantonius, please take a look at this.
I add the list all exchanges and list all assets.

@Bilge, if possible, please review this PR and suggest the recommendation.
And I think that's the proper way to implement these two lists API.

It's related to issue #2.

Thanks.

@coveralls
Copy link

coveralls commented Jun 7, 2018

Pull Request Test Coverage Report for Build 31

  • 20 of 20 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 25: 0.0%
Covered Lines: 54
Relevant Lines: 54

💛 - Coveralls

use ScriptFUSION\Porter\Collection\CountableProviderRecords;
use ScriptFUSION\Porter\Provider\Resource\ProviderResource;

class AssetsRecord extends CountableProviderRecords
Copy link

Choose a reason for hiding this comment

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

This class and the ExchangesRecord class doesn't do anything and should be removed. Just invoke new CountableProviderRecords directly.

Copy link
Member Author

@peter279k peter279k Jun 7, 2018

Choose a reason for hiding this comment

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

Can you show some sample about invoking CountableProviderRecords class directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I see that. Using the CountableProviderRecords directly because it has no any additional argument to be assigned.

{
private $apiKey;

public function __construct(string $apiKey)
Copy link

Choose a reason for hiding this comment

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

It is bad design to specify the API key in the resource because it must be duplicated into every resource. Specify it in the connector instead, to eliminate this duplication.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should I set the encrypted env variable in .travis.yml file?

Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I also use the travis-encrypt tool to encrypt the env variable.

$response = \json_decode(
(string) $connector->fetch(
CryptoMonitor::buildExchangeApiUrl(
"v1/assets"
Copy link

Choose a reason for hiding this comment

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

Double quotes not needed here. Prefer single quotes where interpolation not used to clearly express intent. Applies throughout this repository.

final class GetAssetsTest extends TestCase
{
/** @var $apiKey This is the Coin API Key for test environment*/
private $apiKey = '4E861687-19D6-4894-87B9-E785B1EE3900';
Copy link

Choose a reason for hiding this comment

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

As mentioned before, you shouldn't be committing keys to your repository. They can be used by anyone, which is a security problem. Pass keys at invocation time via environment variables instead. This also fixes the duplication issue.


$assets = new \ArrayIterator($response);

return new AssetsRecord($assets, count($assets), $this);
Copy link

Choose a reason for hiding this comment

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

Instantiate CountableProviderRecords here instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

I use the CountableProviderRecords directly and remove the AssetsRecord and ExchangesRecord. They're useless.

@peter279k peter279k merged commit 5fb4492 into master Jun 11, 2018
@peter279k
Copy link
Member Author

It has to be merged because all request changes should be done.
Thanks for @Bilge.

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.

3 participants