public async Task Should_Return_List_Of_Sub_Accounts()
        {
            // Setup
            string apiKey = ConfigurationManager.AppSettings["APIKey"];

            var request = new AddSubAccountRequest(Guid.NewGuid().ToString())
            {
                CustomQuota = 10,
                Name        = "subaccount1",
                Notes       = "notes"
            };

            // Exercise
            var api = new MandrillApi(apiKey);

            SubaccountInfo addedSubaccount = await api.AddSubaccount(request);

            List <SubaccountInfo> result = await api.ListSubaccounts(new ListSubAccountsRequest());

            // Verify
            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result);
            Assert.IsNotNull(result.Find(s => s.Id == addedSubaccount.Id));

            // Cleanup
            await api.DeleteSubaccount(new DeleteSubAccountRequest(addedSubaccount.Id));
        }
        public async Task Should_Pause_And_Return_Sub_Account()
        {
            // Setup
            string apiKey = ConfigurationManager.AppSettings["APIKey"];

            var request = new AddSubAccountRequest(Guid.NewGuid().ToString())
            {
                CustomQuota = 10,
                Name        = "subaccount1",
                Notes       = "notes"
            };


            // Exercise
            var api = new MandrillApi(apiKey);

            SubaccountInfo result = await api.AddSubaccount(request);

            SubaccountInfo paused = await api.PauseSubaccount(new PauseSubAccountRequest(request.Id));

            // Verify
            Assert.IsNotNull(paused);
            Assert.AreEqual(paused.Id, request.Id);
            Assert.AreEqual(paused.Status, "paused");

            // Cleanup
            await api.DeleteSubaccount(new DeleteSubAccountRequest(result.Id));
        }
Пример #3
0
        public async Task Should_Add_SubAccount_And_Return()
        {
            // Setup
            string apiKey = ConfigurationManager.AppSettings["APIKey"];

            var request = new AddSubAccountRequest(Guid.NewGuid().ToString())
            {
                CustomQuota = 10,
                Name        = "subaccount1",
                Notes       = "notes"
            };


            // Exercise
            var api = new MandrillApi(apiKey);

            SubaccountInfo result = await api.AddSubaccount(request);

            // Verify
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Id, request.Id);
            Assert.AreEqual(result.Name, request.Name);
            Assert.AreEqual(result.CustomQuota, request.CustomQuota);
            Assert.AreEqual(result.Status, "active");
        }
Пример #4
0
        public async Task Should_Update_And_Return()
        {
            // Setup
            string apiKey  = ConfigurationManager.AppSettings["APIKey"];
            var    request = new AddSubAccountRequest(Guid.NewGuid().ToString())
            {
                CustomQuota = 10,
                Name        = "subaccount1",
                Notes       = "notes"
            };

            // Exercise
            var api = new MandrillApi(apiKey);

            SubaccountInfo result = await api.AddSubaccount(request);


            string newName = result.Name + "2";

            var updatedAccount = new UpdateSubAccountRequest(request.Id)
            {
                Name = newName
            };

            SubaccountInfo updated = await api.UpdateSubaccount(updatedAccount);

            // Verify
            Assert.IsNotNull(updated);
            Assert.AreEqual(updated.Id, request.Id);
            Assert.AreEqual(updated.Name, newName);

            // Cleanup
            await api.DeleteSubaccount(new DeleteSubAccountRequest(updatedAccount.Id));
        }
Пример #5
0
        /// <summary>
        ///   Add a new subaccount.
        ///   <see cref="https://mandrillapp.com/api/docs/subaccounts.JSON.html#method=add">Mandrill API Documentation</see>
        /// </summary>
        /// <param name="request">The subaccount request</param>
        /// <returns>the information saved about the new subaccount</returns>
        public async Task <SubaccountInfo> AddSubaccount(AddSubAccountRequest request)
        {
            const string path = "subaccounts/add.json";

            SubaccountInfo resp = await Post <SubaccountInfo>(path, request).ConfigureAwait(false);

            return(resp);
        }
Пример #6
0
    /// <summary>
    ///   Add a new subaccount.
    ///   <see cref="https://mandrillapp.com/api/docs/subaccounts.JSON.html#method=add">Mandrill API Documentation</see>
    /// </summary>
    /// <param name="request">The subaccount request</param>
    /// <returns>the information saved about the new subaccount</returns>
    public async Task<SubaccountInfo> AddSubaccount(AddSubAccountRequest request)
    {
      const string path = "subaccounts/add.json";

      SubaccountInfo resp = await Post<SubaccountInfo>(path, request);

      return resp;
    }
        public async Task Subaccount_Info_Returns_Subaccount()
        {
            // Setup
            string apiKey = ConfigurationManager.AppSettings["APIKey"];

            var subaccount = new AddSubAccountRequest(Guid.NewGuid().ToString())
            {
                CustomQuota = 10, Name = "subaccount1"
            };

            // Exercise
            var api = new MandrillApi(apiKey);

            SubaccountInfo result = await api.AddSubaccount(subaccount);

            SubaccountInfo infoSubaccount = await api.SubaccountInfo(new SubAccountInfoRequest(subaccount.Id));

            // Verify
            Assert.IsNotNull(infoSubaccount);
            Assert.AreEqual(infoSubaccount.Id, subaccount.Id);

            // Cleanup
            await api.DeleteSubaccount(new DeleteSubAccountRequest(subaccount.Id));
        }