예제 #1
0
class QuestionSetListView(APIView):
    '''
    Question Set List View
    '''
    queryset = User.objects.none()

    renderer_classes = (JSONRenderer, )

    identity_validation_client = blockscore.Client({
        'api_key': bs_key,
    })

    @cache_response(60 * 15)
    def get(self, request, format=None):
        """
        Get Question Set List.
        """

        try:
            _question_sets = self.identity_validation_client.question_sets.all(
            )
            question_sets = _question_sets.body
            content = {'data': question_sets}
            return Response(content)
        except ObjectDoesNotExist:
            raise Http404
예제 #2
0
    def setUp(self):
        try:
            self.client = blockscore.Client(
                {'api_key': os.environ['BLOCKSCORE_API']})
        except KeyError:
            sys.stderr.write(
                "To run tests, you must have a BLOCKSCORE_API environment variable with a test api key\n"
            )
            sys.exit(2)

        self.test_company = {
            "entity_name": "BlockScore",
            "tax_id": "123410000",
            "incorporation_date": "1980-08-25",
            "incorporation_state": "DE",
            "incorporation_country_code": "US",
            "incorporation_type": "corporation",
            "dbas": "BitRemite",
            "registration_number": "123123123",
            "email": "*****@*****.**",
            "url": "https://blockscore.com",
            "phone_number": "6505555555",
            "ip_address": "67.160.8.182",
            "address_street1": "1 Infinite Loop",
            "address_street2": None,
            "address_city": "Cupertino",
            "address_subdivision": "CA",
            "address_postal_code": "95014",
            "address_country_code": "US",
        }
예제 #3
0
    def setUp(self):
        try:
            self.client = blockscore.Client(
                {'api_key': os.environ['BLOCKSCORE_API']})
        except KeyError:
            sys.stderr.write(
                "To run tests, you must have a BLOCKSCORE_API environment variable with a test api key\n"
            )
            sys.exit(2)

        self.test_identity = {
            'date_of_birth': '1980-01-01',
            'identification': {
                'ssn': '0000',
                'passport': '12315235'
            },
            'name': {
                'first': 'john',
                'middle': 'a',
                'last': 'doe'
            },
            'address': {
                'street1': '1 Infinite Loop',
                'street2': 'Floor 3',
                'city': 'Palo Alto',
                'state': 'ca',
                'postal_code': '94309',
                'country_code': 'us'
            },
            'note': 'test'
        }
예제 #4
0
    def setUp(self):
        try:
            self.client = blockscore.Client(
                {'api_key': os.environ['BLOCKSCORE_API']})
        except KeyError:
            sys.stderr.write(
                "To run tests, you must have a BLOCKSCORE_API environment variable with a test api key\n"
            )
            sys.exit(2)

        self.test_identity = {
            "name_first": "John",
            "name_middle": "Pearce",
            "name_last": "Doe",
            "birth_day": "23",
            "birth_month": "8",
            "birth_year": "1980",
            "document_type": "ssn",
            "document_value": "0000",
            "address_street1": "1 Infinite Loop",
            "address_street2": "Apt 6",
            "address_city": "Cupertino",
            "address_subdivision": "CA",
            "address_postal_code": "95014",
            "address_country_code": "US",
        }
예제 #5
0
class QuestionSetDetailView(APIView):
    """
    Question Set Detail View
    """
    queryset = User.objects.none()

    renderer_classes = (JSONRenderer, )

    identity_validation_client = blockscore.Client({
        'api_key': bs_key,
    })

    def get_object(self, question_set_id, format=None):
        """
        Retrieve question set instance from Blockscore.
        """
        try:
            question_set = self.identity_validation_client.question_sets.retrieve(
                question_set_id)
            question_set_body = question_set.body
            return question_set_body
        except ObjectDoesNotExist:
            raise Http404

    def post(self, request):
        """
        Create Question Set from Person Id
        """

        form = SubmitQuestionSet(request.POST)

        if form.is_valid():
            person_id = form.cleaned_data['person_id']
            question_set = self.identity_validation_client.question_sets.create(
                person_id=person_id)
            #question_set = self.identity_validation_client.question_sets.create(person_id=person_id, time_limit=5000)
            # @note Optional time_limit argument actually causes a 500 error, and is not expected. This is an issue with blockscore's API.
            #       Further, question sets that are created through the API currently create a score expectation of "null" which is different
            # from what is documented at
            # https://docs.blockscore.com/v4.0/python/#create-a-new-question-set.
            question_set = question_set.body
            content = {'data': question_set}
            return Response(content)

    @cache_response(60 * 15)
    def get(self, request, question_set_id, format=None):
        """
        This allows you to retrieve a question set you have created. If you have already
        scored the question set, we will also return the last score of your submitted answers.
        """
        question_set = self.get_object(question_set_id)
        content = {'data': question_set}
        return Response(content)
예제 #6
0
class QuestionSetScoreDetailView(APIView):
    """
    Question Set Score Detail View Creation.
    """
    queryset = User.objects.all()

    #renderer_classes = (JSONRenderer, )

    identity_validation_client = blockscore.Client({
        'api_key': bs_key,
    })

    def post(self, request, question_set_id):
        """
        Create score validation for question set.
        """

        #form = SubmitScoreQuestionSet(request.POST)

        # if form.is_valid():

        question_1 = {'question_id': 1, 'answer_id': int(request.POST['qc1'])}

        question_2 = {'question_id': 2, 'answer_id': int(request.POST['qc2'])}

        question_3 = {'question_id': 3, 'answer_id': int(request.POST['qc3'])}

        question_4 = {'question_id': 4, 'answer_id': int(request.POST['qc4'])}

        question_5 = {'question_id': 5, 'answer_id': int(request.POST['qc5'])}

        answer_construct = [
            question_1,
            question_2,
            question_3,
            question_4,
            question_5,
        ]

        score = self.identity_validation_client.question_sets.score(
            question_set_id, answer_construct)
        score = score.body

        content = {'data': score}
        return Response(content)
예제 #7
0
class PeopleListView(APIView):
    """
    A view that returns the count of created identities in JSON.
    """

    queryset = User.objects.all()
    renderer_classes = (JSONRenderer, )

    identity_validation_client = blockscore.Client({
        'api_key': bs_key,
    })

    @cache_response(60 * 15)
    def get(self, request, format=None):
        """
        Get List View for People
        """

        people = self.identity_validation_client.people.all()
        content = {'data': people.body}
        return Response(content)
예제 #8
0
class PeopleDetailView(APIView):
    """
    Retrieve, update or delete a person instance.
    """
    queryset = User.objects.all()

    #renderer_classes = (JSONRenderer, )
    identity_validation_client = blockscore.Client({
        'api_key': bs_key,
    })

    def get_object(self, person_id):
        """
        Retrieve person instance from Blockscore.
        """

        try:
            people = self.identity_validation_client.people.retrieve(person_id)
            people_body = people.body
            return people_body
        except ObjectDoesNotExist:
            raise Http404

    def post(self, request, format=None):
        """
        This endpoint creates a new person. The information will be run
        through our verification process and then returned with additional
        information that will help you determine the authenticity of the
        information given.[0]

        —
        [0]: http://docs.blockscore.com/v4.0/python/#create-a-new-person
        """

        form = SubmitIdentity(request.POST)

        if form.is_valid():
            identity = {
                "name_first": form.cleaned_data['name_first'],
                "name_middle": form.cleaned_data['name_middle'],
                "name_last": form.cleaned_data['name_last'],
                "birth_day": form.cleaned_data['birth_day'],
                "birth_month": form.cleaned_data['birth_month'],
                "birth_year": form.cleaned_data['birth_year'],
                # Hardcoded by form
                "document_type": form.cleaned_data['document_type'],
                "document_value": form.cleaned_data['document_value'],
                "address_street1": form.cleaned_data['address_street1'],
                "address_street2": form.cleaned_data['address_street2'],
                "address_city": form.cleaned_data['address_city'],
                "address_subdivision":
                form.cleaned_data['address_subdivision'],
                "address_postal_code":
                form.cleaned_data['address_postal_code'],
                "address_country_code":
                form.cleaned_data['address_country_code'],
            }

            #json = person.json()
            #serializer = IdentitySerializer(data=json)
            #person_json = JSONRenderer().render(serializer.data)
            # if serializer.is_valid():
            # return render(
            #request, 'identity-creation-confirmation.html',
            #{'data': person_json})

            try:
                person = self.identity_validation_client.people.create(
                    identity)
                person = person.body
                content = {'data': person}
                return Response(content)
            except ObjectDoesNotExist:
                raise Http404

    @cache_response(60 * 15)
    def get(self, request, person_id, format=None):
        """
        Load person instance by Id from Blockscore.
        """

        person = self.get_object(person_id)
        #serializer = PersonSerializer(person)
        # return Response(serializer.data)
        content = {'data': person}
        return Response(content)
예제 #9
0
_source_number = source_number
twilio_client = TwilioRestClient(twilio_account, twilio_token)

dev_test_key = 'sk_test_e415139895f6cd4edd6c248f2a72ad12'
prod_test_key = 'sk_test_3e8915ed527ffa299ce00d45f7aa2bdd'
prod_live_key = 'sk_live_40eedf77cdb95ff269c62180e6fe48a8'

if settings.DEBUGBLOCKSCORE is True:
    #bs_key = dev_test_key
    bs_key = prod_live_key
else:
    bs_key = prod_live_key

identity_validation_client = blockscore.Client({
    'api_key': bs_key,
})

baseApiUrl = 'https://utxo.firebaseio.com/'
baseProp = '/name.json'
""" ========================================== Utilities  """


def string_generator(string_length=10):
    """
    Returns a random string of length string_length.
    """

    random = str(uuid.uuid4())  # Convert UUID format to a Python string.
    random = random.upper()  # Make all characters uppercase.
    random = random.replace("-", "")  # Remove the UUID '-'.
예제 #10
0
def main():
    candidates = ['verification.ini', 'blockscore.ini']
    if len(sys.argv) > 1:
        candidates.append(sys.argv[1])

    config = ConfigParser.SafeConfigParser({
        'websocket_url': 'wss://127.0.0.1/trade/',
        'username': '',
        'password': '',
        'api_key': '',
    })
    config.read(candidates)

    websocket_url = config.get('blockscore', 'websocket_url')
    username = config.get('blockscore', 'username')
    password = config.get('blockscore', 'password')
    api_key = config.get('blockscore', 'api_key')

    blockscore_client = blockscore.Client({'api_key': api_key})

    def on_verify_customer(sender, msg):
        print msg
        verification = blockscore_client.verification.create(
            date_of_birth=msg.get('VerificationData')['date_of_birth'],
            identification={'ssn': msg.get('VerificationData')['ssn']},
            name={
                'first': msg.get('VerificationData')['name']['first'],
                'middle': msg.get('VerificationData')['name']['middle'],
                'last': msg.get('VerificationData')['name']['last'],
            },
            address={
                'street1':
                msg.get('VerificationData')['address']['street1'],
                'street2':
                msg.get('VerificationData')['address']['street2'],
                'city':
                msg.get('VerificationData')['address']['city'],
                'state':
                msg.get('VerificationData')['address']['state'],
                'postal_code':
                msg.get('VerificationData')['address']['postal_code'],
                'country_code':
                msg.get('VerificationData')['address']['country_code'],
            })

        verification = verification.body

        print verification

    ws = BitExThreadedClient(websocket_url)
    ws.signal_verify_customer_update.connect(on_verify_customer)
    ws.connect()
    ws.login(username, password)

    while True:
        try:
            sleep(30)
            if ws.is_connected:
                ws.testRequest()
            else:
                try:
                    ws.close()
                except HandshakeError, e:
                    del ws
                    ws = BitExThreadedClient(websocket_url)
                    ws.signal_verify_customer_update.connect(
                        on_verify_customer)
                    ws.connect()
                    ws.login(username, password)

        except KeyboardInterrupt:
            ws.close()
            break
예제 #11
0
    def __init__(self):

        self.client = blockscore.Client(token)