private async void btnValidateCollivery_Click(object sender, EventArgs e) { Collivery collivery = new Collivery() { auth = new AuthenticateRequest() { email = txtEmail.Text, password = txtPassword.Text } }; ValidateColliveryResponse townsResp = await collivery.validate_collivery(new ValidateColliveryRequest() { data = new ValidateColliveryRequestData() { collivery_from = 920466, collivery_to = 870418, collivery_type = 2, cover = 0, parcel_count = 1, parcels = new List <Parcel>() { new Parcel() { height = 22, length = 23, weight = 1.3m, width = 24 } }, service = 1, weight = 1.3m }, token = authResp.token }); if (townsResp.error != null) { txtResult.Text = "Error - " + townsResp.error.error; } else { txtResult.Text = "Success - Price Returned: " + townsResp.price.inc_vat; } }
private async void btnAddCollivery_Click(object sender, EventArgs e) { Collivery collivery = new Collivery() { auth = new AuthenticateRequest() { email = txtEmail.Text, password = txtPassword.Text } }; ValidateColliveryResponse townsResp = await collivery.validate_collivery(new ValidateColliveryRequest() { data = new ValidateColliveryRequestData() { collivery_from = 920466, collivery_to = 870418, collivery_type = 2, contact_from = 951676, contact_to = 900189, cover = 0, parcel_count = 1, parcels = new List <Parcel>() { new Parcel() { height = 22, length = 23, weight = 1.3m, width = 24 } }, service = 1, weight = 1.3m }, token = authResp.token }); if (townsResp.error != null) { txtResult.Text = "Error - " + townsResp.error.error; } else { //After validate add collivery AddColliveryResponse addResp = await collivery.add_collivery(new AddColliveryRequest() { data = new AddColliveryRequestData() { collection_time = townsResp.collection_time, collivery_from = townsResp.collivery_from, collivery_to = townsResp.collivery_to, collivery_type = townsResp.collivery_type, contact_from = townsResp.contact_from, contact_to = townsResp.contact_to, cover = townsResp.cover, cust_ref = "Invoice # 12234", custom_id = "#12234", delivery_time = townsResp.delivery_time, ignore_validation_change = 0, instructions = "Some custom instructions. Test", parcel_count = townsResp.parcel_count, parcels = townsResp.parcels, price = townsResp.price, service = townsResp.service, time_changed = townsResp.time_changed, time_changed_reason = townsResp.time_changed_reason, vm_divisor = townsResp.vm_divisor, vol_weight = townsResp.vol_weight, weight = townsResp.weight }, token = authResp.token }); if (addResp.error == null) { txtResult.Text = "Collivery Added: " + addResp.collivery_id; } } }