updateProfile with delete

AppDelegate.reachfive().updateProfile(authToken, ProfileUpdate)

Description

Update a user profile including removing a field.

This method allows you to remove a field from the user profile, whereas the updateProfile method only lets you update fields.
  • The profile must have been granted the full_write scope at the last authentication.

  • The email and the password fields of the profile can’t be updated with this method, except if the profile has no email address (usually when it is not provided by the social provider). Instead, use the updateEmail method.

  • The phoneNumber field of the profile can’t be updated if the SMS feature is activated on the account settings.

Examples

import Reach5

let profileAuthToken: AuthToken = // Here paste the authorization token of the profile retrieved after login

AppDelegate
  .reachfive()
  .updateProfile(
      authToken: profileAuthToken,
      profileUpdate: ProfileUpdate(phoneNumber: .Delete)
  )
  .onSuccess { updatedProfile in
    // Get the updated profile
  }
  .onFailure { error in
    // Return a ReachFive error
  }

Parameters

Parameter Description

authToken AuthToken

Authorization token of the profile retrieved from login.

idToken string

The ID token JSON Web Token (JWT) that contains the profile’s information.

accessToken string

The authorization credential JSON Web Token (JWT) used to access the ReachFive API.

refreshToken string

The refresh token JSON Web Token (JWT) used to obtain new access tokens once they expire.

tokenType string

The type of token. Always equal to Bearer.

expiresIn number

The lifetime in seconds of the access token.

If expiresIn is less than or equal to 0, the AuthToken is expired.

user OpenIdUser

The user’s information contained in the ID token.

Diff Data

Field Description

Update(newValue)

Update the field with the given new value.

Delete

Delete the value of the field.

NoOp (the default)

Don’t change the field.

ProfileUpdate ProfileUpdate

The profile with the new data. Each field is a Diff.

Field Description

givenName Diff<string>

The given name of the profile.

middleName Diff<string>

The middle name of the profile.

familyName Diff<string>

The family name of the profile.

name Diff<string>

The full name of the profile.

nickname Diff<string>

The nickname of the profile.

birthdate Diff<string>

The birthdate of the profile, represented as an ISO 8601 YYYY-MM-DD format.

picture Diff<string>

The URL of one of the profile picture. This URL refers to an image file (PNG, JPEG, or GIF image file).

username Diff<string>

The username of the profile (the login’s name).

gender Diff<string>

The gender of the profile.

Allowed values are female, male and other.

email Diff<string>

The primary email address of the profile.

phoneNumber Diff<string>

The primary phone number of the profile.

Both the international format and the national conventions of the account’s country are accepted if configured in account settings.

customIdentifier Diff<string>

A string that allows users to authenticate with something other than an email or phone_number.

Each custom_identifier value must be unique. The custom_identifier must be between 4-80 characters.

locale Diff<string>

The profile’s language code in lowercase and country code in uppercase, separated by a dash (e.g. en, fr-FR …​).

company Diff<string>

The company associated with the profile.

Response

Return the profile with the updated data. If parameters are not valid or if the full_write scope is missing, the promise will be rejected and will return a ReachFiveError.

Profile

id string

The ReachFive identifier of the profile.

givenName string

The given name of the profile.

middleName string

The middle name of the profile.

familyName string

The family name of the profile.

name string

The full name of the profile.

nickname string

The nickname of the profile.

birthdate string

The birthdate of the profile, represented as an ISO 8601 YYYY-MM-DD format.

profileURL string

The URL of one of the user’s profile page (usually a social provider’s page).

picture string

The URL of one of the profile picture. This URL refers to an image file (PNG, JPEG, or GIF image file).

externalId string

The external identifier of the profile.

authTypes String[]

The list of the authentication providers used to login by the profile (e.g. facebook, password …​).

loginSummary LoginSummary

The login activities history of the profile.

firstLogin string

The time of the first login.

lastLogin string

The time of the last login.

total string

The number of login.

origins string

Some additional information about the login.

devices string

The devices used for login (desktop, ios, android, mobile_web and windows_phone).

lastProvider string

The last provider used for login (e.g. local, lite, facebook …​).

username string

The username of the profile (the login’s name).

gender string

The gender of the profile.

Allowed values are female, male and other.

email string

The primary email address of the profile.

emailVerified boolean

true if the profile’s e-mail address has been verified; otherwise false.

emails Emails

The e-mail addresses of the profile.

verified string[]

The list of the verified e-mail addresses of the profile.

unverified string[]

The list of the unverified e-mail addresses of the profile.

phoneNumber string

The primary phone number of the profile.

Both the international format and the national conventions of the account’s country are accepted if configured in account settings.

phoneNumberVerified boolean

true if the user’s phone number has been verified; otherwise false.

addresses List of ProfileAddress

The list of the profile’s postal addresses. To get this attribute, the profile must have been granted the address scope at the last authentication.

title string

The title of the address.

This value can’t be an empty string.

isDefault boolean

Whether the address is the default postal address of the profile. Only a single address can be the default address.

Defaults to true.

addressType string

The type of address

Allowed values: delivery or billing.

streetAddress string

The full street address component which may include the house number, the street’s name and the extended street address information separated by newlines.

This value can’t be an empty string.

addressComplement

A complementary address field which can contain additional information about the address.

locality string

The name of the city.

region string

The name of the region.

postalCode string

The zip code.

country string

The name of the country.

This value can’t be an empty string.

deliveryNote string

An additional note from the profile for the delivery.

recipient string

The name of the recipient located at this address.

company string

The name of the company located at this address.

phoneNumber string

The phone number of the contact point at this address (no format validation is required).

locale string

The profile’s language code in lowercase and country code in uppercase, separated by a dash (e.g. en, fr-FR …​).

bio string

The biography of the profile.

customFields Map<string, any>

The custom fields of the profile.

consents Map<string, Consent>

The consents granted to the profile. It is a map of string keys with the associated consent object.

granted boolean

Whether the consent was granted to the profile or not.

consentType boolean

The type of consent.

Allowed values: opt-in opt-out.

date string

The time the consent was last updated.

createdAt string

The time the profile’s information was created.

updatedAt string

The time the profile’s information was last updated.

ReachFiveError

Based on the problem, the ReachFiveError will be:

  • AuthCanceled: The user cancelled the request or no credential was available in the keychain.

  • RequestError(apiError: ApiError) for a Bad Request (status 400) error.

  • AuthFailure(reason: String, apiError: ApiError?) mainly for Unauthorized (status 401) error.

  • TechnicalError(reason: String, apiError: ApiError?) if it’s an Internal Server Error (status 500) or other internal errors.

ApiError

error string

The main error message.

errorId string

The identifier of the error.

errorUserMsg string

The user-friendly error message.

This property is translated according to the user’s OS and app settings. Currently supported languages:
Currently supported languages
  • ar - العربية Arabic

  • de - Deutsch German

  • en - English

  • es - Español Spanish

  • fr - Français French

  • hu - Magyar Hungarian

  • it - Italiano Italian

  • jp - 日本 Japanese

  • ko - 한국인 Korean

  • nl - Nederlands Dutch

  • pt - Portuguese

  • ru - Ру́сский Russian

  • sk - Slovenský Slovak

  • zh-CN - People’s Republic of China Simplified Chinese

  • zh-Hans - Simplified Chinese

  • zh-Hant - Traditional Chinese

  • zh-HK - Hong Kong Traditional Chinese

  • zh-MO - Macao Traditional Chinese

  • zh-SG - Singapore Simplified Chinese

  • zh-TW - Taiwan Traditional Chinese

errorMessageKey string

The error message key.

errorDescription string

The technical error message.

errorDetails FieldError[]

field string

The field concerned by the error.

message string

The message error returned for the field.

code string

The code error returned for the field.