Ejemplo n.º 1
0
        /// <summary>
        /// Check a user password. Useful if you have specific privileged actions
        /// requiring users to confirm their password.
        /// </summary>
        /// <param name="userIdOrEmail">user id or email address</param>
        /// <param name="password">user password</param>
        /// <returns></returns>
        public Boolean CheckPassword(string userIdOrEmail, string password)
        {
            var rgx = new Regex(@".*@.*\.(\w+)");
            var att = new NameValueCollection();

            att.Add("password", MnoEncryptor.encrypt(password, MnoHelper.With(presetName).Api.Key));

            // Check if we should match the password against the id or email
            if (rgx.IsMatch(userIdOrEmail))
            {
                att.Add("email", userIdOrEmail);
            }
            else
            {
                att.Add("id", userIdOrEmail);
            }

            try
            {
                // Raise an error on failure
                MnoClient.Create <User>(User.IndexPath() + "/authenticate", att, presetName);
                return(true);
            } catch (Maestrano.Api.ResourceException) {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void DeserializeObject_DeserializeDate()
        {
            string json   = @"{'Date': '0001-01-01T00:00:00Z','IncorrectDate': '0000-01-01T00:00:00Z','IncorrectNullableDate': '-000-01-01T00:00:00Z'}";
            var    result = MnoClient.DeserializeObject <DateContainer>(json);

            Assert.AreEqual(new DateTime(1, 1, 1), result.IncorrectDate);
            Assert.AreEqual(DateTime.MinValue, result.IncorrectDate);
            Assert.IsNull(result.IncorrectNullableDate);
        }
Ejemplo n.º 3
0
        public Boolean Cancel()
        {
            if (Id != null)
            {
                Bill respBill = MnoClient.Delete <Bill>(ResourcePath(), Id);
                Status = respBill.Status;
                return(Status.Equals("cancelled"));
            }

            return(false);
        }
Ejemplo n.º 4
0
        public Boolean Cancel()
        {
            if (Id != null)
            {
                RecurringBill respBill = MnoClient.Delete <RecurringBill>(ResourcePath(), Id);
                Status    = respBill.Status;
                UpdatedAt = respBill.UpdatedAt;
                return(Status.Equals("cancelled"));
            }

            return(false);
        }
Ejemplo n.º 5
0
        public Bill Create(String groupId, Int32 priceCents, String description, String currency = "AUD", Decimal?units = null, DateTime?periodStartedAt = null, DateTime?periodEndedAt = null)
        {
            var att = new NameValueCollection();

            att.Add("groupId", groupId);
            att.Add("priceCents", priceCents.ToString());
            att.Add("description", description);
            att.Add("currency", currency);
            if (units.HasValue)
            {
                att.Add("units", units.Value.ToString());
            }
            if (periodStartedAt.HasValue)
            {
                att.Add("periodStartedAt", periodStartedAt.Value.ToString("s"));
            }
            if (periodEndedAt.HasValue)
            {
                att.Add("periodEndedAt", periodEndedAt.Value.ToString("s"));
            }

            return(MnoClient.Create <Bill>(Bill.IndexPath(), att, presetName));
        }
Ejemplo n.º 6
0
        public static RecurringBill Create(String groupId, Int32 priceCents, String description, String currency = "AUD", Int32 initialCents = 0, Int16?frequency = null, Int16?cycles = null, DateTime?startDate = null)
        {
            var att = new NameValueCollection();

            att.Add("groupId", groupId);
            att.Add("priceCents", priceCents.ToString());
            att.Add("description", description);
            att.Add("currency", currency);
            att.Add("initialCents", initialCents.ToString());
            if (frequency.HasValue)
            {
                att.Add("frequency", frequency.Value.ToString());
            }
            if (cycles.HasValue)
            {
                att.Add("cycles", cycles.Value.ToString());
            }
            if (startDate.HasValue)
            {
                att.Add("startDate", startDate.Value.ToString("s"));
            }

            return(MnoClient.Create <RecurringBill>(IndexPath(), att));
        }
Ejemplo n.º 7
0
 public Bill Retrieve(string billId)
 {
     return(MnoClient.Retrieve <Bill>(Bill.ResourcePath(), billId, presetName));
 }
Ejemplo n.º 8
0
 public List <Bill> All(NameValueCollection filters = null)
 {
     return(MnoClient.All <Bill>(Bill.IndexPath(), filters, presetName));
 }
Ejemplo n.º 9
0
 public static List <Bill> All(NameValueCollection filters = null)
 {
     return(MnoClient.All <Bill>(IndexPath(), filters));
 }
Ejemplo n.º 10
0
 public static Bill Retrieve(string billId)
 {
     return(MnoClient.Retrieve <Bill>(ResourcePath(), billId));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Retrieve a single Maestrano user by id
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public User Retrieve(string userId)
 {
     return(MnoClient.Retrieve <User>(User.ResourcePath(), userId, presetName));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Retrieve all Maestrano users having access to your application
 /// </summary>
 /// <param name="filters">User attributes to filter on</param>
 /// <returns></returns>
 public List <User> All(NameValueCollection filters = null)
 {
     return(MnoClient.All <User>(User.IndexPath(), filters, presetName));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Retrieve a single Maestrano group by id
 /// </summary>
 /// <param name="groupId"></param>
 /// <returns></returns>
 public Group Retrieve(string groupId)
 {
     return(MnoClient.Retrieve <Group>(Group.ResourcePath(), groupId, presetName));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Retrieve all Maestrano groups having access to your application
 /// </summary>
 /// <param name="filters">User attributes to filter on</param>
 /// <returns></returns>
 public List <Group> All(NameValueCollection filters = null)
 {
     return(MnoClient.All <Group>(Group.IndexPath(), filters, presetName));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Retrieve a single Maestrano user by id
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static User Retrieve(string userId)
 {
     return(MnoClient.Retrieve <User>(ResourcePath(), userId));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Retrieve a single Maestrano group by id
 /// </summary>
 /// <param name="groupId"></param>
 /// <returns></returns>
 public static Group Retrieve(string groupId)
 {
     return(MnoClient.Retrieve <Group>(ResourcePath(), groupId));
 }