5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/fedex_label_service/smartpost_message.rb', line 5
def self.build(sender_attributes, recipient_attributes)
recipient_street = "#{recipient_attributes[:address_one]} #{recipient_attributes[:address_two]}"
sender_street = "#{sender_attributes[:address_one]} #{sender_attributes[:address_two]}"
sender_name = "#{sender_attributes[:first_name]} #{sender_attributes[:last_name]}"
{
'WebAuthenticationDetail' => [
'ParentCredential' => [
'Key' => FedexLabelService.configuration.key,
'Password' => FedexLabelService.configuration.password
],
'UserCredential' => [
'Key' => FedexLabelService.configuration.key,
'Password' => FedexLabelService.configuration.password
]
],
'ClientDetail' => [
'AccountNumber' => FedexLabelService.configuration.account_number,
'MeterNumber' => FedexLabelService.configuration.meter_number
],
'TransactionDetail' => [
'CustomerTransactionId' => 'label_service gem SmartPost Request'
],
'Version' => [
'ServiceId' => 'ship',
'Major' => '21',
'Intermediate' => '0',
'Minor' => '0'
],
'RequestedShipment' => [
'ShipTimestamp' => Time.now.iso8601,
'DropoffType' => 'BUSINESS_SERVICE_CENTER',
'ServiceType' => 'SMART_POST',
'PackagingType' => 'YOUR_PACKAGING',
'Shipper' => [
'Contact' => [
'PersonName' => sender_name,
'CompanyName' => sender_name,
'PhoneNumber' => sender_attributes[:phone]
],
'Address' => [
'StreetLines' => [
sender_street
],
'City' => sender_attributes[:city],
'StateOrProvinceCode' => sender_attributes[:state],
'PostalCode' => sender_attributes[:postal_code],
'CountryCode' => 'US'
]
],
'Recipient' => [
'Contact' => [
'PersonName' => recipient_attributes[:name],
'CompanyName' => recipient_attributes[:company],
'PhoneNumber' => recipient_attributes[:phone]
],
'Address' => [
'StreetLines' => [
recipient_street
],
'City' => recipient_attributes[:city],
'StateOrProvinceCode' => recipient_attributes[:state],
'PostalCode' => recipient_attributes[:postal_code],
'CountryCode' => 'US'
]
],
'ShippingChargesPayment' => [
'PaymentType' => 'SENDER',
'Payor' => [
'ResponsibleParty' => [
'AccountNumber' => FedexLabelService.configuration.account_number,
'Contact' => [],
'Address' => [
'CountryCode' => 'US'
]
]
]
],
'SpecialServicesRequested' => [
'SpecialServiceTypes' => 'RETURN_SHIPMENT',
'ReturnShipmentDetail' => [
'ReturnType' => 'PRINT_RETURN_LABEL'
]
],
'SmartPostDetail' => [
'Indicia' => 'PARCEL_RETURN',
'AncillaryEndorsement' => 'RETURN_SERVICE',
'HubId' => FedexLabelService.configuration.hub_id
],
'LabelSpecification' => [
'LabelFormatType' => 'COMMON2D',
'ImageType' => 'PNG',
'LabelStockType' => 'PAPER_4X6'
],
'PackageCount' => 1,
'RequestedPackageLineItems' => [
'SequenceNumber' => 1,
'Weight' => [
'Units' => 'LB',
'Value' => 2.0
],
'CustomerReferences' => [
'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
'Value' => sender_attributes[:customer_reference]
]
]
]
}
end
|