src/User.php
public function createUserAndMembership($roles = [Membership::ROLE_READ], $organization = '')
    {
        if (\is_string($roles)) {
            $roles = [$roles];
        }
        $roles = array_map(function ($role) {
            return strtolower($role);
        }, $roles);
        $contents = $this
            ->call('POST',
                implode('/', [self::ORGANIZATION_RESOURCE, $this->getOrganizationName($organization), 'memberships']),
                ['json' => [
                    'roles' => $roles,
            ]])
            ->getBody()
            ->getContents();

        return $this->getSingleMemberShipFromJsonResponse($contents);
    }
public function createUserAndMembership($roles = [Membership::ROLE_READ], $organization = '')
    {
        if (\is_string($roles)) {
            $roles = [$roles];
        }
        $roles = array_map(function ($role) {
            return strtolower($role);
        }, $roles);
        $contents = $this
            ->call('POST',
                implode('/', [self::ORGANIZATION_RESOURCE, $this->getOrganizationName($organization), 'memberships']),
                ['json' => [
                    'roles' => $roles,
            ]])
            ->getBody()
            ->getContents();

        return $this->getSingleMemberShipFromJsonResponse($contents);
    }
public function createUserAndMembership ( $ roles = [ Membership :: ROLE_READ ] , $ organization = '' ) { if ( \ is_string ( $ roles ) ) { $ roles = [ $ roles ] ; } $ roles = array_map ( function ( $ role ) { return strtolower ( $ role ) ; } , $ roles ) ; $ contents = $ this -> call ( 'POST' , implode ( '/' , [ self :: ORGANIZATION_RESOURCE , $ this -> getOrganizationName ( $ organization ) , 'memberships' ] ) , [ 'json' => [ 'roles' => $ roles , ] ] ) -> getBody ( ) -> getContents ( ) ; return $ this -> getSingleMemberShipFromJsonResponse ( $ contents ) ; }
Create a user and membership associated to this organization.

@since 1.7.0

@param string       $organization Organization
@param string|array $roles        Role to add

@throws GuzzleException
@throws \RuntimeException

@return Membership
Create a user and membership associated to this organization .