Class: Blackbird::Retoure::ReturnOrder
- Inherits:
-
Object
- Object
- Blackbird::Retoure::ReturnOrder
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/blackbird/retoure/return_order.rb
Overview
Public: This class represents the ReturnOrder object of the DHL API. It validated the required fields for the API like the receiverId, returnDocumentType and the senderAddress.
receiver_id = The id of the return receiver. customer_reference = A customer reference number (optional) shipment_reference = Shipment reference (optional) email = E-Mail address of the customer (optional) telephone_number = Telephone number of the customer (optional) weight_in_grams = The weight of the package (optional) value = The value of the goods (optional) return_document_type = The document type. If not provided the
value SHIPMENT_TYPE will be set.
sender_address = A Hash or a BlackBird::Retoure::SenderAddress object.
Examples
# Create a ReturnOrder object that requests a single shipping label
Blackbird::Retoure::ReturnOrder.new(
receiver_id: 'DE',
sender_address: {
name1: 'Name #1',
street_name: 'Street Name',
house_number: '12345',
post_code: 'Post Code',
city: 'City',
country: {
country_iso_code: 'DEU'
}
}
)
# => <#Blackbird::Retoure::ReturnOrder @receiver_id => 'DE', ...>
# Create just a QR label
sender_address = Blackbird::Retoure::SenderAddress.new(
name1: 'Name #1',
streetName: 'Street Name',
houseNumber: '12345',
postCode: 'Post Code',
city: 'City',
country: {
countryISOCode: 'DEU'
}
)
Blackbird::Retoure::ReturnOrder.new(
receiver_id: 'DE',
senderAddress: sender_address,
return_document_type: 'QR_LABEL'
)
# => <#Blackbird::Retoure::ReturnOrder @receiver_id => 'DE', ...>
Instance Attribute Summary collapse
-
#customer_reference ⇒ Object
readonly
Returns the value of attribute customer_reference.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#receiver_id ⇒ Object
readonly
Returns the value of attribute receiver_id.
-
#return_document_type ⇒ Object
readonly
Returns the value of attribute return_document_type.
-
#sender_address ⇒ Object
Returns the value of attribute sender_address.
-
#shipment_reference ⇒ Object
readonly
Returns the value of attribute shipment_reference.
-
#telephone_number ⇒ Object
readonly
Returns the value of attribute telephone_number.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#weight_in_grams ⇒ Object
readonly
Returns the value of attribute weight_in_grams.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ ReturnOrder
constructor
A new instance of ReturnOrder.
-
#to_json ⇒ Object
Public: Create a JSON payload of this class.
Constructor Details
#initialize(args = {}) ⇒ ReturnOrder
Returns a new instance of ReturnOrder.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/blackbird/retoure/return_order.rb', line 63 def initialize(args = {}) @receiver_id = args[:receiver_id] @customer_reference = args[:customer_reference] @shipment_reference = args[:shipment_reference] @email = args[:email] @telephone_number = args[:telephone_number] @weight_in_grams = args[:weight_in_grams] @value = args[:value] @return_document_type = args.fetch(:return_document_type, 'SHIPMENT_LABEL') self.sender_address = args[:sender_address] if args[:sender_address] end |
Instance Attribute Details
#customer_reference ⇒ Object (readonly)
Returns the value of attribute customer_reference.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def customer_reference @customer_reference end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def email @email end |
#receiver_id ⇒ Object (readonly)
Returns the value of attribute receiver_id.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def receiver_id @receiver_id end |
#return_document_type ⇒ Object (readonly)
Returns the value of attribute return_document_type.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def return_document_type @return_document_type end |
#sender_address ⇒ Object
Returns the value of attribute sender_address.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def sender_address @sender_address end |
#shipment_reference ⇒ Object (readonly)
Returns the value of attribute shipment_reference.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def shipment_reference @shipment_reference end |
#telephone_number ⇒ Object (readonly)
Returns the value of attribute telephone_number.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def telephone_number @telephone_number end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def value @value end |
#weight_in_grams ⇒ Object (readonly)
Returns the value of attribute weight_in_grams.
56 57 58 |
# File 'lib/blackbird/retoure/return_order.rb', line 56 def weight_in_grams @weight_in_grams end |
Instance Method Details
#to_json ⇒ Object
Public: Create a JSON payload of this class.
Returns a String representing the JSON payload.
95 96 97 98 99 100 101 |
# File 'lib/blackbird/retoure/return_order.rb', line 95 def to_json { receiverId: @receiver_id, customerReference: @customer_reference, shipmentReference: @shipment_reference, email: @email, telephoneNumber: @telephone_number, weightInGrams: @weight_in_grams, value: @value, senderAddress: JSON.parse(@sender_address.to_json), returnDocumentType: @return_document_type }.reject { |_k, v| v.blank? }.to_json end |