Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add organization management #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
35 changes: 35 additions & 0 deletions src/Actions/ManagesOrganizations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Novu\SDK\Actions;

use Novu\SDK\Resources\Organization;
use Novu\SDK\Resources\Topic;
use Novu\SDK\Resources\Workflow;

trait ManagesOrganizations
{
/**
* Get Organizations.
*
* @return \Novu\SDK\Resources\Organization
*/
public function getOrganizationsList()
{
$response = $this->get('organizations')['data'];

return new Organization($response, $this);
}

/**
* Create a new topic.
*
* @param array $data
* @return \Novu\SDK\Resources\Organization
*/
public function createOrganization(array $data)
{
$topic = $this->post("organizations", $data)['data'];

return new Topic($topic, $this);
}
}
3 changes: 2 additions & 1 deletion src/Novu.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Novu
Actions\ManagesNotificationGroups,
Actions\ManagesNotificationTemplates,
Actions\ManagesWorkflow,
Actions\ManagesBlueprints;
Actions\ManagesBlueprints,
Actions\ManagesOrganizations;

/**
* The Novu API Key.
Expand Down
61 changes: 61 additions & 0 deletions src/Resources/Organization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Novu\SDK\Resources;

class Organization extends Resource
{
/**
* @var string
*/
public $id;

/**
* @var string
*/
public $name;

/**
* @var string
*/
public $logo;

/**
* @var array
*/
public $branding;

/**
* @var array
*/
public $partnerConfigurations;

/**
* @var string
*/
public $createdAt;


/**
* @var string
*/
public $updatedAt;


/**
* @var string
*/
public $v;


public function toArray(): array
{
$publicProperties = get_object_vars($this);

unset($publicProperties['attributes']);
unset($publicProperties['novu']);

return array_filter($publicProperties, function ($value) {
return null !== $value;
});
}
}