Example #1
0
        /// <summary>
        /// Retrieve a Event from its id.
        /// </summary>
        /// <param name="id">String representing a Event. Starts with "evt_".</param>
        /// <returns>EasyPost.Event instance.</returns>
        public static Event Retrieve(string id)
        {
            Request request = new Request("v2/events/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Event>());
        }
Example #2
0
        /// <summary>
        ///     Retrieve an Insurance from its id.
        /// </summary>
        /// <param name="id">String representing an Insurance. Starts with "ins_".</param>
        /// <returns>EasyPost.Insurance instance.</returns>
        public static Insurance Retrieve(string id)
        {
            Request request = new Request("insurances/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Insurance>());
        }
Example #3
0
        /// <summary>
        /// Retrieve a Container from its id or reference.
        /// </summary>
        /// <param name="id">String representing a Container. Starts with "container_" if passing an id.</param>
        /// <returns>EasyPost.Container instance.</returns>
        public static Container Retrieve(string id)
        {
            Request request = new Request("containers/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Container>());
        }
Example #4
0
        /// <summary>
        /// Enable a Webhook that has been disabled previously.
        /// </summary>
        public void Update()
        {
            Request request = new Request("v2/webhooks/{id}", Method.PUT);

            request.AddUrlSegment("id", id);

            Merge(request.Execute <Webhook>());
        }
Example #5
0
        /// <summary>
        /// Retrieve a Rate from its id.
        /// </summary>
        /// <param name="id">String representing a Rate. Starts with "rate_".</param>
        /// <returns>EasyPost.Rate instance.</returns>
        public static Rate Retrieve(string id)
        {
            Request request = new Request("v2/rates/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Rate>());
        }
Example #6
0
        /// <summary>
        ///     Retrieve a Report from its id.
        /// </summary>
        /// <param name="id">String representing a report.</param>
        /// <returns>EasyPost.Report instance.</returns>
        public static Report Retrieve(string id)
        {
            Request request = new Request("reports/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Report>());
        }
Example #7
0
        /// <summary>
        /// Retrieve a Webhook from its id.
        /// </summary>
        /// <param name="id">String representing a webhook. Starts with "hook_".</param>
        /// <returns>EasyPost.User instance.</returns>
        public static Webhook Retrieve(string id)
        {
            Request request = new Request("v2/webhooks/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Webhook>());
        }
Example #8
0
        /// <summary>
        /// Retrieve a CarrierAccount from its id.
        /// </summary>
        /// <param name="id">String representing a carrier account. Starts with "ca_".</param>
        /// <returns>EasyPost.CarrierAccount instance.</returns>
        public static CarrierAccount Retrieve(string id)
        {
            Request request = new Request("carrier_accounts/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <CarrierAccount>());
        }
Example #9
0
        /// <summary>
        /// Remove this CarrierAccount from your account.
        /// </summary>
        public void Destroy()
        {
            Request request = new Request("carrier_accounts/{id}", Method.DELETE);

            request.AddUrlSegment("id", id);

            request.Execute();
        }
        /// <summary>
        ///     Remove this CarrierAccount from your account.
        /// </summary>
        /// <returns>Whether the request was successful or not.</returns>
        public bool Destroy()
        {
            Request request = new Request("carrier_accounts/{id}", Method.Delete);

            request.AddUrlSegment("id", id);

            return(request.Execute());
        }
Example #11
0
#pragma warning restore IDE1006 // Naming Styles

        /// <summary>
        /// Retrieve a Parcel from its id.
        /// </summary>
        /// <param name="id">String representing a Parcel. Starts with "prcl_".</param>
        /// <returns>EasyPost.Parcel instance.</returns>
        public static Parcel Retrieve(string id)
        {
            Request request = new Request("v2/parcels/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Parcel>());
        }
Example #12
0
        /// <summary>
        /// Retrieve a Batch from its id.
        /// </summary>
        /// <param name="id">String representing a Batch. Starts with "batch_".</param>
        /// <returns>EasyPost.Batch instance.</returns>
        public static Batch Retrieve(string id)
        {
            Request request = new Request("v2/batches/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Batch>());
        }
Example #13
0
        /// <summary>
        /// Asychronously generate a scan from for the batch.
        /// </summary>
        public void GenerateScanForm()
        {
            Request request = new Request("v2/batches/{id}/scan_form", Method.POST);

            request.AddUrlSegment("id", id);

            Merge(request.Execute <Batch>());
        }
Example #14
0
        /// <summary>
        /// Purchase all shipments within a batch. The Batch's state must be "created" before purchasing.
        /// </summary>
        public void Buy()
        {
            Request request = new Request("v2/batches/{id}/buy", Method.POST);

            request.AddUrlSegment("id", id);

            Merge(request.Execute <Batch>());
        }
Example #15
0
        // ADD CUSTOM REFERENCES (e.g. sku, upc)

        /// <summary>
        /// Retrieve an Item from its id or reference.
        /// </summary>
        /// <param name="id">String representing a Item. Starts with "item_" if passing an id.</param>
        /// <returns>EasyPost.Item instance.</returns>
        public static Item Retrieve(string id)
        {
            Request request = new Request("v2/items/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Item>());
        }
Example #16
0
        /// <summary>
        /// Send a refund request to the carrier the shipment was purchased from.
        /// </summary>
        public void Refund()
        {
            Request request = new Request("shipments/{id}/refund");

            request.AddUrlSegment("id", id);

            ResourceExtension.Merge(this, client.Execute <Shipment>(request));
        }
Example #17
0
        /// <summary>
        /// Retrieve a CustomsInfo from its id.
        /// </summary>
        /// <param name="id">String representing a CustomsInfo. Starts with "cstinfo_".</param>
        /// <returns>EasyPost.CustomsInfo instance.</returns>
        public static CustomsInfo Retrieve(string id)
        {
            Request request = new Request("customs_infos/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <CustomsInfo>());
        }
Example #18
0
        /// <summary>
        /// Retrieve a Pickup from its id.
        /// </summary>
        /// <param name="id">String representing a Pickup. Starts with "pickup_".</param>
        /// <returns>EasyPost.Pickup instance.</returns>
        public static Pickup Retrieve(string id)
        {
            Request request = new Request("v2/pickups/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Pickup>());
        }
Example #19
0
        /// <summary>
        /// Retrieve a ScanForm from its id.
        /// </summary>
        /// <param name="id">String representing a scan form, starts with "sf_".</param>
        /// <returns>EasyPost.ScanForm instance.</returns>
        public static ScanForm Retrieve(string id)
        {
            Request request = new Request("scan_forms/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <ScanForm>());
        }
Example #20
0
        /// <summary>
        /// Cancel this pickup.
        /// </summary>
        public void Cancel()
        {
            Request request = new Request("v2/pickups/{id}/cancel", Method.POST);

            request.AddUrlSegment("id", id);

            Merge(request.Execute <Pickup>());
        }
Example #21
0
        /// <summary>
        /// Send a refund request to the carrier the shipment was purchased from.
        /// </summary>
        public void Refund(Client client)
        {
            Request request = new Request("v2/shipments/{id}/refund");

            request.AddUrlSegment("id", id);

            Merge(request.Execute <Shipment>(client));
        }
Example #22
0
        /// <summary>
        ///     Retrieve an Address from its id.
        /// </summary>
        /// <param name="id">String representing an Address. Starts with "adr_".</param>
        /// <returns>EasyPost.Address instance.</returns>
        public static Address Retrieve(string id)
        {
            Request request = new Request("addresses/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Address>());
        }
Example #23
0
        /// <summary>
        /// Retrieve a Shipment from its id.
        /// </summary>
        /// <param name="id">String representing a Shipment. Starts with "shp_".</param>
        /// <returns>EasyPost.Shipment instance.</returns>
        public static Shipment Retrieve(Client client, string id)
        {
            Request request = new Request("v2/shipments/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Shipment>(client));
        }
Example #24
0
        /// <summary>
        ///     Retrieve a Tracker from its id.
        /// </summary>
        /// <param name="id">String representing a Tracker. Starts with "trk_".</param>
        /// <returns>EasyPost.Tracker instance.</returns>
        public static Tracker Retrieve(string id)
        {
            Request request = new Request("trackers/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Tracker>());
        }
Example #25
0
#pragma warning restore IDE1006 // Naming Styles

        /// <summary>
        /// Retrieve a Order from its id or reference.
        /// </summary>
        /// <param name="id">String representing a Order. Starts with "order_" if passing an id.</param>
        /// <returns>EasyPost.Order instance.</returns>
        public static Order Retrieve(string id)
        {
            Request request = new Request("v2/orders/{id}");

            request.AddUrlSegment("id", id);

            return(request.Execute <Order>());
        }
Example #26
0
        /// <summary>
        /// Generate a postage label for this shipment.
        /// </summary>
        /// <param name="fileFormat">Format to generate the label in. Valid formats: "pdf", "zpl" and "epl2".</param>
        public void GenerateLabel(string fileFormat) {
            Request request = new Request("shipments/{id}/label");
            request.AddUrlSegment("id", id);
            // This is a GET, but uses the request body, so use ParameterType.GetOrPost instead.
            request.AddParameter("file_format", fileFormat, ParameterType.GetOrPost);

            this.Merge(request.Execute<Shipment>());
        }
        /// <summary>
        /// Update this CarrierAccount.
        /// </summary>
        /// <param name="parameters">See CarrierAccount.Create for more details.</param>
        public void Update(Dictionary <string, object> parameters)
        {
            Request request = new Request("v2/carrier_accounts/{id}", Method.PUT);

            request.AddUrlSegment("id", id);
            request.AddBody(parameters, "carrier_account");

            Merge(request.Execute <CarrierAccount>());
        }
Example #28
0
        /// <summary>
        /// Create a Report.
        /// </summary>
        /// <param name="type">
        /// The type of report, e.g. "shipment", "tracker", "payment_log", etc.
        /// </param>
        /// <param name="parameters">
        /// Optional dictionary containing parameters to create the carrier account with. Valid pairs:
        ///   * {"start_date", string} Date to start the report at.
        ///   * {"end_date", string} Date to end the report at.
        ///   * {"include_children", string} Whether or not to include child objects in the report.
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Report instance.</returns>
        public static Report Create(string type, Dictionary <string, object> parameters = null)
        {
            Request request = new Request("v2/reports/{type}", Method.POST);

            request.AddUrlSegment("type", type);
            request.AddQueryString(parameters ?? new Dictionary <string, object>());

            return(request.Execute <Report>());
        }
Example #29
0
        /// <summary>
        /// Update the User associated with the api_key specified.
        /// </summary>
        /// <param name="parameters">
        /// Optional dictionary containing parameters to create the carrier account with. Valid pairs:
        ///   * {"name", string} Name on the account.
        ///   * {"email", string} Email on the account. Can only be updated on the parent account.
        ///   * {"phone_number", string} Phone number on the account. Can only be updated on the parent account.
        ///   * {"recharge_amount", int} Recharge amount for the account in cents. Can only be updated on the parent account.
        ///   * {"secondary_recharge_amount", int} Secondary recharge amount for the account in cents. Can only be updated on the parent account.
        ///   * {"recharge_threshold", int} Recharge threshold for the account in cents. Can only be updated on the parent account.
        /// All invalid keys will be ignored.
        /// </param>
        public void Update(Dictionary <string, object> parameters)
        {
            Request request = new Request("users/{id}", Method.PUT);

            request.AddUrlSegment("id", id);
            request.AddBody(parameters, "user");

            this.Merge(request.Execute <User>());
        }
Example #30
0
        /// <summary>
        /// Insure shipment for the given amount.
        /// </summary>
        /// <param name="amount">The amount to insure the shipment for. Currency is provided when creating a shipment.</param>
        public void Insure(double amount) {
            Request request = new Request("shipments/{id}/insure", Method.POST);
            request.AddUrlSegment("id", id);
            request.addBody(new List<Tuple<string, string>>() {
                new Tuple<string, string>("amount", amount.ToString())
            });

            this.Merge(request.Execute<Shipment>());
        }