Skip to content

update for api v2.0#7

Closed
galperins4 wants to merge 23 commits intoArkEcosystem:developfrom
galperins4:develop
Closed

update for api v2.0#7
galperins4 wants to merge 23 commits intoArkEcosystem:developfrom
galperins4:develop

Conversation

@galperins4
Copy link
Copy Markdown
Contributor

Please see https://docs.ark.io/docs/contributing for details before opening your pull request.

  • added v2 api methods
  • added config for service/port switching
  • updated readme with progress
  • slightly modified install instructions

* update install instructions

* Update transport.py

* update transport for port 4002

* Update install instructions for develop branch

* fixed transport wonkiness
* Delete __init__.py

* initial API v2 classes

* updated ark.py new config.py

added api v2 methods to ark.py
added config.py to manage port switching for connections (e.g., p2p, public API / webhooks)

* Update README.md

* update setup to remove p2p folder

* Delete config.py

* update ark to move config in as method

* Update ark.py

* update ark.py to fix typo

* fix typo in switch config

* update for new api reference for api v2

* update api.py

remove json error message as it causes key error with v2 api

* fix typo

* fix typos

* fix typo

* fix typo

* typo

* added missing parameters

* updated items completed
Comment thread README.md Outdated
git clone https://github.com/ArkEcosystem/python-client
cd python-client
sudo python3 setup.py install
pip3 install setuptools
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no need for pip3 install setuptools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will remove

Copy link
Copy Markdown
Contributor

@roks0n roks0n left a comment

Choose a reason for hiding this comment

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

There's also a lot of flake8 errors in Travis

Comment thread ark/two/peer.py Outdated
class Peer2(API):

def peer(self, ip):
return self.get(f'api/v2/peers/{ip}')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this syntax only works in py3.6, we are supporting 3.4+

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change them all to use the .format() nomeclature

Comment thread ark/ark.py Outdated
raise NotImplementedError()
return Vote2(self)

def switchConfig(self, service, nethash):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you follow the official guidelines (check naming section). I'd like us to follow official Python guidelines so we follow the standards.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I ended up using camelcase for functions as needed to be consistent. Let me know if I should rename

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

camelcase is used for classes/exceptions. For methods/functions you should use lowercase snake case.

Comment thread ark/two/api.py Outdated
import requests


class API(ABC):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there's no need for an abstract base class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will remove

Comment thread ark/two/delegate.py
def delegate(self, id):
return self.get(f'api/v2/delegates/{id}')

def delegates(self, parameters=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of accepting dictionary for parameters, why not specify which args/kwargs can user pass in?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wanted the API calls to be as flexible and clean as possible. Also if any changes are made in the future to API inputs it won't break the API call and then we can just focus on maintaining the docstrings

Copy link
Copy Markdown
Contributor Author

@galperins4 galperins4 left a comment

Choose a reason for hiding this comment

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

Made all the changes as requested

@mihazelnik
Copy link
Copy Markdown

Can you also write some tests for this? use pytest for testing

@galperins4
Copy link
Copy Markdown
Contributor Author

Will add this as a to do item for future releases

Copy link
Copy Markdown
Contributor Author

@galperins4 galperins4 left a comment

Choose a reason for hiding this comment

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

added snake_case as needed

Copy link
Copy Markdown
Contributor Author

@galperins4 galperins4 left a comment

Choose a reason for hiding this comment

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

fixed the remaining flake8 errors

Copy link
Copy Markdown
Contributor Author

@galperins4 galperins4 left a comment

Choose a reason for hiding this comment

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

fixed more flake8 errors

@tsifrer
Copy link
Copy Markdown

tsifrer commented Jun 18, 2018

Sorry, but need to close this PR as we're going to restructure the client to be somewhat similar to other implementations of ark client. Thank you for your contributions so far. Until further notice (until we're happy with the base of the client) all future contributions will be closed and not merged in: https://github.com/ArkEcosystem/python-client#contributions-are-closed

@tsifrer tsifrer closed this Jun 18, 2018
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.

4 participants