예제 #1
0
def main(argv):

    parser = argparse.ArgumentParser(description='Main Test Application')
    # times should be in YYYY-MM-dd format
    parser.add_argument('-s', '--start', required=True)
    parser.add_argument('-f', '--finish', required=True)

    parser.add_argument('-n', '--hostname', required=True)
    parser.add_argument('-u',
                        '--username',
                        default='alice.lee',
                        required=False)
    parser.add_argument('-p', '--password', default='socotra', required=False)
    args = parser.parse_args(argv)

    print 'Authenticating with tenant: ' + args.hostname
    client = SocotraClient.get_authenticated_client_for_hostname(
        args.hostname, args.username, args.password)

    start = dates.date_to_millis(args.start, 'America/Los_Angeles', '%Y-%m-%d')
    finish = dates.date_to_millis(args.finish, 'America/Los_Angeles',
                                  '%Y-%m-%d')

    token = None
    while True:
        response = client.get_events(start_timestamp=start,
                                     end_timestamp=finish,
                                     paging_token=token)
        process_events(response['events'])
        if 'pagingToken' not in response.keys():
            break
        token = response['pagingToken']
예제 #2
0
def main(argv):

    parser = argparse.ArgumentParser(description='Main Test Application')
    parser.add_argument('-n', '--hostname', required=True)
    parser.add_argument('-u',
                        '--username',
                        default='alice.lee',
                        required=False)
    parser.add_argument('-p', '--password', default='socotra', required=False)
    args = parser.parse_args(argv)

    # with open('../default_config/products/personal-auto/policy/exposures/vehicle/perils/' +
    #           'a_third_party_liability.premium.liquid', "r") as f:
    #     calculation = f.read()

    print('Authenticating with tenant: ' + args.hostname)
    client = SocotraClient.get_authenticated_client_for_hostname(
        args.hostname, args.username, args.password)

    ph_values = {'first_name': ['Gary'], 'last_name': ['Richards']}

    ph = client.create_policyholder(values=ph_values)
    ph_locator = ph['locator']

    with open('ref_exposure.json', 'r') as f:
        exp_values = json.load(f)
    with open('ref_policy.json', 'r') as f:
        policy_values = json.load(f)
    with open('ref_driver.json', 'r') as f:
        driver = json.load(f)

    peril = {'name': 'a_third_party_liability'}
    exposure = {
        'exposureName': 'vehicle',
        'fieldValues': exp_values['required'],
        'perils': [peril]
    }

    start_timestamp = dates.date_to_millis('01/10/2019', 'America/Los_Angeles',
                                           "%d/%m/%Y")
    end_timestamp = dates.date_to_millis('01/10/2020', 'America/Los_Angeles',
                                         "%d/%m/%Y")
    policy = client.create_policy('personal-auto',
                                  ph_locator,
                                  policy_start_timestamp=start_timestamp,
                                  policy_end_timestamp=end_timestamp,
                                  field_values=policy_values['required'],
                                  exposures=[exposure, exposure],
                                  finalize=False)

    print(json.dumps(policy))
    policy_locator = policy['locator']
    client.uw_policy(policy_locator)
    client.price_policy(policy_locator)
    client.finalize_policy(policy_locator)
    client.issue_policy(policy_locator)
예제 #3
0
파일: renewals.py 프로젝트: socotra/public
def main(argv):

    parser = argparse.ArgumentParser(description='Main Test Application')
    parser.add_argument('-n', '--hostname', required=True)
    parser.add_argument('-l', '--locator', required=True)
    parser.add_argument('-u',
                        '--username',
                        default='alice.lee',
                        required=False)
    parser.add_argument('-p', '--password', default='socotra', required=False)
    args = parser.parse_args(argv)

    policy_locator = args.locator

    print 'Authenticating with tenant: ' + args.hostname
    client = SocotraClient.get_authenticated_client_for_hostname(
        args.hostname, args.username, args.password)

    rn1_end = dates.date_to_millis('01/10/2021', 'America/Los_Angeles',
                                   "%d/%m/%Y")
    policy_change = {"channel": "Agent"}
    rn1 = client.create_renewal(policy_locator,
                                field_values=policy_change,
                                end_timestamp=rn1_end)
    rn1_locator = rn1['locator']
    print rn1_locator
    print json.dumps(rn1)

    rn1_price = client.price_renewal(rn1_locator)
    print json.dumps(rn1_price)
    print
    rn1 = client.get_renewal(rn1_locator)
    print json.dumps(rn1)

    accept_result = client.update_renewal(rn1_locator, action='accept')
    print json.dumps(accept_result)
    print
    rn1 = client.get_renewal(rn1_locator)
    print json.dumps(rn1)
    print rn1['documents'][0]['url']
예제 #4
0
def get_report_timestamps(startdate, enddate):
    start_timestamp = dates.date_to_millis(startdate, 'America/Los_Angeles',
                                           "%Y-%m-%d")
    end_timestamp = dates.date_to_millis(enddate, 'America/Los_Angeles',
                                         "%Y-%m-%d")
    return start_timestamp, end_timestamp
예제 #5
0
def main(argv):

    parser = argparse.ArgumentParser(description='Main Test Application')
    parser.add_argument('-n', '--hostname', required=True)
    parser.add_argument('-u',
                        '--username',
                        default='alice.lee',
                        required=False)
    parser.add_argument('-p', '--password', default='socotra', required=False)
    args = parser.parse_args(argv)

    with open(
            '../default_config/products/auto/policy/exposures/vehicle/perils/'
            + 'bodily_injury.premium.liquid', "r") as f:
        calculation = f.read()

    print 'Authenticating with tenant: ' + args.hostname
    client = SocotraClient.get_authenticated_client_for_hostname(
        args.hostname, args.username, args.password)

    ph_values = {'first_name': ['Gary'], 'last_name': ['Richards']}

    ph = client.create_policyholder(values=ph_values)
    ph_locator = ph['locator']

    with open('ref_exposure.json', 'r') as f:
        exp_values = json.load(f)
    with open('ref_policy.json', 'r') as f:
        policy_values = json.load(f)
    with open('ref_claim.json', 'r') as f:
        claim = json.load(f)

    peril = {'name': 'bodily_injury'}
    exposure = {
        'exposureName': 'vehicle',
        'fieldValues': exp_values['required'],
        'perils': [peril]
    }

    start_timestamp = dates.date_to_millis('30/11/2017', 'America/Los_Angeles',
                                           "%d/%m/%Y")
    end_timestamp = dates.date_to_millis('30/11/2018', 'America/Los_Angeles',
                                         "%d/%m/%Y")
    policy = client.create_policy('auto',
                                  ph_locator,
                                  policy_start_timestamp=start_timestamp,
                                  policy_end_timestamp=end_timestamp,
                                  field_values=policy_values['required'],
                                  field_groups=[claim, claim],
                                  exposures=[exposure, exposure],
                                  finalize=False)

    # print json.dumps(policy)
    policy_locator = policy['locator']
    client.uw_policy(policy_locator)
    client.price_policy(policy_locator)
    client.finalize_policy(policy_locator)

    # print json.dumps(policy)
    peril_id = policy['exposures'][0]['perils'][0]['displayId']
    print 'Policy Locator: ' + policy_locator
    print '-----'
    uw_result = client.uw_policy(policy_locator)
    print json.dumps(uw_result)
    print '----'
    price_result = client.price_policy(policy_locator)
    print json.dumps(price_result)
    print '----'
    detailed_price_result = client.check_existing_peril_premium(
        calculation, peril_id)
    print json.dumps(
        detailed_price_result, sort_keys=True, indent=4,
        separators=(',', ':')) + "\n"
예제 #6
0
def main(argv):

    parser = argparse.ArgumentParser(description='Main Test Application')
    parser.add_argument('-n', '--hostname', required=True)
    parser.add_argument('-l', '--locator', required=True)
    parser.add_argument('-u',
                        '--username',
                        default='alice.lee',
                        required=False)
    parser.add_argument('-p', '--password', default='socotra', required=False)
    parser.add_argument('--environment',
                        '-e',
                        help='Environment',
                        choices=['sandbox', 'iag', 'perf'],
                        default='sandbox',
                        required=False)

    args = parser.parse_args(argv)

    policy_locator = args.locator

    with open('ref_driver.json', 'r') as f:
        driver = json.load(f)

    print('Authenticating with tenant: ' + args.hostname)
    environment = args.environment
    if environment == 'iag':
        url = 'https://api-iag.socotra.com'
    elif environment == 'perf':
        url = 'https://api-db-internal.socotra.com'
    else:
        url = 'https://api.sandbox.socotra.com'
    print(url)
    client = SocotraClient.get_authenticated_client_for_hostname(args.hostname,
                                                                 args.username,
                                                                 args.password,
                                                                 api_url=url,
                                                                 debug=False)

    en1_eff = dates.date_to_millis('01/04/2020', 'America/Los_Angeles',
                                   '%d/%m/%Y')
    policy_change = {"channel": "Agent"}
    en1 = client.create_endorsement(policy_locator,
                                    'generic',
                                    effective_timestamp=en1_eff,
                                    field_values=policy_change)
    print(json.dumps(en1))
    en1_locator = en1['locator']
    print(en1_locator)

    en1_price = client.price_endorsement(en1_locator)
    print(json.dumps(en1_price))
    print()
    en1 = client.get_endorsement(en1_locator)
    print(json.dumps(en1))

    accept_result = client.update_endorsement(en1_locator, action='accept')
    print(json.dumps(accept_result))
    print()
    en1 = client.get_endorsement(en1_locator)
    print(json.dumps(en1))
    print(en1['documents'][0]['url'])