コード例 #1
0
        public void CanCreateAllocations()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobId        = Guid.Parse("53EB6C0D-12EB-4650-AC33-4183579AB260");
            var newId        = Guid.NewGuid();
            var staffId      = Guid.Parse("4150ea27-4992-46c5-9d59-7671f4f5e80b");
            var allocationId = Guid.Parse("13203791-e742-4487-83c7-e74d1bcabefb");

            var jobAllocation = new JobAllocation()
            {
                uuid                   = newId,
                job_uuid               = jobId,
                staff_uuid             = staffId,
                active                 = 1,
                edit_date              = DateTime.Now,
                allocation_date        = DateTime.Now,
                allocation_window_uuid = allocationId,

                acceptance_status  = "0",
                estimated_duration = "0", requires_acceptance = "0", revised_duration = "0",
                sort_priority      = "0",
                expiry_timestamp   = DateTime.Now.AddYears(1)
            };

            var result = servicem8Client.JobAllocations.Create(jobAllocation);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #2
0
        public void CanCreateNewQuote()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);


            var newJobId = Guid.NewGuid();

            var newJob = new Job()
            {
                uuid            = newJobId,
                active          = 1,
                job_address     = string.Format("newAddress{0}", newJobId),
                billing_address = string.Format("newBillingAddress{0}", newJobId),
                date            = DateTime.Now,
                job_description = string.Format("jobDesc{0}", newJobId),
                work_order_date = DateTime.Now,
                status          = "Quote"
            };

            var result = servicem8Client.Jobs.Create(newJob);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #3
0
ファイル: MaterialTests.cs プロジェクト: codelabnz/servicem8
        public void CanDeleteMaterial()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);


            var materialId = Guid.Parse("1281E649-79FA-4EE6-A2B7-C8FA7FA87296");

            var newMaterial = new Material()
            {
                uuid                = materialId,
                active              = 1,
                barcode             = "1234",
                cost                = "100",
                item_description    = "Test1nov",
                item_is_inventoried = 0,
                item_number         = "Test1nov",
                name                = "Test1nov",
                price               = "100",
                quantity_in_stock   = 100
            };

            var result = servicem8Client.Materials.Delete(newMaterial);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #4
0
        public void CanCreateJobContact()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            Guid jobId        = Guid.Parse("648ea5f1-699b-4b23-ba80-2898d2862bbb");
            Guid jobContactId = Guid.NewGuid();

            var jobContact = new JobContact()
            {
                active    = 1,
                edit_date = DateTime.Now,
                email     = "*****@*****.**",
                first     = "test",
                job_uuid  = jobId,
                last      = "user",
                mobile    = "123",
                phone     = "456",
                type      = "BILLING",
                uuid      = jobContactId
            };

            var result = servicem8Client.JobContacts.Create(jobContact);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #5
0
        public void CanDeleteJobContact()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            Guid jobId        = Guid.Parse("648ea5f1-699b-4b23-ba80-2898d2862bbb");
            Guid jobContactId = Guid.Parse("8837a2e2-451b-47e8-9722-b8c1fd095094");

            var jobContact = new JobContact()
            {
                active    = 0,
                edit_date = DateTime.Now,
                email     = "*****@*****.**",
                first     = "test",
                job_uuid  = jobId,
                last      = "user2",
                mobile    = "1234",
                phone     = "4566",
                type      = "BILLING",
                uuid      = jobContactId
            };

            var result = servicem8Client.JobContacts.Delete(jobContact);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #6
0
        public void CanCreateNewJobMaterial()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);


            var jobId       = Guid.Parse("cceda3a1-6d1b-4eeb-86e4-c2f83b73a5d1");
            var materialId  = Guid.Parse("eb6b708a-ab8a-4d29-bfd9-581a8addda0b");
            var jobMaterial = new Models.JobMaterial()
            {
                active           = 1,
                cost             = "10.00",
                displayed_amount = "10.00",
                edit_date        = DateTime.Now,
                job_uuid         = jobId,
                name             = "test",
                price            = "10.00",
                quantity         = "1",
                tax_rate_uuid    = Guid.Empty,
                uuid             = Guid.NewGuid(),
                material_uuid    = materialId
            };

            var result = servicem8Client.JobMaterials.Create(jobMaterial);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #7
0
ファイル: CompanyTests.cs プロジェクト: codelabnz/servicem8
        public async Task CanUpdateCompany()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var newId = Guid.NewGuid();

            var company = new Company()
            {
                active  = 1,
                name    = string.Format("name{0}", newId.ToString()),
                address = "test street",
                uuid    = newId
            };

            var result = servicem8Client.Companies.Create(company);

            result.Wait();

            //Update the address of the company
            company.address = "updated street address";

            result = servicem8Client.Companies.Update(company);
            result.Wait();

            Assert.IsNull(result.Exception);

            //Fetch company from API to verify
            company = await servicem8Client.Companies.ById(company.uuid);

            Assert.AreEqual <string>(company.address, "updated street address");
        }
コード例 #8
0
        public async Task CanFetchStaff()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var staff = await servicem8Client.Staff.List();

            Assert.IsTrue(staff.Count > 0);
        }
コード例 #9
0
ファイル: CompanyTests.cs プロジェクト: codelabnz/servicem8
        public async Task CanFetchCompanies()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var companies = await servicem8Client.Companies.List();

            Assert.IsTrue(companies.Count > 0);
        }
コード例 #10
0
        public async Task CanFetchJobContacts()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobContacts = await servicem8Client.JobContacts.List();

            Assert.IsTrue(jobContacts.Count > 0);
        }
コード例 #11
0
        public async Task CanFetchAttachments()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var attachments = await servicem8Client.Attachments.List();

            Assert.IsTrue(attachments.Count > 0);
        }
コード例 #12
0
ファイル: MaterialTests.cs プロジェクト: codelabnz/servicem8
        public async Task CanFetchMaterials()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var materials = await servicem8Client.Materials.List();

            Assert.IsTrue(materials.Count > 0);
        }
コード例 #13
0
        public void CanFetchAttachmentInformation()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var attachmentId = Guid.Parse("9b983876-e941-4c79-b348-3e8934df72cb");
            var attachment   = servicem8Client.Attachments.ById(attachmentId);

            Assert.IsNotNull(attachment);
        }
コード例 #14
0
        public async Task CanFetchJobActivitiesByJob()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobId         = Guid.Parse("53EB6C0D-12EB-4650-AC33-4183579AB260");
            var jobActivities = await servicem8Client.JobActivities.ByJobId(jobId);

            Assert.IsTrue(jobActivities.Count > 0);
        }
コード例 #15
0
ファイル: CompanyTests.cs プロジェクト: codelabnz/servicem8
        public async Task CanFetchById()
        {
            var servicem8Client = new Servicem8Client(_apiUsername, _apiPassword);

            var companyUUID = Guid.Parse("a8528af7-6a1e-49f2-9026-afc20aab7916");

            var company = await servicem8Client.Companies.ById(companyUUID);

            Assert.IsNotNull(company);
        }
コード例 #16
0
        public void CanDownloadAttachment()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var attachmentId = Guid.Parse("9b983876-e941-4c79-b348-3e8934df72cb");
            var attachment   = servicem8Client.Attachments.DownloadFile(attachmentId);

            Assert.IsNotNull(attachment);
            Assert.IsTrue(attachment.Length > 0);
        }
コード例 #17
0
        public async Task CanFetchJobContactsByJob()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            Guid jobId = Guid.Parse("648ea5f1-699b-4b23-ba80-2898d2862bbb");

            var jobContacts = await servicem8Client.JobContacts.ByJob(jobId);

            Assert.IsTrue(jobContacts.Count > 0);
        }
コード例 #18
0
        public async Task CanFetchJobMaterialsByJob()
        {
            var jobId = Guid.Parse("cceda3a1-6d1b-4eeb-86e4-c2f83b73a5d1");

            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobMaterials = await servicem8Client.JobMaterials.ByJob(jobId);

            Assert.IsTrue(jobMaterials.Count > 0);
        }
コード例 #19
0
        public async Task CanFetchJobs()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobs = await servicem8Client.Jobs.List();

            Assert.IsTrue(jobs.Count > 0);

            var job = jobs.Find(s => s.generated_job_id == "51");
        }
コード例 #20
0
        public async Task CanFetchQuotes()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var quotes = await servicem8Client.Jobs.Quotes();

            Assert.IsTrue(quotes.Count > 0);
            foreach (var quote in quotes)
            {
                Assert.IsTrue(quote.status == "Quote");
            }
        }
コード例 #21
0
        public async Task CanFetchAttachmentsByJob()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobId       = Guid.Parse("26f5a76c-cf9a-41ea-8f37-2d5a5adb156d");
            var attachments = await servicem8Client.Attachments.ByJobId(jobId);

            foreach (var attachment in attachments)
            {
                Assert.IsTrue(attachment.related_object_uuid == jobId);
            }
        }
コード例 #22
0
        public async Task CanFetchByStatuses()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var statuses = new List <string>()
            {
                "Quote", "Work Order"
            };

            var jobs = await servicem8Client.Jobs.Statuses(statuses);

            Assert.IsTrue(jobs.Count > 0);
        }
コード例 #23
0
        public async Task CanDeleteJob()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var jobId = Guid.Parse("82df202f-ac5b-4f49-942f-437cd4dcb29f");
            var job   = await servicem8Client.Jobs.ById(jobId);

            Assert.IsNotNull(job);

            var result = servicem8Client.Jobs.Delete(job);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #24
0
ファイル: CompanyTests.cs プロジェクト: codelabnz/servicem8
        public void CanCreateCompany()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);

            var newId = Guid.NewGuid();

            var company = new Company()
            {
                active  = 1,
                name    = string.Format("name{0}", newId.ToString()),
                address = "test street",
                uuid    = newId
            };

            var result = servicem8Client.Companies.Create(company);

            result.Wait();

            Assert.IsNull(result.Exception);
        }
コード例 #25
0
ファイル: MaterialTests.cs プロジェクト: codelabnz/servicem8
        public async Task CanCreateNewMaterial()
        {
            var servicem8Client = new Servicem8Client(_apiUsername,
                                                      _apiPassword);


            var newMaterialId = Guid.NewGuid();

            var newMaterial = new Material()
            {
                uuid                = newMaterialId,
                active              = 1,
                barcode             = "1234",
                cost                = "10.23",
                item_description    = newMaterialId.ToString(),
                item_is_inventoried = 0,
                item_number         = "1234",
                name                = string.Format("material {0}", newMaterialId.ToString()),
                price               = "22.22",
                quantity_in_stock   = 100
            };

            var result = servicem8Client.Materials.Create(newMaterial);

            result.Wait();

            Assert.IsNull(result.Exception);

            var verifyMaterial = await servicem8Client.Materials.ById(newMaterialId);

            Assert.AreEqual <Guid>(newMaterialId, verifyMaterial.uuid);
            Assert.AreEqual <string>(newMaterial.barcode, verifyMaterial.barcode);
            Assert.AreEqual <string>(newMaterial.name, verifyMaterial.name);
            Assert.AreEqual <string>(newMaterial.item_number, verifyMaterial.item_number);
            Assert.AreEqual <int>(newMaterial.quantity_in_stock, verifyMaterial.quantity_in_stock);
        }