Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/GetCourse/core/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Model
* Название аккаунта GetCourse
*/
private static $accountName = '';
/**
* Домен (будет использоваться вместо account_name.getcourse.ru)
* Без https://, без `/` в конце
*/
private static string $customDomain = '';

public static function setAccessToken($accessToken) {
self::$accessToken = $accessToken;
Expand All @@ -32,10 +37,17 @@ public static function setAccessToken($accessToken) {
public static function setAccountName($accountName) {
self::$accountName = $accountName;
}

public static function setCustomDomain($domain) {
self::$customDomain = $domain;
}

public static function getUrl() {
if(!self::$accountName) {
throw new \Exception("Account name not supplied");
if(!self::$accountName && !self::$customDomain) {
throw new \Exception("Account name and Domain not supplied");
}
if (self::$customDomain) {
return 'https://' . self::$customDomain . '/pl/api/';
}
return 'https://' . self::$accountName . '.getcourse.ru/pl/api/';
}
Expand Down
4 changes: 3 additions & 1 deletion sample/dealadd.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

// Замените на ваш аккаунт
$deal::setAccountName('account_name');
// или укажите свой домен, если в аккаунте настроен редирект с your_account.getcourse.ru на ваш домен my-domain.ru
// $user::setCustomDomain('my-domain.ru')
// Замените токен на сгенерированный вашим аккаунтом (http://{your_account}.getcourse.ru/saas/account/api)
$deal::setAccessToken('secret_key');

Expand All @@ -29,4 +31,4 @@
echo $e->getMessage();
}

print_r( $result );
print_r( $result );
4 changes: 3 additions & 1 deletion sample/useradd.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

// Замените на ваш аккаунт
$user::setAccountName('account_name');
// или укажите свой домен, если в аккаунте настроен редирект с your_account.getcourse.ru на ваш домен my-domain.ru
// $user::setCustomDomain('my-domain.ru')
// Замените токен на сгенерированный вашим аккаунтом (http://{your_account}.getcourse.ru/saas/account/api)
$user::setAccessToken('secret_key');

Expand All @@ -27,4 +29,4 @@
echo $e->getMessage();
}

print_r( $result );
print_r( $result );