public function findAllFor($userId)
 {
     Assert::string($userId, 'User ID "%s" expected to be string, type %s given.');
     Assert::notEmpty($userId, 'User ID "%s" is empty, but non empty value was expected.');
     $consentListJson = $this->apiClient->read('consent/%s', [$userId]);
     return ConsentListFactory::createListFromMetadata($consentListJson);
 }
 /**
  * @param ConsentList $consentList
  * @param AttributeSetInterface $attributeSet
  * @return SpecifiedConsentList
  * @SuppressWarnings(PHPMD.NPathComplexity) Build and mapping logic causes complexity
  */
 public function applyAttributeReleasePolicies(ConsentList $consentList, AttributeSetInterface $attributeSet)
 {
     $entityIds = $consentList->map(function (Consent $consent) {
         return $consent->getServiceProvider()->getEntity()->getEntityId()->getEntityId();
     });
     $mappedAttributes = [];
     foreach ($attributeSet as $attribute) {
         $mace = $attribute->getAttributeDefinition()->getUrnMace();
         $oid = $attribute->getAttributeDefinition()->getUrnOid();
         if ($mace !== null) {
             $mappedAttributes[$mace] = $attribute->getValue();
         }
         if ($oid !== null) {
             $mappedAttributes[$oid] = $attribute->getValue();
         }
     }
     $data = ['entityIds' => $entityIds, 'attributes' => !empty($mappedAttributes) ? $mappedAttributes : new stdClass()];
     $response = $this->jsonApiClient->post($data, '/arp');
     $specifiedConsents = $consentList->map(function (Consent $consent) use($response) {
         $entityId = $consent->getServiceProvider()->getEntity()->getEntityId()->getEntityId();
         if (!isset($response[$entityId])) {
             throw new InvalidResponseException(sprintf('EntityID "%s" was not found in the ARP response (entityIDs: %s)', $entityId, join(', ', array_keys($response))));
         }
         $attributes = [];
         foreach ($response[$entityId] as $attributeName => $attributeValue) {
             try {
                 $attributeDefinition = $this->attributeDictionary->getAttributeDefinitionByUrn($attributeName);
             } catch (UnknownUrnException $exception) {
                 $attributeDefinition = new AttributeDefinition($attributeName, $attributeName, $attributeName);
             }
             $attribute = new Attribute($attributeDefinition, $attributeValue);
             if (!in_array($attribute, $attributes)) {
                 $attributes[] = $attribute;
             }
         }
         return SpecifiedConsent::specifies($consent, AttributeSetWithFallbacks::create($attributes));
     });
     return SpecifiedConsentList::createWith($specifiedConsents);
 }
 /**
  * @param EntityId $entityId
  * @return ContactPersonList
  */
 public function findAllForIdp(EntityId $entityId)
 {
     $identityProviderJson = $this->apiClient->read('metadata/idp?entity-id=%s', [$entityId->getEntityId()]);
     return ContactPersonListFactory::createListFromMetadata($identityProviderJson);
 }