# updateCustomer

### Update the customer's attributes

```swift
/**
 * Update existing customer.
 *
 * @param customer - Customer with all fields that needs to be updated. All customer fields except 'username', 'password' and 'lock' can be updated with this method.
 * @param onSuccess - invoked if customer successfully updated
 * @param onError - invoked if exception occurred
 *
 */
- (void) updateCustomer: (Customer*) customer
              onSuccess: (void (^)(BOOL)) onSuccess
                onError: (void (^)(NSError *error)) onError NS_SWIFT_NAME( updateCustomer(_:onSuccess:onError:) );
```

The attributes:

`username`, `password`, `lock`

are not available in customer update.

The function updates the customer created with functions `createCustomer,` `setupCustomer` and `getCustomerInfo.`

### Examples

{% tabs %}
{% tab title="Swift" %}

```swift
var customer = Customer();
customer?.firstName = "Michele-edit"
customer?.lastName = "Rossi-edit"
customer?.email = email+"edit"
customer?.language = "en"
customer?.extId="extId-12345677810-edit"
customer?.extProp1="extP1-1234567789-edit"
customer?.extProp2="extIdP2 -1234567789-edit"
customer?.ppd = false
customer?.profiling = false

let document = CustomerDocument()
document.passportNumber="PN-123456-edit"
document.personalId="personalId-123-edit"
document.memberId="memberId-123-edit"
customer?.document = document

customer?.emailVerified=false

customer?.country = "US"
customer?.birthDate = "2018-12-01"
customer?.gender = "M"
customer?.phoneNumber = "+391111111110000"
customer?.phoneVerified=false

let customFields = ["doYouLikeBeer":"yes","doYouLikeWine":"yes"]
customer?.custom = customFields

for policy in policies {
    approvedPolicies[policy] = "false"
}
customer?.policies = approvedPolicies

cloud4WiSDKWiFi.updateCustomer(customer) {_ in
    print("INFO: Update customer success")
} onError: { (error) in
    print(error)
}
```

{% endtab %}

{% tab title="Objective-C" %}

```swift
Cloud4WiSDKWiFi *cloud4WiSDKWiFi = [[Cloud4WiSDKWiFi alloc] init];
	
	Customer* customer;
	[customer setFirstName:@"Michele-edit"];
	[customer setLastName:@"Rossi-edit"];
	[customer setEmail: @"email-edit"];
	[customer setLanguage:@"en"];
	[customer setExtId: @"extId-12345677810-edit"];
	[customer setExtProp1:@"extP1-1234567789-edit"];
	[customer setExtProp2:@"extIdP2 -1234567789-edit"];
	[customer setPpd: [NSNumber numberWithBool:false]];
	[customer setProfiling:[NSNumber numberWithBool:false]];
	
	CustomerDocument* document;
	[document setPassportNumber:@""];
	[document setPersonalId:@""];
	[document setMemberId:@""];
	
	[customer setDocument:document];

	[customer setEmailVerified:false];
	
	[customer setCountry:@"US"];
	[customer setBirthDate:@"2018-12-01"];
	[customer setGender:@"M"];
	[customer setPhoneNumber:@"+391111111110000"];
	[customer setPhoneVerified:false];
	
	NSDictionary *customFields = @{@"doYouLikeBeer": @"yes", @"doYouLikeWine" : @"yes"};
	
	[customer setCustom:customFields];
	
	[cloud4WiSDKWiFi getListOfPolicies:^(NSArray<NSString *> *policies) {
		NSMutableDictionary *approvedPolicies = [[NSMutableDictionary alloc] init];
		for (NSString* policy in policies) {
			[approvedPolicies setObject:@"true" forKey:policy];
		}
		[customer setPolicies:approvedPolicies];
		
		[cloud4WiSDKWiFi updateCustomer:customer onSuccess:^(BOOL) {
			NSLog(@"INFO: Update customer success");
		} onError:^(NSError *error) {
			NSLog(@"error");
		}];
	} onError:^(NSError *error) {
		NSLog(@"error");
	}];
```

{% endtab %}
{% endtabs %}
