Beispiel #1
0
        public async Task TestCreateCheckAsync()
        {
            Setup();
            var value0 = Guid.NewGuid().ToString();
            var value1 = Guid.NewGuid().ToString();

            var metaData = new Dictionary<string, string>
            {
                { "key0", value0 }, { "key1", value1 }
            };

            var bankAccount = GetAndVerifyBankAccount();
            var address = GetAddress();

            var checkDefinition = new CheckDefinition
            {
                BankAccountId = bankAccount.Id,
                Description = "check",
                ToAddress = new Location(address.Id),
                FromAddress = new Location(address.Id),
                Amount = 1000,
                Message = "test message",
                CheckNumber = 100,
                Memo = "Test Check",
                MetaData = metaData,
                CheckBottom = new LobImageFile("<div>Hi</div>", false),
                MailType = MailType.UPSNextDayAir
            };

            var check = await _checksClient.CreateCheckAsync(checkDefinition);
            check.BankAccount.Id.Should().Be(bankAccount.Id);
            check.ToAddress.Id.Should().Be(address.Id);
            check.FromAddress.Id.Should().Be(address.Id);
            check.Description.Should().Be("check");
            check.MetaData["key0"].Should().Be(value0);
            check.MetaData["key1"].Should().Be(value1);
            check.Message.Should().BeNull();
            check.Memo.Should().Be("Test Check");
            check.URL.Should().NotBeEmpty();
            check.CheckNumber.Should().BeGreaterThan(0);
            check.ExpectedDeliveryDate.Should().NotBe(DateTime.MinValue);
            check.Amount.Should().Be(1000);
            check.Thumbnails.Should().NotBeEmpty();

            var metaDataResponse = (await _checksClient.GetChecksAsync(new GetFilterOptions
            {
                Metadata = metaData,
                Limit = 1
            })).Entries.First();

            metaDataResponse.Id.Should().Be(check.Id);
            checkDefinition.Logo = new LobImageFile("https://s3-us-west-2.amazonaws.com/lob-assets/lob_check_logo.png", false);
            var remoteLogo = await _checksClient.CreateCheckAsync(checkDefinition);
            var newestCheck = await _checksClient.GetCheckAsync(remoteLogo.Id);
            newestCheck.Id.Should().Be(remoteLogo.Id);
        }
 public Task<Check> CreateCheckAsync(CheckDefinition checkDefinition)
 {
     var populator = new CheckDefinitionPopulator(checkDefinition);
     var resource = Router.CHECKS;
     return ExecuteAsync<Check>(resource, "POST", populator);
 }