Threecolts Single Sign On (3C SSO) / API Callbacks / Update an account

Update an account

PUT /sso/organizations/{ssoOrganizationId}/accounts/{ssoAccountId}

Version Change
v1.0 Initial version
v1.2 DB Structure changes, validations and create an organization
v1.3 Add check
v1.4 Remove validation for account_name in payload

<v1.2>

{ssoOrganizationId} - integer - this will be a number which we need to match to hub_alpha>threecolts_organization>organization_id

{ssoAccountId} - integer - this will be a number which we need to match to hub_alpha>client>threecolts_account_id

Must return 200.

404 if {ssoOrganizationId} OR {ssoAccountId} are not in the database.

If {ssoAccountId} exists in the database but it is with deleted = 1. Then we consider it as non existent

Updates a 3C account (hub_alpha>client). 

If the {owner_organization} does not exists we need to create a new record with hub_alpha>threecolts_organization>organization_id = {sso_organization_id}, hub_alpha>threecolts_ogranization>organization_name = {name}, hub_alpha>threecolts_ogranization>organization_owner_id = {sso_user_id}, (from the request, please refer to the mapping). And for the field threecolts_app_id we are to use the app>id that matches the token from the authentication.

When moving account to new organization we detach (remove the record in hub_alpha>client_user) the old owner of the account (hub_alpha>threecolts_organization>organization_owner_id) from the specified account.

Please refer to the case “Moving accounts to other organizations” from the 3C docs for better understanding of the case for moving account ownership.

</v1.2>

<v1.3>

If owner_user is different from the current owner of the organization but the organization is the same return 400

</v1.3>

Еxample request:

{
    "account_name": "Rodrigo",
    "created_at": "2016-04-18T11:23:39.000000Z",
    "owner_user": {
        "sso_user_id": "3",
        "email": "rcastro@threecolts.com",
        "user_name": "tacticalarbitrage",
        "first_name": "Rodrigo",
        "last_name": "Castro",
        "time_zone": "America/Chicago"
    },
    "owner_organization": {
        "sso_organization_id": "4", // this can be different to {ssoOrganizationId} in the path if the organization owner is changing
        "name": "New Organization"
    }
}
Key in request Value from field/hardoced Extra info
account_name hub_alpha>client>clientName <v1.4>Do not update the value in clientName if this field is empty. Leave the value which was previously stored. </v1.4>
created_at hub_alpha>client>date_created Use format: 2016-04-18T11:23:39.000000Z
owner_user The information of the person that created the account.
sso_user_id hub_alpha>client>threecolts_user_id We always create a connection between user and client_user. It is by the field client_user>user.id and user.id.

<v1.2> If there is no user with this ID.user with flag deleted that equals 1 is considered non existent. First we need to create it. Otherwise just connect</v1.2> | | | email | hub_alpha>user>email | Connection between user and client_user is by the field client_user>user.id and user.id | | | user_name | hub_alpha>user>username | <v1.2> Added value. Default null if empty</v1.2> | | | first_name | hub_alpha>user>names | Concatenation between first_name and last_name to be saved in the field. With an empty space between both | | | last_name | hub_alpha>user>names | Concatenation between first_name and last_name to be saved in the field. With an empty space between both | | | time_zone | hub_alpha>user>timezone | v1.2> Default value is UTC if empty Send the value from the database.</v1.2> | | owner_organization | | N/A | This is only for changing the owner of the org for account. N/A if the owner stays the same | | | sso_organization_id | hub_alpha>client>threecolts_organization_id | <v1.2> If this is different from the one from {ssoOrganizationId} form the parameters. We need to check if this org exists or not. If it does we change the value of the field (hub_alpha>client>threecolts_organization_id) to the value ofhub_alpha>threecolts_organization>id by matching {sso_organization_id} with hub_alpha>threecolts_organization>organization_id If not we create a new organization as explained above the example and update the field with the new id </v1.2> | | | name | hub_alpha>threecolts_organization>organization_name | <v1.2> Changed table </v1.2> |

Is this article helpful?
0 0 0