from __future__ import print_function
import time
import authorizenet_rest
from authorizenet_rest.rest import ApiException

from authorizenet_rest.apis.addresses_api import AddressesApi
from pprint import pprint
import os
import sys

import imp

ExternalConfig = imp.load_source('modulename', '.\ExternalConfiguration.py')
#constants = imp.load_source('modulename', 'constants.py')

def update_customer_address(customer_id, address_id):
    # create an instance of the API class
    ExternalConfig.setConfig();
    apiclient = ExternalConfig.configureApiClient();
    authorization = ExternalConfig.getAuthorization()
    api_instance = authorizenet_rest.apis.addresses_api.AddressesApi(apiclient)

    create_customer_address = authorizenet_rest.CreateCustomerAddress("Electonics City Phase d1 update", "ABxdfC", "ABsdsC",
                                                                     "India", None, "Red Cross", "Main Cross",
                                                                     "locality", "8748486465", "784684")

    try:
        # Update  Customer Address
        api_response = api_instance.update_customer_address(customer_id, address_id, create_customer_address, authorization=authorization)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling AddressesApi->update_customer_address: %s\n" % e)

if(os.path.basename(__file__) == os.path.basename(sys.argv[0])):
    update_customer_address('1813514836','1812376674')
