The Client class makes API calls and translates the response to the appropriate object.
Name | Description |
---|---|
__construct | Initialize a client for making queries to the SmarterU API. By default a GuzzleHttp\Client will be automatically created as needed to communicate with the SmarterU API. |
addUsersToGroup | Make an addUsersToGroup query to the SmarterU API. This query will add any specified User(s) to the Group, but will not grant them any permissions within the Group. If you would like the Users to have any additional permissions, you must call Client::grantPermissions() after assigning the User to the Group. |
createGroup | Make a CreateGroup query to the SmarterU API. |
createUser | Make a CreateUser query to the SmarterU API. |
getAccountApi | Get the account API key. |
getHttpClient | Get the HTTP Client. If the client has not already been provided, a new default HttpClient instance will be created and returned. |
getLearnerReport | Make a GetLearnerReport query to the SmarterU API. |
getUserApi | Get the user API key. |
getXMLGenerator | Get the XML Generator. If one has not already been provided, a new default XMLGenerator instance will be created and returned. |
grantPermissions | Make a GrantPermissions request to the SmarterU API. |
listGroups | Make a ListGroups query to the SmarterU API. |
listUsers | Make a ListUsers query to the SmarterU API. |
readGroupById | Read the Group whose ID matches the one provided. |
readGroupByName | Read the Group whose name matches the one provided. |
readGroupsForUserByEmail | Read the Groups that have the specified User as a member. The User will be identified by their email address. |
readGroupsForUserByEmployeeId | Read the Groups that have the specified User as a member. The User will be identified by their employee ID. |
readGroupsForUserById | Read the Groups that have the specified User as a member. The User will be identified by their ID. |
readUserByEmail | Read the User whose email address matches the one provided. |
readUserByEmployeeId | Read the User whose employee ID matches the one provided. |
readUserById | Read the User whose ID matches the one provided. |
removeUsersFromGroup | Make a removeUsersFromGroup query to the SmarterU API. |
requestExternalAuthorizationByEmail | Make a RequestExternalAuthorization query to the SmarterU API using the email address to identify the user requesting authorization. |
requestExternalAuthorizationByEmployeeId | Make a RequestExternalAuthorization query to the SmarterU API using the employee ID to identify the user requesting authorization. |
revokePermissions | Make a RevokePermissions request to the SmarterU API. |
setAccountApi | Set the account API key. |
setHttpClient | Set the HTTP Client. |
setUserApi | Set the user API key. |
setXMLGenerator | Set the XML Generator. |
updateGroup | Make an UpdateGroup query to the SmarterU API. In the event that the Group's name and/or ID are being updated, the fields used to keep track of the old values in the Group object will be erased while making the request. This prevents outdated information from mistakenly being passed into the SmarterU API when making an additional updateGroup query after updating a Group's name and/or ID. |
updateUser | Make an UpdateUser query to the SmarterU API. In the event that the User's email address and/or employee ID are being updated, the fields used to keep track of the old values in the User object will be erased while making the request. This prevents outdated information from mistakenly being passed into the SmarterU API when making an additional updateUser query after updating a User's email address and/or employee ID. |
Description
public __construct (string $apiKey, string $apiUserKey)
Initialize a client for making queries to the SmarterU API. By default a GuzzleHttp\Client will be automatically created as needed to communicate with the SmarterU API.
Parameters
(string) $apiKey
: the account API key, used for authentication
purposes when making requests to the SmarterU API. Defaults to null.
You must set the account API key via the constructor or
setAccountApi
before invoking methods which interact with the
SmarterU API(string) $apiUserKey
: the user API key, used for authentication
purposes when making requests to the SmarterU API. Defaults to null.
You must set the user API key via the constructor or
setUserApi
before invoking methods which interact with the
SmarterU API
Return Values
void
Description
public addUsersToGroup (\User[] $users, \Group $group)
Make an addUsersToGroup query to the SmarterU API. This query will add any specified User(s) to the Group, but will not grant them any permissions within the Group. If you would like the Users to have any additional permissions, you must call Client::grantPermissions() after assigning the User to the Group.
Parameters
(\User[]) $users
: An array containing one or more Users to add to the
Group.(\Group) $group
: The Group to which the User(s) will be added.
Return Values
\Group
The Group as updated by the SmarterU API.
Throws Exceptions
\InvalidArgumentException
If the "$users" array contains a value
that is not a User.
\MissingValueException
If the "$users" array contains a User that
does not have an email address or an employee ID, or if the Group
does not have a name or an ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public createGroup (\Group $group)
Make a CreateGroup query to the SmarterU API.
Parameters
(\Group) $group
: The Group to create
Return Values
\Group
The group as created by the SmarterU API.
Throws Exceptions
\MissingValueException
If one of the Tags is missing both its
name and its ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public createUser (\User $user)
Make a CreateUser query to the SmarterU API.
Parameters
(\User) $user
: the user to create
Return Values
\User
The user as created by the API.
Throws Exceptions
\MissingValueException
If the User to be created does not have
an email address or an employee ID, or does not have a home Group.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public getAccountApi (void)
Get the account API key.
Parameters
This function has no parameters.
Return Values
string
the account API key
Description
public getHttpClient (void)
Get the HTTP Client. If the client has not already been provided, a new default HttpClient instance will be created and returned.
Parameters
This function has no parameters.
Return Values
\HttpClient
the HTTP Client
Description
public getLearnerReport (\GetLearnerReportQuery $query)
Make a GetLearnerReport query to the SmarterU API.
Parameters
(\GetLearnerReportQuery) $query
: The query by which to filter the
results of the Learner Report.
Return Values
\LearnerReport[]
A list of all LearnerReports matching the query.
Throws Exceptions
\MissingValueException
If the Group(s) or User(s) to include in
the report are not identified, or if Groups are filtered by tags
that are not identified.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public getUserApi (void)
Get the user API key.
Parameters
This function has no parameters.
Return Values
string
the user API key
Description
public getXMLGenerator (void)
Get the XML Generator. If one has not already been provided, a new default XMLGenerator instance will be created and returned.
Parameters
This function has no parameters.
Return Values
\XMLGenerator
The XML Generator.
Description
public grantPermissions (\User $user, \Group $group, string[] $permissions)
Make a GrantPermissions request to the SmarterU API.
Parameters
(\User) $user
: The User to grant permissions to.(\Group) $group
: The Group in which the User will be granted
the specified permissions.(string[]) $permissions
: The permissions to be granted to the
specified User within the specified Group.
Return Values
\User
The User as updated by the SmarterU API.
Throws Exceptions
\InvalidArgumentException
If any value in the "$permissions"
array is not a string or is not one of the permissions accepted
by the SmarterU API.
\MissingValueException
If the user whose permissions are being
modified doesn't have an email address or an employee ID, or if the
Group in which the permissions are being modified does not have a
name or an ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public listGroups (\ListGroupsQuery $query)
Make a ListGroups query to the SmarterU API.
Parameters
(\ListGroupsQuery) $query
: The query representing the Groups to return
Return Values
array
An array of any Groups returned by the SmarterU API.
Throws Exceptions
\MissingValueException
If one of the Tags by which to filter the
Groups is missing both its name and its ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public listUsers (\ListUsersQuery $query)
Make a ListUsers query to the SmarterU API.
Parameters
(\ListUsersQuery) $query
: The query representing the Users to return
Return Values
array
An array of all Users matching the parameters specified by
the query passed into the SmarterU API.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readGroupById (string $id)
Read the Group whose ID matches the one provided.
Parameters
(string) $id
: The ID of the Group to return
Return Values
?\Group
The Group as read by the API, or null if no Group
matching the provided ID exists within your SmarterU account.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readGroupByName (string $name)
Read the Group whose name matches the one provided.
Parameters
(string) $name
: The name of the Group to return
Return Values
?\Group
The Group as read by the API, or null if no Group
matching the provided name exists within your SmarterU account.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readGroupsForUserByEmail (string $email)
Read the Groups that have the specified User as a member. The User will be identified by their email address.
Parameters
(string) $email
: The email address of the User to search for.
Return Values
array
All Groups that User is a member of.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readGroupsForUserByEmployeeId (string $employeeId)
Read the Groups that have the specified User as a member. The User will be identified by their employee ID.
Parameters
(string) $employeeId
: The employee ID of the User to search for.
Return Values
array
All Groups that User is a member of.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readGroupsForUserById (string $id)
Read the Groups that have the specified User as a member. The User will be identified by their ID.
Parameters
(string) $id
: The ID of the User to search for.
Return Values
array
All Groups that User is a member of.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readUserByEmail (string $employeeId)
Read the User whose email address matches the one provided.
Parameters
(string) $employeeId
: The email address of the User to return.
Return Values
?\User
The User whose email address matches the one provided,
or null if no such User exists within your SmarterU Account.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readUserByEmployeeId (string $employeeId)
Read the User whose employee ID matches the one provided.
Parameters
(string) $employeeId
: The employee ID of the User to return.
Return Values
?\User
The User whose employee ID matches the provided ID,
or null if no such User exists within your SmarterU Account.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public readUserById (string $employeeId)
Read the User whose ID matches the one provided.
Parameters
(string) $employeeId
: The ID of the User to return.
Return Values
?\User
The User whose ID matches the provided ID,
or null if no such User exists within your SmarterU Account.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public removeUsersFromGroup (\User[] $users, \Group $group)
Make a removeUsersFromGroup query to the SmarterU API.
Parameters
(\User[]) $users
: An array containing one or more Users to remove
from the Group.(\Group) $group
: The Group from which the User(s) will be removed.
Return Values
\Group
The Group as updated by the SmarterU API.
Throws Exceptions
\InvalidArgumentException
If the "$users" array contains a value
that is not a User.
\MissingValueException
If the "$users" array contains a User that
does not have an email address or an employee ID, or if the Group
does not have a name or an ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public requestExternalAuthorizationByEmail (string $email)
Make a RequestExternalAuthorization query to the SmarterU API using the email address to identify the user requesting authorization.
Parameters
(string) $email
: The email address of the user requesting external
authorization.
Return Values
\ExternalAuthorization
A container for the authorization keys and
URL returned by the SmarterU API.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public requestExternalAuthorizationByEmployeeId (string $employeeId)
Make a RequestExternalAuthorization query to the SmarterU API using the employee ID to identify the user requesting authorization.
Parameters
(string) $employeeId
: The employee ID of the user requesting
external authorization.
Return Values
\ExternalAuthorization
A container for the authorization keys and
URL returned by the SmarterU API.
Throws Exceptions
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public revokePermissions (\User $user, \Group $group, string[] $permissions)
Make a RevokePermissions request to the SmarterU API.
Parameters
(\User) $user
: The User to revoke permissions from.(\Group) $group
: The Group in which the User will have the specified
permissions revoked.(string[]) $permissions
: The permissions to be revoked from the
specified User within the specified Group.
Return Values
array
The User as updated by the SmarterU API.
Throws Exceptions
\InvalidArgumentException
If any value in the "$permissions"
array is not a string or is not one of the permissions accepted
by the SmarterU API.
\MissingValueException
If the user whose permissions are being
modified doesn't have an email address or an employee ID, or if the
Group in which the permissions are being modified does not have a
name or an ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public setAccountApi (string $accountApi)
Set the account API key.
Parameters
(string) $accountApi
: the account API key
Return Values
self
Description
public setHttpClient (\HttpClient $httpClient)
Set the HTTP Client.
Parameters
(\HttpClient) $httpClient
: The HTTP Client
Return Values
self
Description
public setUserApi (string $userApi)
Set the user API key.
Parameters
(string) $userApi
: the user API key
Return Values
self
Description
public setXMLGenerator (\XMLGenerator $xmlGenerator)
Set the XML Generator.
Parameters
(\XMLGenerator) $xmlGenerator
: The XML generator.
Return Values
self
Description
public updateGroup (\Group $group)
Make an UpdateGroup query to the SmarterU API. In the event that the Group's name and/or ID are being updated, the fields used to keep track of the old values in the Group object will be erased while making the request. This prevents outdated information from mistakenly being passed into the SmarterU API when making an additional updateGroup query after updating a Group's name and/or ID.
Parameters
(\Group) $group
: The Group to update
Return Values
\Group
The Group as updated by the SmarterU API.
Throws Exceptions
\MissingValueException
If one of the Tags is missing both its
name and its ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.
Description
public updateUser (\User $user)
Make an UpdateUser query to the SmarterU API. In the event that the User's email address and/or employee ID are being updated, the fields used to keep track of the old values in the User object will be erased while making the request. This prevents outdated information from mistakenly being passed into the SmarterU API when making an additional updateUser query after updating a User's email address and/or employee ID.
Parameters
(\User) $user
: The User to update
Return Values
\User
The User as updated by the SmarterU API.
Throws Exceptions
\MissingValueException
If the User being updated does not have an
email address or an employee ID.
\ClientException
If the HTTP response includes a status code
indicating that an HTTP error has prevented the request from
being made.
\SmarterUException
If the response from the SmarterU API
reports a fatal error that prevents the request from executing.