from ..with_request import WithRequest


class Account(WithRequest):

    def __init__(self, url, session_id):
        self.base_url = url
        self.session_id=session_id

    def account_get_by_id(self, i_account):
        """Get account by id"""
        endpoint = "{0}".format('/rest/Account/get_account_info')
        auth = '{{ "session_id": "{0}" }}'.format(self.session_id)
        params = '{{ "i_account": {0} }}'.format(i_account)

        payload = {
            u'auth_info': auth,
            u'params': params
        }
        return self.post_it(endpoint, payload, {})

    def account_get_by_pin(self, pin_number):
        """Get account by pin number"""
        endpoint = "{0}".format('/rest/Account/get_account_info')
        auth = '{{ "session_id": "{0}" }}'.format(self.session_id)
        params = '{{ "id": "{0}" }}'.format(pin_number)

        payload = {
            u'auth_info': auth,
            u'params': params
        }
        return self.post_it(endpoint, payload, {})

    def account_terminate_by_id(self, i_account):
        """Terminate account by id"""
        endpoint = "{0}".format('/rest/Account/terminate_account')
        auth = '{{ "session_id": "{0}" }}'.format(self.session_id)
        params = '{{ "i_account": {0} }}'.format(i_account)

        payload = {
            u'auth_info': auth,
            u'params': params
        }
        return self.post_it(endpoint, payload, {})
