/**
         * Create a QueryString with all the fields of this class different of Null
         *
         * @return the String with the param codified in the QueryString
         */
        public String generateQueryString()
        {
            QueryString qs = new QueryString("page", this.page.ToString());

            qs.add("limit", this.limit.ToString());

            if (this.keyword != null)
            {
                qs.add("keyword", this.keyword);
            }
            if (this.createdAtMin != default(DateTime))
            {
                qs.add("created_at_min", DateMethods.ToString(this.createdAtMin));
            }
            if (this.createdAtMax != default(DateTime))
            {
                qs.add("created_at_max", DateMethods.ToString(this.createdAtMax));
            }
            if (this.lang != null)
            {
                qs.add("lang", this.lang);
            }

            if (this._slugs != null)
            {
                qs.add("slug", this._slugs);
            }

            if (this._origins != null)
            {
                qs.add("origin", string.Join(",", this._origins));
            }

            if (this._destinations != null)
            {
                qs.add("destination", string.Join(",", this._destinations));
            }

            if (this._tags != null)
            {
                qs.add("tag", string.Join(",", this._tags));
            }

            if (this._fields != null)
            {
                qs.add("fields", string.Join(",", this._fields));
            }

            //globalJSON.put("tracking", trackingJSON);

            return(qs.getQuery());
        }
示例#2
0
 public Checkpoint(JObject checkpointJSON)
 {
     // Console.WriteLibe(typeof(checkpointJSON["created_at"]));
     this.createdAt = checkpointJSON["created_at"] == null? DateTime.MinValue:
                      DateMethods.getDate((String)checkpointJSON["created_at"]);
     this.checkpointTime = checkpointJSON["checkpoint_time"] == null?null:(String)checkpointJSON["checkpoint_time"];
     this.city           = checkpointJSON["city"] == null?null:(String)checkpointJSON["city"];
     this.countryISO3    = checkpointJSON["country_iso_3"] == null?0:
                           (ISO3Country)Enum.Parse(typeof(ISO3Country), (String)checkpointJSON["country_iso3"]);
     this.countryName = checkpointJSON["country_name"] == null?null:(String)checkpointJSON["country_name"];
     this.message     = checkpointJSON["message"] == null?null:(String)checkpointJSON["message"];
     this.state       = checkpointJSON["state"] == null?null:(String)checkpointJSON["state"];
     this.tag         = checkpointJSON["tag"] == null?null:(String)checkpointJSON["tag"];
     this.zip         = checkpointJSON["zip"] == null?null:(String)checkpointJSON["zip"];
 }
示例#3
0
        public Tracking(JObject trackingJSON)
        {
            this.id = trackingJSON["id"] == null?null:(String)trackingJSON["id"];

            //fields that can be updated by the user
            _trackingNumber         = trackingJSON["tracking_number"] == null?null:(String)trackingJSON["tracking_number"];
            _slug                   = trackingJSON["slug"] == null?null:(String)trackingJSON["slug"];
            _title                  = trackingJSON["title"] == null?null:(String)trackingJSON["title"];
            _customerName           = trackingJSON["customer_name"] == null?null:(String)trackingJSON["customer_name"];
            _destinationCountryISO3 = (String)trackingJSON["destination_country_iso3"] == null?0:
                                      (ISO3Country)Enum.Parse(typeof(ISO3Country), (String)trackingJSON["destination_country_iso3"]);
            _orderID               = trackingJSON["order_id"] == null?null:(String)trackingJSON["order_id"];
            _orderIDPath           = trackingJSON["order_id_path"] == null?null:(String)trackingJSON["order_id_path"];
            _trackingAccountNumber = trackingJSON["tracking_account_number"] == null?null:
                                     (String)trackingJSON["tracking_account_number"];
            _trackingPostalCode = trackingJSON["tracking_postal_code"] == null?null:
                                  (String)trackingJSON["tracking_postal_code"];
            _trackingShipDate = trackingJSON["tracking_ship_date"] == null?null:
                                (String)trackingJSON["tracking_ship_date"];

            JArray smsesArray = trackingJSON["smses"] == null?null:(JArray)trackingJSON["smses"];

            if (smsesArray != null && smsesArray.Count != 0)
            {
                _smses = new List <String>();
                for (int i = 0; i < smsesArray.Count; i++)
                {
                    _smses.Add((String)smsesArray[i]);
                }
            }

            JArray emailsArray = trackingJSON["emails"] == null?null: (JArray)trackingJSON["emails"];

            if (emailsArray != null && emailsArray.Count != 0)
            {
                _emails = new List <String>();
                for (int i = 0; i < emailsArray.Count; i++)
                {
                    _emails.Add((String)emailsArray[i]);
                }
            }



            JObject customFieldsJSON = trackingJSON["custom_fields"] == null?null:
                                       (JObject)trackingJSON["custom_fields"];

//			if(customFieldsJSON!=null){
//				_customFields = new Dictionary<String, String>();
//				foreach (var item in customFieldsJSON) {
//					_customFields.Add (item.Key, (String)item.Value);
//				}
//			}

            if (customFieldsJSON != null)
            {
                _customFields = new Dictionary <String, String>();
                IEnumerable <JProperty> keys = customFieldsJSON.Properties();
                foreach (var item in keys)
                {
                    _customFields.Add(item.Name, (String)customFieldsJSON[item.Name]);
                }
            }

            //fields that can't be updated by the user, only retrieve
            _createdAt        = trackingJSON["created_at"] == null?DateTime.MinValue:DateMethods.getDate((String)trackingJSON["created_at"]);
            _updatedAt        = trackingJSON["updated_at"] == null?DateTime.MinValue:DateMethods.getDate((String)trackingJSON["updated_at"]);
            _expectedDelivery = trackingJSON["expected_delivery"] == null?null:(String)trackingJSON["expected_delivery"];

            _active            = trackingJSON ["active"] == null? false : (bool)trackingJSON["active"];
            _originCountryISO3 = (String)trackingJSON["origin_country_iso3"] == null?0:
                                 (ISO3Country)Enum.Parse(typeof(ISO3Country), (String)trackingJSON["origin_country_iso3"]);
            _shipmentPackageCount = trackingJSON["shipment_package_count"] == null?0:
                                    (int)trackingJSON["shipment_package_count"];
            _shipmentType = trackingJSON["shipment_type"] == null?null:(String)trackingJSON["shipment_type"];
            _signedBy     = trackingJSON["singned_by"] == null?null:(String)trackingJSON["signed_by"];
            _source       = trackingJSON["source"] == null?null:(String)trackingJSON["source"];
            _tag          = (String)trackingJSON["tag"] == null?0:
                            (StatusTag)Enum.Parse(typeof(StatusTag), (String)trackingJSON["tag"]);

            _trackedCount = trackingJSON["tracked_count"] == null?0:(int)trackingJSON["tracked_count"];
            _uniqueToken  = trackingJSON["unique_token"] == null?null:(String)trackingJSON["unique_token"];

            // checkpoints
            JArray checkpointsArray = trackingJSON["checkpoints"] == null?null:
                                      (JArray)trackingJSON["checkpoints"];

            if (checkpointsArray != null && checkpointsArray.Count != 0)
            {
                _checkpoints = new List <Checkpoint>();
                for (int i = 0; i < checkpointsArray.Count; i++)
                {
                    _checkpoints.Add(new Checkpoint((JObject)checkpointsArray[i]));
                }
            }
        }