Example #1
0
        public async void OnGet(string car, string fname, string lname, string email)
        {
            this.FirstName = fname;
            this.Email     = email;

            // creates an instance of the Visma Sign Class which will handle the communication with Visma Sign
            var vismaSign = new VismaSign(
                "https://vismasign.frakt.io",
                identifier: "{INSERT YOUR IDENTIDIER HERE}", // uuid
                secret: "{INSERT YOUR SECRET HERE}"          // in base64
                );

            // Creates a new document in Visma Sign
            var documentUri = await vismaSign.DocumentCreate(
                "{\"document\":{\"name\":\"Car rental contract - " + fname + "." + lname + "\"}}"
                );

            // Get the rental contract PDF
            byte[] fileContent = System.IO.File.ReadAllBytes("wwwroot/cont/VismaCarRentals-Contract.pdf");

            // Add the PDF-file to the created document in Visma Sign.
            await vismaSign.DocumentAddFile(documentUri, fileContent);

            // Create and send invitations to sign document
            var invitations = await vismaSign.DocumentAddInvitations(
                documentUri,
                "[{\"email\":\"" + email + "\"}]"
                );
        }
        public async Task ShouldGetCategory()
        {
            var options = new ConnectionOption
            {
                Identifier  = Identifier,
                Secret      = Secret,
                BaseAddress = BaseAddress
            };

            HttpResponseWithBody result = await(dynamic) VismaSign.CategoriesGet(options, new CancellationToken());

            Assert.Equal(200, result.StatusCode);
        }
        public async Task ShouldSearchDocuments()
        {
            var settings = new DocumentSearchInput()
            {
                Query = "status=cancelled"
            };

            var options = new ConnectionOption
            {
                Identifier  = Identifier,
                Secret      = Secret,
                BaseAddress = BaseAddress
            };

            HttpResponseWithBody result = await(dynamic) VismaSign.DocumentSearch(settings, options, new CancellationToken());

            Assert.StartsWith("{\"total\":", result.Body);
        }
        public async Task ShouldCreateDocument()
        {
            var settings = new DocumentCreateInput
            {
                Body = "{ \"document\": { \"name\": \"Test document\"}}"
            };

            var options = new ConnectionOption
            {
                Identifier  = Identifier,
                Secret      = Secret,
                BaseAddress = BaseAddress
            };

            HttpResponse result = await(dynamic) VismaSign.DocumentCreate(settings, options, new CancellationToken());

            Assert.StartsWith("https://sign.visma.net/api/v1/document/", result.Location);
        }
        public async Task ShouldGetDocument()
        {
            var settings = new DocumentGetInput()
            {
                DocumentUriId = "38ca4a5c-5080-4b95-9486-4055f226ecbd",
                Passphrase    = ""
            };

            var options = new ConnectionOption
            {
                Identifier  = Identifier,
                Secret      = Secret,
                BaseAddress = BaseAddress
            };

            HttpResponseWithByteArrayBody result = await(dynamic) VismaSign.DocumentGet(settings, options, new CancellationToken());

            Assert.Equal(200, result.StatusCode);
        }