okta / okta-sdk-php

PHP SDK for the Okta API
Apache License 2.0
38 stars 71 forks source link

Possible to pass 'sendEmail' param on all requests? #65

Closed cbiggins closed 4 years ago

cbiggins commented 4 years ago

During development it'd be great to pass activate=false and sendEmail=false on all requests. I can't see anywhere in the code for this to be added, is it possible?

Also, I noticed that the README is outdated - it needs new class names.

Thanks guys!!

bretterer commented 4 years ago

On all requests that allow that property to be passed, it is already available.

During the create calls, such as creating a user, you pass in the query array you want to pass

$user = new \Okta\Users\User();
$profile = new \Okta\Users\Profile();

$profile->setFirstName('John')
    ->setLastName('User')
    ->setLogin('auser@example.com')
    ->setEmail('auser@example.com');
$user->setProfile($profile);

$credentials = new \Okta\Users\Credentials();

$password = new \Okta\Users\Password();
$password->setPassword('Abcd1234!');

$recoveryQuestion = new \Okta\Users\RecoveryQuestion();
$recoveryQuestion->setQuestion('What Language do I write in?')
    ->setAnswer('PHP!');

$provider = new \Okta\Users\Provider();
$provider->setName('OKTA')
    ->setType('OKTA');

$credentials->setPassword($password);
$credentials->setRecoveryQuestion($recoveryQuestion);
$credentials->setProvider($provider);

$user->setCredentials($credentials);

$user->setGroupIds([
    '00gajavp1anBX8svy0h7',
    '00gajb08d19WCvbsC0h7'
]);

$user->create(['sendEmail' => false]);

There is an issue reported already to have the readme updated, and it will be addressed in #55