Class: PBShipping::Manifest
- Inherits:
-
ShippingApiResource
- Object
- ApiObject
- ApiResource
- ShippingApiResource
- PBShipping::Manifest
- Defined in:
- lib/pbshipping/manifest.rb
Class Method Summary collapse
- .reprintById(auth_obj, manifestId) ⇒ Object
- .retryByTransactionId(auth_obj, txid, originalTxid) ⇒ Object
Instance Method Summary collapse
-
#create(auth_obj, txid, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: POST /manifests API signature: post/manifests.
-
#reprint(auth_obj, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: GET /manifests/manifestId API signature: get/manifests/…
-
#retry(auth_obj, txid, originalTxid, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: GET /manifests API signature: get/manifests/.
Methods inherited from ApiObject
#[], #[]=, #add_accessors, #as_json, convert_to_api_object, #create_accessor, #each, #initialize, #inspect, #key?, #keys, #metaclass, #respond_to?, #to_hash, #to_json, #to_s, #update, #values
Constructor Details
This class inherits a constructor from PBShipping::ApiObject
Class Method Details
Instance Method Details
#create(auth_obj, txid, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: POST /manifests API signature: post/manifests
Create a USPS scan form
By default, the returned result would overwrite the current state of the object. To avoid overwriting, set the input argument overwrite to False and a copy of the result would be generated and returned instead
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pbshipping/manifest.rb', line 34 def create(auth_obj, txid, overwrite=true) if self.key?(:carrier) == false raise MissingResourceAttribute.new(:carrier) elsif self.key?(:parcelTrackingNumbers) == false raise MissingResourceAttribute.new(:parcelTrackingNumbers) elsif self.key?(:submissionDate) == false raise MissingResourceAttribute.new(:submissionDate) elsif self.key?(:fromAddress) == false raise MissingResourceAttribute.new(:fromAddress) end hdrs = { PBShipping::txid_attrname => txid } payload = { :carrier => self[:carrier], :parcelTrackingNumbers => self[:parcelTrackingNumbers], :submissionDate => self[:submissionDate], :fromAddress => self[:fromAddress] } api_sig = "post/manifests" api_version = PBShipping::get_api_version(api_sig) api_path = "/manifests" json_resp = PBShipping::api_request( auth_obj, :post, api_version, api_path, hdrs, {}, payload) if overwrite == true self.update(json_resp) self else Manifest.new(json_resp) end end |
#reprint(auth_obj, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: GET /manifests/manifestId API signature: get/manifests/…
Reprint the USPS scan form
By default, the returned result would overwrite the current state of the object. To avoid overwriting, set the input argument overwrite to False and a copy of the result would be generated and returned instead
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/pbshipping/manifest.rb', line 76 def reprint(auth_obj, overwrite=true) if self.key?(:manifestId) == false raise MissingResourceAttribute.new(:manifestId) end api_sig = "get/manifests/..." api_version = PBShipping::get_api_version(api_sig) api_path = "/manifests/" + self[:manifestId] json_resp = PBShipping::api_request( auth_obj, :get, api_version, api_path, {}, {}, {}) if overwrite == true self.update(json_resp) self else Manifest.new(json_resp) end end |
#retry(auth_obj, txid, originalTxid, overwrite = true) ⇒ Object
MANAGING MANIFESTS API: GET /manifests API signature: get/manifests/
Retry a manifest request that was previously submitted with no successful response
By default, the returned result would overwrite the current state of the object. To avoid overwriting, set the input argument overwrite to False and a copy of the result would be generated and returned instead
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/pbshipping/manifest.rb', line 110 def retry(auth_obj, txid, originalTxid, overwrite=true) hdrs = { PBShipping::txid_attrname => txid } params = { :originalTransactionId => originalTxid } api_sig = "get/manifests" api_version = PBShipping::get_api_version(api_sig) api_path = "/manifests" json_resp = PBShipping::api_request( auth_obj, :get, api_version, api_path, hdrs, params, {}) if overwrite == true self.update(json_resp) self else Manifest.new(json_resp) end end |