////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>This Init function prepares the Directory functional block, to work 
 /// as a trusted client. 
 /// It calls the base Init function, wich creates the SSL client's certificate, the Bluevia Connector and
 /// sets the operational mode. 
 /// Then creates itself the api url, the parsers and serializers that the
 /// service petition's process needs</summary>
 /// <param name="mode"> The Bluevia Mode enumerator, that describes the 
 /// operational behavior of the client: <a href="https://www.bluevia.com/en/page/tech.howto.tut_APPtest"> LIVE, TEST, SANDBOX.</a></param>
 /// <param name="consumer">The application Identifier.</param>
 /// <param name="consumerSecret">The application Secret.</param>
 /// <param name="certPath">The path to the ssl client's pem certificate.</param>
 /// <param name="certPasswd">Optional (only if needed): The password of the ssl client's pem certificate.</param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 protected new void InitTrusted(Bluevia.Core.BVMode mode
     , string consumer, string consumerSecret
     , string certPath, string certPasswd = "")
 {
     base.InitTrusted(mode, consumer, consumerSecret, certPath, certPasswd);
     InitApiUrlAndObjects();
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>Converts a complex adResponse object, into a collection of SimpleCreativeElements.</summary>
        /// <param name="simpleAdresponse">A complex adResponse</param>
        /// <returns>A collection of SimpleCreativeElements</returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static SimpleAdResponse SimplifyAdResponse(Bluevia.Advertising.Schemas.SimpleAdResponseType simpleAdresponse)
        {
            //CAN BE IMPROVED
            //This function could be implemented with a for loop, to save the List instantiation

            List<CreativeElement> response = new List<CreativeElement>();
            foreach (CreativeElementType cet in simpleAdresponse.ad.resource.creative_element)
            {
                CreativeElement sce = new CreativeElement();
                sce.type = (TypeId)Enum.Parse(typeof(TypeId), cet.type);
                //Searching for the advertise attribute
                foreach (AttributeType attribute in cet.attribute)
                {
                    if (("text".Equals(cet.type.ToLower())
                        && attribute.type.ToLower().Equals("adtext")) ||
                        ("image".Equals(cet.type.ToLower())
                        && attribute.type.ToLower().Equals("locator")))
                    {
                        sce.value = attribute.Value;
                        break;
                    }
                }

                sce.interaction = cet.interaction[0].attribute[0].Value;
                response.Add(sce);
            }
            return new SimpleAdResponse(simpleAdresponse.id, response.ToArray());
        }