Esempio n. 1
0
def assuranceimage(request):
    consumer_key = request.GET['oauth-consumer-key']
    consumer_secret = request.GET['oauth-consumer-secret']
    access_token = request.GET['oauth-access-token']
    access_token_secret = request.GET['oauth-access-token-secret']
    type = request.GET['type']

    if consumer_key and consumer_secret and access_token and access_token_secret and type:
        api = MiiCardOAuthClaimsService(consumer_key, consumer_secret, access_token, access_token_secret)
        response = api.assurance_image(type)
    
        toReturn = HttpResponse(response, mimetype='image/png')
        toReturn['Content-Length'] = len(response)

        return toReturn
Esempio n. 2
0
def cardimage(request):
    consumer_key = request.GET['oauth-consumer-key']
    consumer_secret = request.GET['oauth-consumer-secret']
    access_token = request.GET['oauth-access-token']
    access_token_secret = request.GET['oauth-access-token-secret']

    format = request.GET['format']
    snapshot_id = request.GET['snapshot-id']
    show_email_address = request.GET['show-email-address'] == "True"
    show_phone_number = request.GET['show-phone-number'] == "True"

    if consumer_key and consumer_secret and access_token and access_token_secret:
        api = MiiCardOAuthClaimsService(consumer_key, consumer_secret, access_token, access_token_secret)
        response = api.get_card_image(snapshot_id, show_email_address, show_phone_number, format)

        toReturn = HttpResponse(response, mimetype='image/png')
        toReturn['Content-Length'] = len(response)
        
        return toReturn
Esempio n. 3
0
def home(request):
    view_model = HarnessViewModel()

    action = None

    if request.method == "POST":
        # Try parsing the form params (if any)
        view_model.consumer_key = request.POST.get('oauth-consumer-key', None)
        view_model.consumer_secret = request.POST.get('oauth-consumer-secret', None)
        view_model.access_token = request.POST.get('oauth-access-token', None)
        view_model.access_token_secret = request.POST.get('oauth-access-token-secret', None)

        view_model.social_account_type = request.POST.get('social-account-type', None)
        view_model.social_account_id = request.POST.get('social-account-id', None)

        view_model.assurance_image_type = request.POST.get('assurance-image-type', None)

        view_model.snapshot_id = request.POST.get('snapshot-id', None)
        view_model.snapshot_details_id = request.POST.get('snapshot-details-id', None)
        view_model.snapshot_pdf_id = request.POST.get('snapshot-pdf-id', None)
        view_model.snapshot_authentication_details_id = request.POST.get('snapshot-authentication-details-id', None)

        view_model.card_image_format = request.POST.get('card-image-format', None)
        view_model.card_image_show_email_address = request.POST.get('card-image-show-email-address', 'off') == 'on'
        view_model.card_image_show_phone_number = request.POST.get('card-image-show-phone-number', 'off') == 'on'
        view_model.card_image_snapshot_id = request.POST.get('card-image-snapshot-id', None)

        view_model.financial_data_modesty_limit = request.POST.get('financial-data-modesty-limit', None)
        view_model.financial_data_credit_cards_modesty_limit = request.POST.get('financial-data-credit-cards-modesty-limit', None)

        view_model.directory_criterion = request.POST.get('directory_criterion', '')
        view_model.directory_criterion_value = request.POST.get('directory_criterion_value', '')
        view_model.directory_criterion_value_hashed = request.POST.get('directory_criterion_value_hashed', 'off') == 'on'

        action = request.POST.get('btn-invoke', None)

    if action and action == "directory-search":
        directory_result = MiiCardDirectoryService().find_by(view_model.directory_criterion, view_model.directory_criterion_value, view_model.directory_criterion_value_hashed)
        if directory_result is not None:
            view_model.last_directory_search_result = prettify_claims(directory_result)
    elif action and view_model.consumer_key and view_model.consumer_secret and view_model.access_token and view_model.access_token_secret:
        api = MiiCardOAuthClaimsService(view_model.consumer_key, view_model.consumer_secret, view_model.access_token, view_model.access_token_secret)
        financial_api = MiiCardOAuthFinancialService(view_model.consumer_key, view_model.consumer_secret, view_model.access_token, view_model.access_token_secret)
        
        if action == "get-claims":
            view_model.last_get_claims_result = prettify_response(api.get_claims(), prettify_claims)
        elif action == 'is-user-assured':
            view_model.last_is_user_assured_result = prettify_response(api.is_user_assured(), None)
        elif action == 'is-social-account-assured' and view_model.social_account_type and view_model.social_account_id:
            view_model.last_is_social_account_assured_result = prettify_response(api.is_social_account_assured(view_model.social_account_id, view_model.social_account_type), None)
        elif action == 'assurance-image' and view_model.assurance_image_type:
            view_model.show_assurance_image = True
        elif action == 'card-image':
            view_model.show_card_image = True
        elif action == 'get-identity-snapshot-details':
            view_model.last_get_identity_snapshot_details_result = prettify_response(api.get_identity_snapshot_details(view_model.snapshot_details_id), prettify_identity_snapshot_details)
        elif action == 'get-identity-snapshot' and view_model.snapshot_id:
            view_model.last_get_identity_snapshot_result = prettify_response(api.get_identity_snapshot(view_model.snapshot_id), prettify_identity_snapshot)
        elif action == 'get-authentication-details':
            view_model.last_get_authentication_details_result = prettify_response(api.get_authentication_details(view_model.snapshot_authentication_details_id), prettify_identity_snapshot_authentication_details)
        elif action == 'get-identity-snapshot-pdf' and view_model.snapshot_pdf_id:
            response = api.get_identity_snapshot_pdf(view_model.snapshot_pdf_id)

            toReturn = HttpResponse(response, mimetype='application/pdf')
            toReturn['Content-Length'] = len(response)
            toReturn['Content-Disposition'] = 'attachment; filename="' + view_model.snapshot_pdf_id + '"'

            return toReturn
        elif action == 'is-credit-bureau-refresh-in-progress':
            view_model.is_credit_bureau_refresh_in_progress_result = prettify_response(api.is_credit_bureau_refresh_in_progress(), None)
        elif action == 'refresh-credit-bureau-data':
            view_model.refresh_credit_bureau_data_result = prettify_response(api.refresh_credit_bureau_data(), prettify_refresh_credit_bureau_data)
        elif action == 'is-refresh-in-progress':
            view_model.is_refresh_in_progress_result = prettify_response(financial_api.is_refresh_in_progress(), None)
        elif action == 'is-refresh-in-progress-credit-cards':
            view_model.is_refresh_in_progress_credit_cards_result = prettify_response(financial_api.is_refresh_in_progress_credit_cards(), None)
        elif action == 'refresh-financial-data':
            view_model.refresh_financial_data_result = prettify_response(financial_api.refresh_financial_data(), prettify_refresh_financial_data)
        elif action == 'refresh-financial-data-credit-cards':
            view_model.refresh_financial_data_credit_cards_result = prettify_response(financial_api.refresh_financial_data(), prettify_refresh_financial_data_credit_cards)
        elif action == 'get-financial-transactions':
            configuration = PrettifyConfiguration(view_model.financial_data_modesty_limit)
            view_model.get_financial_transactions_result = prettify_response(financial_api.get_financial_transactions(), prettify_financial_transactions, configuration)
        elif action == 'get-financial-transactions-credit-cards':
            configuration = PrettifyConfiguration(view_model.financial_data_credit_cards_modesty_limit)
            view_model.get_financial_transactions_credit_cards_result = prettify_response(financial_api.get_financial_transactions_credit_cards(), prettify_financial_transactions, configuration)

    elif action:
        view_model.show_oauth_details_required_error = True

    return render_to_response('index.html', { 'view_model': view_model }, context_instance=RequestContext(request))