View Source SmeeView.Aspects.PrivacyURL (SmeeView v0.2.0)

Represents and processes <mdui:PrivacyStatementURL> elements in entity metadata as Aspect structs.

The functions in this module are intended to be applied to individual Aspect structs - for extracting and processing collections of these records please use the matching View module.

Summary

Functions

Is this aspect relevant to the IdP role?

Returns the language of this aspect (as a two letter ISO 639-1 code)

Is the aspect using this language? (two letter ISO 639-1 code)

Returns the URL for this aspect as a parsed URI struct.

Returns the associated role for this aspect: :sp, :idp or :all

Is this aspect relevant to the SP role?

Returns the URL for this aspect, as a text binary

Is this a valid URL? Returns true if the URL can be parsed.

Types

@type t() :: %SmeeView.Aspects.PrivacyURL{lang: binary(), url: binary()}

Functions

@spec idp?(aspect :: t()) :: boolean()

Is this aspect relevant to the IdP role?

Will return true if the aspect has been derived from an IdP role, or is applicable to all roles.

PrivacyURL.idp?(aspect)
# => true
@spec lang(aspect :: t()) :: binary()

Returns the language of this aspect (as a two letter ISO 639-1 code)

If no language code has been set for this aspect then the default language code will be returned.

PrivacyURL.lang(aspect)
# => "fr"
Link to this function

lang?(aspect, lang \\ SmeeView.Utils.default_lang())

View Source

Is the aspect using this language? (two letter ISO 639-1 code)

Returns true if the provided code matches that of the aspect.

If no language code has been set for this aspect then the aspect will be assumed to have the default language code.

PrivacyURL.lang?(aspect, "en")
# => false
@spec parsed!(aspect :: t()) :: URI.t()

Returns the URL for this aspect as a parsed URI struct.

If the URI cannot be parsed then an exception will be raised. If you need more control you should either use valid?/1 first, or just use URI.parse/1 yourself.

PrivacyURL.parsed!(aspect)
# => %URI{...}
@spec role(aspect :: t()) :: atom()

Returns the associated role for this aspect: :sp, :idp or :all

The role type is useful when handling a mixed list of aspects that may be specific to certain roles of an entity.

PrivacyURL.role(aspect)
# => :idp
@spec sp?(aspect :: t()) :: boolean()

Is this aspect relevant to the SP role?

Will return true if the aspect has been derived from an SP role, or is applicable to all roles.

PrivacyURL.sp?(aspect)
# => false
@spec url(aspect :: t()) :: binary()

Returns the URL for this aspect, as a text binary

Aspects containing URLs are printable and can be converted to strings using Kernel.to_string/1 or interpolated into another string.

PrivacyURL.url(aspect)
# => "https://idp.example.com/information"
@spec valid?(aspect :: t()) :: boolean()

Is this a valid URL? Returns true if the URL can be parsed.

PrivacyURL.valid?(aspect)
# => false