Ejemplo n.º 1
0
class Verifica:
    client = None
    lang = None

    def __init__(self, key, lang=VerificaLang.pt_BR):
        self.client = VerificaClient(key=key,lang=lang)

    def get_public_key(self):
        data = self.client.request(VERIFICA_VERSION,'getPublicKey')
        if int(data.get('code')) > 0:
            raise Exception(data.get('message'))
        else:
            return data.get('data').get('key')
        return False

    def validate_token(self, country, phone_number, token):
        data = self.client.request(VERIFICA_VERSION,'validateToken',dict(country=country,phone_number=phone_number,token=token))
        if int(data.get('code')) > 0:
            raise Exception(data.get('message'))
        else:
            return data.get('data')
        return False

    def delivery_token(self, country, phone_number, method=VerificaDeliveryMethod.SMS):
        data = self.client.request(VERIFICA_VERSION,'deliveryToken',dict(
            country=country,
            phone_number=phone_number,
            region=region))
        if int(data.get('code')) > 0:
            raise Exception(data.get('message'))
        else:
            return data.get('data')
        return False

    def get_country_codes(self, orderBy=VerificaOrderBy.COUNTRY_NAME):
        data = self.client.request(VERIFICA_VERSION,'getCountryCodes',dict(order=orderBy))
        if int(data.get('code')) > 0:
            raise Exception(data.get('message'))
        else:
            return [VerificaCountry(c) for c in data.get('data')]
        return False
Ejemplo n.º 2
0
 def __init__(self, key, lang=VerificaLang.pt_BR):
     self.client = VerificaClient(key=key,lang=lang)