Skip to content

Commit

Permalink
Aggiunta risorsa Users
Browse files Browse the repository at this point in the history
  • Loading branch information
HighLiuk committed Feb 9, 2022
1 parent 95bb40c commit f9937a6
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/Users/Users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Mediatoolkit\ActiveCampaign\Users;


use Mediatoolkit\ActiveCampaign\Resource;

/**
* Class Users
* @package Mediatoolkit\ActiveCampaign\Users
* @see https://developers.activecampaign.com/reference#users
*/
class Users extends Resource
{

/**
* Create a user
* @see https://developers.activecampaign.com/reference#create-new-user
* @param array $user
* @return string
*/
public function create(array $user)
{
$req = $this->client
->getClient()
->post('/api/3/users', [
'json' => [
'user' => $user
]
]);

return $req->getBody()->getContents();
}

/**
* Retrieve all users or a user when id is not null
* @see https://developers.activecampaign.com/reference#retrieve-a-user
* @param null $id
* @param array $query_params
* @return string
*/
public function retrieve($id = null, array $query_params = [])
{
$uri = '/api/3/users';
if (!is_null($id)) {
$uri .= '/' . $id;
}
$req = $this->client
->getClient()
->get($uri, [
'query' => $query_params
]);

return $req->getBody()->getContents();
}

/**
* Delete a user
* @see https://developers.activecampaign.com/reference#delete-a-user
* @param $id
* @return string
*/
public function delete($id)
{
$req = $this->client
->getClient()
->delete('/api/3/users/' . $id);

return $req->getBody()->getContents();
}

}

0 comments on commit f9937a6

Please sign in to comment.