Threecolts Single Sign On (3C SSO) / API Callbacks / List organizations

List organizations

Request : GET /sso/organizations

Version Change
v1.0 Initial version
v1.1 Payload fixes to match tests
v1.2 DB structure change and validations

Optional GET params:

  • per_page - integer - number of organizations per page of the request. By default this is 10.
  • page - integer - the current page number. By default it is 1

Lists all organizations, their users and accounts. Paginated.

This API endpoint will be called just once to import all users from the product into the 3C manager. This will be how 3C will get all our users. We will be exporting the hub_alpha>user table.

<v1.2>

There must be only 1 owner per organization. If organization has no accounts we are not sending it in the response and if an account has no users we are not including that account in the accounts for the organization. So this may end up in a situation where an organization has 2 accounts but none of them have users, this will mean we are not sending the organization.

Accounts and organizations that have the flag deleted equal to 1 are not to be returned. (This flag is handled from the Remove calls from the API.)

For integration once this is called we will receive a csv with the representative ids for each level and we are to update them manually in our database. (organization, account, user)

</v1.2>

Еxample response:

{
    "result": "success",
    "data": [
        {
            "product_organization_id": "1",
            "organization_name": "ACME Ltd",
            "accounts": [
                {
                    "product_account_id": "2",
                    "account_name": "3C Tacicalarbitrage" | null,
                    "created_at": "2016-04-18T11:23:39.000000Z",
                    "users": [
                        {
                            "product_user_id": "3",
                            "email": "rcastro@threecolts.com",
                            "user_name": "tacticalarbitrage" | null,
                            "first_name": "Rodrigo",
                            "last_name": "Castro",
                            "time_zone": "America/Chicago" | null,
                            "external_login_type": "google" | null,
                            "password": "$P$BW___REDACTED" | null,
                            "created_at": "2016-04-18T11:23:39.000000Z",
                            "is_account_owner": true | false,
                            "is_organization_owner": true | false,
                        },
                    ]
                }
            ],
            "created_at": "2016-04-18T11:23:39.000000Z" | null
        }
    ],
    "page_number": 1,
    "per_page": 10,
    "pages_total": 1929
}
Key in response Value from field/hardcoded Extra info
result success We have no other option here. The request does not require any input. The error cases of 401,500 and etc. will not return this response and will work as normal
data Array of rows in hub_alpha>threecolts_organization
product_organization_id hub_alpha>threecolts_organization>id <v1.2> This field must be send as a string </v1.2>
organization_name hub_alpha>threecolts_organization>organization_name
accounts Array of all eligible records in hub_alpha>client. For the specific organization_id.
 We are to exclude the clients with names default, containing the values callbacks or api and with suffix _mysqli . These are system connections that are for internal purposes.
product_account_id hub_alpha>client>id <v1.1>This must be a string in the payload.</v1.1>
account_name hub_alpha>client>clientName
created_at hub_alpha>client>date_created If null send current date. Use format: 2016-04-18T11:23:39.000000Z. This format for PHP is called ATOM
users Array of client_user that match the client>id with client_user>client_id
product_user_id hub_alpha>client_user>user_id <v1.1>This must be a string in the payload.</v1.1>
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 to the field. Default value is null and if empty or its length is < 3 we are to send null otherwise the value from the field </v1.2>
first_name hub_alpha>user>names Extract first name. Before first empty space
last_name hub_alpha>user>names All names if more than one. Except the first_name (refer above for how to select it)
time_zone hub_alpha>user>timezone <v1.2> Default value is UTC . Send the value from the database</v1.2>
external_login_type null <v1.1>Adding a null value</v1.1>
password hub_alpha>user>password <v1.1>Value is added</v1.1>
created_at hub_alpha>user>date_created If null send current date. Use format: 2016-04-18T11:23:39.000000Z. For PHP this is format ATOM
is_account_owner boolean <v1.1>This is the same as is_organization_owner</v1.1>
is_organization_owner boolean <v1.2>

For this we will check if the hub_alpha>client_user>user_id matches hub_alpha>threecolts_organization>organization_owner_id. If it matches it means true if it does not it means false.</v1.2> | | created_at | Date | <v1.1>Sending current date, because validation do not allow it to be null and is irrelevant for our use cases </v1.1> | | page_numer | integer | Pagination counter Must be integer in the payload | | per_page | 10 | Hardcoded or from GET parameter per_page Must be integer in the payload | | pages_total | count( unique hub_alpha>threecolts_dev_data>organization_id) | Unique organization_id |

Is this article helpful?
0 0 0