php - When creating a client via the API, how do we assign the Client+ role and project to them? -
when creating client via api, how assign client+ role them , assign them project? i've created script redirects users projects based on email address.
the client created, believe can assigned role of client (no client+ role exists). additional client plus permissions come custom permission: manage tasks, can see in database.
when include permission, client never created.
this code create client:
$payload = [ "type" => "client", "first_name" => $first_name, "last_name" => $last_name, "email" => $email, "password" => $this->rand_string(15), "company_id" => $company, ]; $result = $this->client->post("/users", $payload); $result_json = $result->getjson(); $client_id = @$result_json['single']['id']; $payload = [ "id" => $project, "members" => array( $client_id ), ]; $result = $this->client->post("/projects", $payload);
the client gets created, although without right permissions, , client never added project (which means can't make task against it).
client+ regular client instance, permissions. these permissions set using custom permissions
property. note works if client+ enabled in add-ons section of app.
apparently, post-ing /users
api breaks, can use regular invitation route , post on /users/invite
api end-point payload:
$payload = [ "role" => "client", "custom_permissions" => ["can_manage_tasks"], "email_addresses" => [$email], "company_id" => $company_id, "project_ids" : [1, 2, 3], ];
to invite users client+ permissions.
Comments
Post a Comment