ship_me 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'ship_me'
3
+ require 'active_merchant'
4
+
5
+ include ShipMe
6
+ include FedEx
7
+
8
+ TEST_URL = 'https://gatewaybeta.fedex.com:443/xml'
9
+ LIVE_URL = 'https://gateway.fedex.com:443/xml'
10
+
11
+ ActiveMerchant::Connection.class_eval do
12
+ include ActiveMerchant::PostsData
13
+ end
14
+
15
+ connection = ActiveMerchant::Connection.new(TEST_URL)
16
+ connection.logger = Logger.new(STDOUT)
17
+
18
+ request = FedEx::DeleteShipmentRequest.new
19
+ request.key = "G3JsUpzeWtsOkGHP"
20
+ request.password = "AnKa7AnkmKg7RW4pOr3IN9XDs"
21
+ request.account_number = "510087089"
22
+ request.meter_number = "118513648"
23
+ request.tracking_id = FedEx::TrackingId.new
24
+ request.tracking_id.tracking_id_type = FedEx::TrackingIdType::GROUND
25
+ request.tracking_id.tracking_number = "800025615003088"
26
+ request.deletion_control = FedEx::DeletionControlType::DELETE_ALL_PACKAGES
27
+
28
+ puts request.to_xml
29
+ response = connection.ssl_post(TEST_URL, request.to_xml.to_s.gsub("\n",''))
30
+ # response = connection.request(:post, request.to_xml.to_s)
31
+ puts response
@@ -0,0 +1,117 @@
1
+ require 'rubygems'
2
+ require 'ship_me'
3
+ require 'active_merchant'
4
+
5
+ include ShipMe
6
+ include FedEx
7
+
8
+ TEST_URL = 'https://gatewaybeta.fedex.com:443/xml'
9
+ LIVE_URL = 'https://gateway.fedex.com:443/xml'
10
+
11
+ ActiveMerchant::Connection.class_eval do
12
+ include ActiveMerchant::PostsData
13
+ end
14
+
15
+ connection = ActiveMerchant::Connection.new(TEST_URL)
16
+ connection.logger = Logger.new(STDOUT)
17
+
18
+ request = CreatePendingShipmentRequest.new
19
+ request.key = "G3JsUpzeWtsOkGHP"
20
+ request.password = "AnKa7AnkmKg7RW4pOr3IN9XDs"
21
+ request.account_number = "510087089"
22
+ request.meter_number = "118513648"
23
+ # request.key = "56Tu12ESWtX3N5Xc"
24
+ # request.password = "XGKlvSxX9Qv3xAyhoMWcE2oRH"
25
+ # request.account_number = "296678449"
26
+ # request.meter_number = "101825156"
27
+ request.requested_shipment = FedEx::RequestedShipment.new
28
+ request.requested_shipment.ship_timestamp = Time.now.iso8601
29
+ request.requested_shipment.dropoff_type = FedEx::DropoffType::REGULAR_PICKUP
30
+ request.requested_shipment.service_type = FedEx::ServiceType::FEDEX_GROUND
31
+ request.requested_shipment.packaging_type = FedEx::PackagingType::YOUR_PACKAGING
32
+ request.requested_shipment.shipper = FedEx::Party.new(
33
+ :contact => FedEx::Contact.new(
34
+ :person_name => 'Henry Hsu',
35
+ :company_name => 'Photo USA Corporation',
36
+ :phone_number => '4087359900'
37
+ ),
38
+ :address => FedEx::Address.new(
39
+ :street_lines => '1133 Sonora Ct.',
40
+ :city => 'Sunnyvale',
41
+ :state_or_province_code => 'CA',
42
+ :postal_code => '94086',
43
+ :country_code => 'US'
44
+ )
45
+ )
46
+ request.requested_shipment.recipient = FedEx::Party.new(
47
+ :contact => FedEx::Contact.new(
48
+ :person_name => 'Henry Hsu',
49
+ :company_name => 'Photo USA Corporation',
50
+ :phone_number => '4087359900'
51
+ ),
52
+ :address => FedEx::Address.new(
53
+ :street_lines => '1135 Sonora Ct.',
54
+ :city => 'Sunnyvale',
55
+ :state_or_province_code => 'CA',
56
+ :postal_code => '94086',
57
+ :country_code => 'US'
58
+ )
59
+ )
60
+ request.requested_shipment.shipping_charges_payment = FedEx::Payment.new(
61
+ :payment_type => FedEx::PaymentType::SENDER,
62
+ :payor => FedEx::Payor.new(
63
+ :account_number => '510087089',
64
+ :country_code => 'US'
65
+ )
66
+ )
67
+ request.requested_shipment.special_services_requested = FedEx::ShipmentSpecialServicesRequested.new(
68
+ :special_service_types => [FedEx::ShipmentSpecialServiceType::PENDING_SHIPMENT],
69
+ :pending_shipment_detail => FedEx::PendingShipmentDetail.new(
70
+ :email_label_detail => FedEx::EMailLabelDetail.new(
71
+ :notification_e_mail_address => 'henry@photomugs.com'
72
+ ),
73
+ :expiration_date => Time.now.tomorrow.to_date,
74
+ :type => FedEx::PendingShipmentType::EMAIL
75
+ )
76
+ )
77
+ request.requested_shipment.label_specification = FedEx::LabelSpecification.new(
78
+ :label_format_type => FedEx::LabelFormatType::COMMON2D,
79
+ :image_type => FedEx::ShippingDocumentImageType::PNG,
80
+ :label_stock_type => FedEx::LabelStockType::PAPER_4X6
81
+ )
82
+ request.requested_shipment.rate_request_types = [FedEx::RateRequestType::LIST]
83
+ request.requested_shipment.package_count = 1
84
+ request.requested_shipment.package_detail = FedEx::RequestedPackageDetailType::INDIVIDUAL_PACKAGES
85
+ request.requested_shipment.requested_package_line_items = [
86
+ FedEx::RequestedPackageLineItem.new(
87
+ :weight => FedEx::Weight.new(
88
+ :units => FedEx::WeightUnits::LB,
89
+ :value => '33'
90
+ ),
91
+ :dimensions => FedEx::Dimensions.new(
92
+ :length => 14,
93
+ :width => 14,
94
+ :height => 14,
95
+ :units => FedEx::LinearUnits::IN
96
+ ),
97
+ :item_description => "11 oz. Ceramic Mug"
98
+ )
99
+ ]
100
+
101
+ # puts request.to_xml
102
+ # response = connection.ssl_post(TEST_URL, request.to_xml.to_s.gsub("\n",''))
103
+ # response = connection.request(:post, request.to_xml.to_s)
104
+ # puts response
105
+
106
+ response_xml = File.read('../fixtures/fed_ex/pending_response.xml')
107
+ reply = FedEx::CreatePendingShipmentReply.from_xml(response_xml)
108
+
109
+ details = reply.completed_shipment_detail.completed_package_details.first
110
+ #
111
+ # p details.tracking_ids.map(&:tracking_number)
112
+ #
113
+ # image = details.label.parts.map(&:image).first
114
+ #
115
+ # image = Base64.decode64(image)
116
+ #
117
+ # File.open('label.png', 'w+') { |f| f.print image }
@@ -0,0 +1,118 @@
1
+ require 'rubygems'
2
+ require 'ship_me'
3
+ # require 'active_merchant'
4
+
5
+ include ShipMe
6
+ include FedEx
7
+
8
+ # TEST_URL = 'https://gatewaybeta.fedex.com:443/xml'
9
+ # LIVE_URL = 'https://gateway.fedex.com:443/xml'
10
+ #
11
+ # ActiveMerchant::Connection.class_eval do
12
+ # include ActiveMerchant::PostsData
13
+ # end
14
+ #
15
+ # connection = ActiveMerchant::Connection.new(TEST_URL)
16
+ # connection.logger = Logger.new(STDOUT)
17
+
18
+ request = ProcessShipmentRequest.new
19
+ request.key = "G3JsUpzeWtsOkGHP"
20
+ request.password = "AnKa7AnkmKg7RW4pOr3IN9XDs"
21
+ request.account_number = "510087089"
22
+ request.meter_number = "118513648"
23
+ # request.key = "56Tu12ESWtX3N5Xc"
24
+ # request.password = "XGKlvSxX9Qv3xAyhoMWcE2oRH"
25
+ # request.account_number = "296678449"
26
+ # request.meter_number = "101825156"
27
+ request.requested_shipment = FedEx::RequestedShipment.new
28
+ request.requested_shipment.ship_timestamp = Time.now.iso8601
29
+ request.requested_shipment.dropoff_type = FedEx::DropoffType::REGULAR_PICKUP
30
+ request.requested_shipment.service_type = FedEx::ServiceType::FEDEX_GROUND
31
+ request.requested_shipment.packaging_type = FedEx::PackagingType::YOUR_PACKAGING
32
+ request.requested_shipment.shipper = FedEx::Party.new(
33
+ :contact => FedEx::Contact.new(
34
+ :person_name => 'Henry Hsu',
35
+ :company_name => 'Photo USA Corporation',
36
+ :phone_number => '4087359900'
37
+ ),
38
+ :address => FedEx::Address.new(
39
+ :street_line => '1133 Sonora Ct.',
40
+ :city => 'Sunnyvale',
41
+ :state_or_province_code => 'CA',
42
+ :postal_code => '94086',
43
+ :country_code => 'US'
44
+ )
45
+ )
46
+ request.requested_shipment.recipient = FedEx::Party.new(
47
+ :contact => FedEx::Contact.new(
48
+ :person_name => 'Ronald Pruyn',
49
+ :company_name => 'R & l OTH Enterprises',
50
+ :phone_number => '5414932308'
51
+ ),
52
+ :address => FedEx::Address.new(
53
+ :street_line => '57467 Hwy 78',
54
+ :street_line_2 => 'P.O. Box 814',
55
+ :city => 'Crane',
56
+ :state_or_province_code => 'OR',
57
+ :postal_code => '97732-0814',
58
+ :country_code => 'US'
59
+ )
60
+ )
61
+ request.requested_shipment.shipping_charges_payment = FedEx::Payment.new(
62
+ :payment_type => FedEx::PaymentType::SENDER,
63
+ :payor => FedEx::Payor.new(
64
+ :account_number => '510087089',
65
+ :country_code => 'US'
66
+ )
67
+ )
68
+ # request.requested_shipment.special_services_requested = FedEx::ShipmentSpecialServicesRequested.new(
69
+ # :special_service_types => [FedEx::ShipmentSpecialServiceType::PENDING_SHIPMENT],
70
+ # :pending_shipment_detail => FedEx::PendingShipmentDetail.new(
71
+ # :email_label_detail => FedEx::EMailLabelDetail.new(
72
+ # :notification_e_mail_address => 'henry@photomugs.com'
73
+ # ),
74
+ # :expiration_date => Time.now.to_date,
75
+ # :type => FedEx::PendingShipmentType::EMAIL
76
+ # )
77
+ # )
78
+ request.requested_shipment.label_specification = FedEx::LabelSpecification.new(
79
+ :label_format_type => FedEx::LabelFormatType::COMMON2D,
80
+ :image_type => FedEx::ShippingDocumentImageType::PNG,
81
+ :label_stock_type => FedEx::LabelStockType::PAPER_4X6
82
+ )
83
+ request.requested_shipment.rate_request_types = [FedEx::RateRequestType::LIST]
84
+ request.requested_shipment.package_count = 1
85
+ request.requested_shipment.package_detail = FedEx::RequestedPackageDetailType::INDIVIDUAL_PACKAGES
86
+ request.requested_shipment.requested_package_line_items = [
87
+ FedEx::RequestedPackageLineItem.new(
88
+ :weight => FedEx::Weight.new(
89
+ :units => FedEx::WeightUnits::LB,
90
+ :value => '33'
91
+ ),
92
+ :dimensions => FedEx::Dimensions.new(
93
+ :length => 14,
94
+ :width => 14,
95
+ :height => 14,
96
+ :units => FedEx::LinearUnits::IN
97
+ )
98
+ )
99
+ ]
100
+
101
+ puts request.to_xml
102
+ response = request.commit(true)
103
+ # response = connection.ssl_post(TEST_URL, request.to_xml.to_s.gsub("\n",''))
104
+ # response = connection.request(:post, request.to_xml.to_s.gsub("\n",''))
105
+ puts response
106
+
107
+ # response_xml = File.read('SampleFedExShipResponse3.xml')
108
+ # reply = FedEx::ProcessShipmentReply.from_xml(response_xml)
109
+ #
110
+ # details = reply.completed_shipment_detail.completed_package_details.first
111
+ #
112
+ # p details.tracking_ids.map(&:tracking_number)
113
+ #
114
+ # image = details.label.parts.map(&:image).first
115
+ #
116
+ # image = Base64.decode64(image)
117
+ #
118
+ # File.open('label.png', 'w+') { |f| f.print image }
@@ -0,0 +1,119 @@
1
+ require 'rubygems'
2
+ require 'ship_me'
3
+ require 'active_merchant'
4
+
5
+ include ShipMe
6
+ include FedEx
7
+
8
+ # TEST_URL = 'https://gatewaybeta.fedex.com:443/xml'
9
+ # LIVE_URL = 'https://gateway.fedex.com:443/xml'
10
+ #
11
+ # ActiveMerchant::Connection.class_eval do
12
+ # include ActiveMerchant::PostsData
13
+ # end
14
+ #
15
+ # connection = ActiveMerchant::Connection.new(TEST_URL)
16
+ # connection.logger = Logger.new(STDOUT)
17
+
18
+ ShipMe.template :process, ShipMe::FedEx::ProcessShipmentRequest do
19
+ {
20
+ :key => "G3JsUpzeWtsOkGHP",
21
+ :password => "AnKa7AnkmKg7RW4pOr3IN9XDs",
22
+ :account_number => "510087089",
23
+ :meter_number => "118513648",
24
+ :requested_shipment => {
25
+ :ship_timestamp => Time.now.iso8601,
26
+ :dropoff_type => ShipMe::FedEx::DropoffType::REGULAR_PICKUP,
27
+ :service_type => shipping_method,
28
+ :packaging_type => ShipMe::FedEx::PackagingType::YOUR_PACKAGING,
29
+ :shipper => ShipMe::FedEx::Party.new(
30
+ :contact => ShipMe::FedEx::Contact.new(
31
+ :person_name => 'Henry Hsu',
32
+ :company_name => 'Photo USA Corporation',
33
+ :phone_number => '4087359900'
34
+ ),
35
+ :address => ShipMe::FedEx::Address.new(
36
+ :street_line => '1133 Sonora Ct.',
37
+ :city => 'Sunnyvale',
38
+ :state_or_province_code => 'CA',
39
+ :postal_code => '94086',
40
+ :country_code => 'US'
41
+ )
42
+ ),
43
+ :recipient => ShipMe::FedEx::Party.new(
44
+ :contact => ShipMe::FedEx::Contact.new(
45
+ :person_name => 'Henry Hsu',
46
+ :company_name => 'Photo USA Corporation',
47
+ :phone_number => '4087359900'
48
+ ),
49
+ :address => ShipMe::FedEx::Address.new(
50
+ :street_line => '57467 Hwy 78',
51
+ :street_line_2 => 'P.O. Box 814',
52
+ :city => 'Crane',
53
+ :state_or_province_code => 'OR',
54
+ :postal_code => '97732-0814',
55
+ :country_code => 'US'
56
+ )
57
+ ),
58
+ :shipping_charges_payment => ShipMe::FedEx::Payment.new(
59
+ :payment_type => ShipMe::FedEx::PaymentType::SENDER,
60
+ :payor => ShipMe::FedEx::Payor.new(
61
+ :account_number => '510087089',
62
+ :country_code => 'US'
63
+ )
64
+ ),
65
+ :label_specification => ShipMe::FedEx::LabelSpecification.new(
66
+ :label_format_type => ShipMe::FedEx::LabelFormatType::COMMON2D,
67
+ :image_type => ShipMe::FedEx::ShippingDocumentImageType::PNG,
68
+ :label_stock_type => ShipMe::FedEx::LabelStockType::PAPER_4X6
69
+ ),
70
+ :rate_request_types => [FedEx::RateRequestType::ACCOUNT],
71
+ :package_count => 1,
72
+ :package_detail => ShipMe::FedEx::RequestedPackageDetailType::INDIVIDUAL_PACKAGES,
73
+ :requested_package_line_items => [
74
+ ShipMe::FedEx::RequestedPackageLineItem.new(
75
+ :sequence_number => 1,
76
+ :weight => ShipMe::FedEx::Weight.new(
77
+ :units => ShipMe::FedEx::WeightUnits::LB,
78
+ :value => '33'
79
+ ),
80
+ :dimensions => ShipMe::FedEx::Dimensions.new(
81
+ :length => 14,
82
+ :width => 14,
83
+ :height => 14,
84
+ :units => ShipMe::FedEx::LinearUnits::IN
85
+ )
86
+ ),
87
+ ShipMe::FedEx::RequestedPackageLineItem.new(
88
+ :sequence_number => 2,
89
+ :weight => ShipMe::FedEx::Weight.new(
90
+ :units => ShipMe::FedEx::WeightUnits::LB,
91
+ :value => '33'
92
+ ),
93
+ :dimensions => ShipMe::FedEx::Dimensions.new(
94
+ :length => 14,
95
+ :width => 14,
96
+ :height => 14,
97
+ :units => ShipMe::FedEx::LinearUnits::IN
98
+ )
99
+ )
100
+ ]
101
+ }
102
+ }
103
+ end
104
+
105
+ request = ShipMe.templates[:process].make(
106
+ :shipping_method => ShipMe::FedEx::ServiceType::FEDEX_GROUND
107
+ )
108
+
109
+ puts request.to_xml
110
+ response = request.commit(true)
111
+ puts response
112
+ #
113
+ # request = ShipMe.templates[:process].make(
114
+ # :shipping_method => ShipMe::FedEx::ServiceType::FEDEX_EXPRESS_SAVER
115
+ # )
116
+ #
117
+ # puts request.to_xml
118
+ # response = request.commit(true)
119
+ # puts response
@@ -0,0 +1,23 @@
1
+ <v8:DeleteShipmentRequest xmlns="http://fedex.com/ws/ship/v8" xmlns:ns="http://fedex.com/ws/ship/v8" xmlns:v8="http://fedex.com/ws/ship/v8">
2
+ <WebAuthenticationDetail>
3
+ <UserCredential>
4
+ <Key>1111</Key>
5
+ <Password>2222</Password>
6
+ </UserCredential>
7
+ </WebAuthenticationDetail>
8
+ <ClientDetail>
9
+ <AccountNumber>3333</AccountNumber>
10
+ <MeterNumber>4444</MeterNumber>
11
+ </ClientDetail>
12
+ <Version>
13
+ <ServiceId>ship</ServiceId>
14
+ <Major>8</Major>
15
+ <Intermediate>0</Intermediate>
16
+ <Minor>0</Minor>
17
+ </Version>
18
+ <TrackingId>
19
+ <TrackingIdType>GROUND</TrackingIdType>
20
+ <TrackingNumber>800025615003088</TrackingNumber>
21
+ </TrackingId>
22
+ <DeletionControl>DELETE_ALL_PACKAGES</DeletionControl>
23
+ </v8:DeleteShipmentRequest>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <v8:ShipmentReply xmlns:v9="http://fedex.com/ws/ship/v9" xmlns:v8="http://fedex.com/ws/ship/v8">
3
+ <v8:HighestSeverity>SUCCESS</v8:HighestSeverity>
4
+ <v8:Notifications>
5
+ <v8:Severity>SUCCESS</v8:Severity>
6
+ <v8:Source>ship</v8:Source>
7
+ <v8:Code>0000</v8:Code>
8
+ <v8:Message>Success</v8:Message>
9
+ <v8:LocalizedMessage>Success</v8:LocalizedMessage>
10
+ </v8:Notifications>
11
+ <ns:Version xmlns:ns="http://fedex.com/ws/ship/v8">
12
+ <ns:ServiceId>ship</ns:ServiceId>
13
+ <ns:Major>8</ns:Major>
14
+ <ns:Intermediate>0</ns:Intermediate>
15
+ <ns:Minor>0</ns:Minor>
16
+ </ns:Version>
17
+ </v8:ShipmentReply>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <v8:ShipmentReply xmlns:v9="http://fedex.com/ws/ship/v9" xmlns:v8="http://fedex.com/ws/ship/v8">
3
+ <v8:HighestSeverity>NOTE</v8:HighestSeverity>
4
+ <v8:Notifications>
5
+ <v8:Severity>NOTE</v8:Severity>
6
+ <v8:Source>ship</v8:Source>
7
+ <v8:Code>8159</v8:Code>
8
+ <v8:Message>Shipment Delete was requested for a tracking number already in a deleted state.</v8:Message>
9
+ <v8:LocalizedMessage>Shipment Delete was requested for a tracking number already in a deleted state.</v8:LocalizedMessage>
10
+ </v8:Notifications>
11
+ <ns:Version xmlns:ns="http://fedex.com/ws/ship/v8">
12
+ <ns:ServiceId>ship</ns:ServiceId>
13
+ <ns:Major>8</ns:Major>
14
+ <ns:Intermediate>0</ns:Intermediate>
15
+ <ns:Minor>0</ns:Minor>
16
+ </ns:Version>
17
+ </v8:ShipmentReply>