friendly_shipping 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0116dbbecf450a2d319054657287b93b5df9f19
4
- data.tar.gz: 9a0f816797149b9995e85f3b6b74eba010b6fd3b
3
+ metadata.gz: 6474cdfc41f6c366bbc23ec531346f569a820250
4
+ data.tar.gz: f54265c3fac066e54892c1430f6b28d7f65d027a
5
5
  SHA512:
6
- metadata.gz: 42c0b1c6e67c8467ff3a92f3804239d038a080c8c8bacfde0994fef9c7d23a4c9f77a6c570db7e3424cdf4691bdb6f08f817554891ad0923e0e1a91f42d6dc65
7
- data.tar.gz: 3b87784060938c7b0968565c8ade8d5733f326bfe764c300545e9fdee5ecbbe120365c405e99d9c2496c578a1ada0898a41a18173bcc366de4eb82411b8c3871
6
+ metadata.gz: bbc3d24cf5f1c690f13e33b5bfd3fc0857f071fb8d4ee79bea1fa08df8f93eab900b6cd233c4627022c9e1c6dcae7056ba0a3140e99882be038c6f192a46eea7
7
+ data.tar.gz: bf83d0948e27ad4dc2c8cbf45643d70bd7d7563986901a0bc782cc119cd3c8aac7ac3f1aec19edf86fd37541b7bf36e6467edf971fb3dd193752c9552d7d3ebf
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.4.6] - 2019-11-28
8
+
9
+ ### Changed
10
+ - UPS Service: Add Support for voiding labels
11
+
7
12
  ## [0.4.5] - 2019-11-27
8
13
 
9
14
  ### Changed
@@ -8,12 +8,14 @@ require 'friendly_shipping/services/ups/serialize_address_validation_request'
8
8
  require 'friendly_shipping/services/ups/serialize_rating_service_selection_request'
9
9
  require 'friendly_shipping/services/ups/serialize_shipment_accept_request'
10
10
  require 'friendly_shipping/services/ups/serialize_shipment_confirm_request'
11
+ require 'friendly_shipping/services/ups/serialize_void_shipment_request'
11
12
  require 'friendly_shipping/services/ups/parse_address_validation_response'
12
13
  require 'friendly_shipping/services/ups/parse_address_classification_response'
13
14
  require 'friendly_shipping/services/ups/parse_city_state_lookup_response'
14
15
  require 'friendly_shipping/services/ups/parse_rate_response'
15
16
  require 'friendly_shipping/services/ups/parse_shipment_confirm_response'
16
17
  require 'friendly_shipping/services/ups/parse_shipment_accept_response'
18
+ require 'friendly_shipping/services/ups/parse_void_shipment_response'
17
19
  require 'friendly_shipping/services/ups/shipping_methods'
18
20
  require 'friendly_shipping/services/ups/label_options'
19
21
 
@@ -40,6 +42,7 @@ module FriendlyShipping
40
42
  rates: '/ups.app/xml/Rate',
41
43
  ship_confirm: '/ups.app/xml/ShipConfirm',
42
44
  ship_accept: '/ups.app/xml/ShipAccept',
45
+ void: '/ups.app/xml/Void',
43
46
  }.freeze
44
47
 
45
48
  def initialize(key:, login:, password:, test: true, client: HttpClient.new)
@@ -165,6 +168,19 @@ module FriendlyShipping
165
168
  end
166
169
  end
167
170
 
171
+ def void(label, debug: false)
172
+ url = base_url + RESOURCES[:void]
173
+ void_request_xml = SerializeVoidShipmentRequest.call(label: label)
174
+ request = FriendlyShipping::Request.new(
175
+ url: url,
176
+ body: access_request_xml + void_request_xml,
177
+ debug: debug
178
+ )
179
+ client.post(request).bind do |response|
180
+ ParseVoidShipmentResponse.call(request: request, response: response)
181
+ end
182
+ end
183
+
168
184
  private
169
185
 
170
186
  def access_request_xml
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
4
+
5
+ module FriendlyShipping
6
+ module Services
7
+ class Ups
8
+ class ParseVoidShipmentResponse
9
+ def self.call(request:, response:)
10
+ parsing_result = ParseXMLResponse.call(response.body, 'VoidShipmentResponse')
11
+ parsing_result.fmap do |xml|
12
+ FriendlyShipping::ApiResult.new(
13
+ xml.root.at('ResponseStatusDescription').text,
14
+ original_request: request,
15
+ original_response: response
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FriendlyShipping
4
+ module Services
5
+ class Ups
6
+ class SerializeVoidShipmentRequest
7
+ def self.call(label:)
8
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
9
+ xml.VoidShipmentRequest do
10
+ xml.Request do
11
+ xml.RequestAction('Void')
12
+ end
13
+ xml.ShipmentIdentificationNumber(label.tracking_number)
14
+ end
15
+ end
16
+ xml_builder.to_xml
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FriendlyShipping
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: data_uri
@@ -194,6 +194,7 @@ files:
194
194
  - lib/friendly_shipping/services/ups/parse_rate_response.rb
195
195
  - lib/friendly_shipping/services/ups/parse_shipment_accept_response.rb
196
196
  - lib/friendly_shipping/services/ups/parse_shipment_confirm_response.rb
197
+ - lib/friendly_shipping/services/ups/parse_void_shipment_response.rb
197
198
  - lib/friendly_shipping/services/ups/parse_xml_response.rb
198
199
  - lib/friendly_shipping/services/ups/serialize_access_request.rb
199
200
  - lib/friendly_shipping/services/ups/serialize_address_snippet.rb
@@ -204,6 +205,7 @@ files:
204
205
  - lib/friendly_shipping/services/ups/serialize_shipment_accept_request.rb
205
206
  - lib/friendly_shipping/services/ups/serialize_shipment_address_snippet.rb
206
207
  - lib/friendly_shipping/services/ups/serialize_shipment_confirm_request.rb
208
+ - lib/friendly_shipping/services/ups/serialize_void_shipment_request.rb
207
209
  - lib/friendly_shipping/services/ups/shipping_methods.rb
208
210
  - lib/friendly_shipping/services/ups_freight.rb
209
211
  - lib/friendly_shipping/services/ups_freight/generate_commodity_information.rb