Example #1
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            try
            {
                ConsignmentResponse consignmentResponse;

                FzShipMate fzShipMate = new FzShipMate();

                switch (_fzShipMateAction)
                {
                case FzShipMateAction.Login:
                    LoginResponse loginResponse = fzShipMate.Login(new LoginRequest(fzShipMate.UserName, fzShipMate.Password));
                    this.txtResponse.Text = loginResponse.ToString();
                    break;

                case FzShipMateAction.Services:
                    ServicesResponse servicesResponse = fzShipMate.GetServices();
                    this.txtResponse.Text = servicesResponse.ToString();
                    break;

                case FzShipMateAction.CreateConsignment:
                    List <Parcel> list   = new List <Parcel>();
                    Parcel        parcel = new Parcel(this.txt_reference.Text, int.Parse(this.txt_weight.Text), int.Parse(this.txt_width.Text), int.Parse(this.txt_length.Text), int.Parse(this.txt_depth.Text));
                    list.Add(parcel);
                    consignmentResponse   = fzShipMate.CreateConsignment(new ConsignmentRequest(int.Parse(this.txt_ServiceID.Text), int.Parse(this.txt_RemittanceID.Text), this.txt_consignment_reference.Text, this.txt_Token.Text, this.txt_service_key.Text, new ToAddressRequest(this.txt_name.Text, this.txt_line_1.Text, this.txt_city.Text, this.txt_postcode.Text, this.txt_country.Text), list));
                    this.txtResponse.Text = consignmentResponse.ToString();
                    break;

                case FzShipMateAction.TrackingByConsignment:
                    TrackingConsignmentResponse trackingConsignmentResponse = fzShipMate.TrackingByConsignment(this.txt_consignment_reference.Text);
                    this.txtResponse.Text = trackingConsignmentResponse.ToString();
                    break;

                case FzShipMateAction.TrackingByParcels:
                    TrackingByParcelsResponse trackingByParcelsResponse = fzShipMate.TrackingByParcels(this.txt_Tracking_reference.Text);
                    this.txtResponse.Text = trackingByParcelsResponse.ToString();
                    break;

                case FzShipMateAction.CancelConsignment:
                    CancelConsignmentResponse cancelConsignmentResponse = fzShipMate.CancelConsignments(this.txt_consignment_reference.Text);
                    this.txtResponse.Text = cancelConsignmentResponse.ToString();
                    break;

                case FzShipMateAction.Label:
                    consignmentResponse   = fzShipMate.GetLabel(this.txt_Tracking_reference.Text);
                    this.txtResponse.Text = consignmentResponse.ToString();
                    break;

                case FzShipMateAction.PrintLabel:
                    consignmentResponse   = fzShipMate.PrintLabel(this.txt_Tracking_reference.Text);
                    this.txtResponse.Text = consignmentResponse.ToString();
                    break;
                }
            }
            catch (Exception ex)
            {
                this.txtResponse.Text = "An error happened: " + ex.Message;
            }
        }