fedex_location_service 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 218e8c66cf2caf2aea9d44a75d13009b9d1671d0fc93d29118ae7eea81940ae2
4
- data.tar.gz: b707b292cc9e5da7555921371a09733fa1a509e50398d1e01beb0b2112de120a
3
+ metadata.gz: c4ef54bf08411e8df537a9c21188188011cbdb5a192e3a38dd633937b853d391
4
+ data.tar.gz: 733843444d101bf5f49b893fce04b79e7be73f111dd66e4f474c73f9991a4530
5
5
  SHA512:
6
- metadata.gz: e33c0bf49982055240980f8a96b5c645c80d18c8bcce5f594626c10b5936637ea9d01118f68f40dc13468d538a8234cb4cd42bcd2b238bf6b9d04300f1d93e16
7
- data.tar.gz: 906595cdc98eb8924270d52b928e9d3a7de7d194348465ed37477bbe4c5ecd96e7a49c91d9ee83246e4ce697f2b08dca9738dcfbf5327637739b6ffb5ad882ee
6
+ metadata.gz: 89d0483eb3b12ba9ee42ebf0a18fd7d9c48269a2301b0d66233e33e2065f09dd882665621e9aa95bc770cff7da1a49e4db92b2b28414116b19476af59562a280
7
+ data.tar.gz: 14d261f96e65f8e46d6ffe02d808a7947208484fa56047a8fde85e9be18c5dc83b05bb108da2217f4e652ab7b740a8893743b583152f22a02e52c1d1d85ab1dc
data/README.md CHANGED
@@ -60,17 +60,26 @@ The resulting message can then be passed to FedexLocationService::Request.call()
60
60
  response = FedexLocationService::Request.call(message)
61
61
  ```
62
62
 
63
- This will return a Savon::Response object that you can parse.
63
+ This will return a Savon::Response or Savon::SOAPFault object.
64
64
 
65
- The FedEx Location Service API will return a status of 'SUCCESS' if locations have been found for the address provided in the message.
65
+ This retuned Savon object can then be passed to FedexLocationService::Response.build()
66
66
 
67
- The FedEx Location Service API will return a status of 'ERROR' if no locations have been found for the address provided in the message.
67
+ ```ruby
68
+ parsed_response = FedexLocationService::Response.build(response)
69
+ ```
70
+
71
+ Depending on how the request went the parsed_response will have a different status:
68
72
 
69
- The method will rescue from any Savon::SOAPFault exception and return a hash that consists of:
73
+ ```ruby
74
+ ## The address was correct and there are FedEx locations:
75
+ parsed_response[:search_locations_reply][:highest_severity] == 'SUCCESS'
76
+
77
+ ## The address was correct and there are no FedEx locations:
78
+ parsed_response[:search_locations_reply][:highest_severity] == 'ERROR'
70
79
 
71
- * :cause
72
- * :code
73
- * :desc
80
+ ## There was a SOAP Fault:
81
+ parsed_response[:search_locations_reply][:highest_severity] == 'FATAL'
82
+ ```
74
83
 
75
84
  Included is a FedexLocationService::Locations.call() method that will extract the first 5 closest locations and return the addresses, distance and a map image.
76
85
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "fedex_location_service"
3
+ require 'bundler/setup'
4
+ require 'fedex_location_service'
5
5
  require 'dotenv/load'
6
6
 
7
7
  Bundler.require
@@ -9,5 +9,5 @@ Bundler.require
9
9
  require_relative '../spec/support/address.rb'
10
10
  require_relative '../spec/support/fedex_location_service_config.rb'
11
11
 
12
- require "pry"
12
+ require 'pry'
13
13
  Pry.start
@@ -1,40 +1,40 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
+
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "fedex_location_service/version"
4
+ require 'fedex_location_service/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "fedex_location_service"
7
+ spec.name = 'fedex_location_service'
8
8
  spec.version = FedexLocationService::VERSION
9
- spec.authors = ["odin - (Casey Ellett)"]
10
- spec.email = ["casey.ellett@gmail.com"]
9
+ spec.authors = ['odin - (Casey Ellett)']
10
+ spec.email = ['casey.ellett@gmail.com']
11
11
 
12
12
  spec.summary = %q{Interface for FedEx Location Services API.}
13
13
  spec.homepage = 'https://github.com/odin/fedex_location_service'
14
- spec.license = "MIT"
14
+ spec.license = 'MIT'
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
17
  # to allow pushing to a single host or delete this section to allow pushing to any host.
18
18
  if spec.respond_to?(:metadata)
19
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
20
  else
21
- raise "RubyGems 2.0 or newer is required to protect against " \
22
- "public gem pushes."
21
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
22
+ 'public gem pushes.'
23
23
  end
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
26
  f.match(%r{^(test|spec|features)/})
27
27
  end
28
28
 
29
- spec.bindir = "exe"
29
+ spec.bindir = 'exe'
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
31
+ spec.require_paths = ['lib']
32
32
 
33
- spec.add_development_dependency "awesome_print"
34
- spec.add_development_dependency "bundler", "~> 1.15"
35
- spec.add_development_dependency "dotenv"
36
- spec.add_development_dependency "rake", "~> 10.0"
37
- spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency 'awesome_print'
34
+ spec.add_development_dependency 'bundler', '~> 1.15'
35
+ spec.add_development_dependency 'dotenv'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
37
+ spec.add_development_dependency 'rspec', '~> 3.0'
38
38
  spec.add_development_dependency 'guard'
39
39
  spec.add_development_dependency 'guard-rspec'
40
40
  spec.add_development_dependency 'webmock'
@@ -2,6 +2,7 @@ require 'fedex_location_service/configuration'
2
2
  require 'fedex_location_service/locations'
3
3
  require 'fedex_location_service/message'
4
4
  require 'fedex_location_service/request'
5
+ require 'fedex_location_service/response'
5
6
  require 'fedex_location_service/version'
6
7
 
7
8
  require 'savon'
@@ -24,6 +25,6 @@ module FedexLocationService
24
25
  end
25
26
 
26
27
  def self.root
27
- Pathname.new File.expand_path('../..', __FILE__)
28
+ Pathname.new File.expand_path('..', __dir__)
28
29
  end
29
30
  end
@@ -30,7 +30,7 @@ module FedexLocationService
30
30
  'StreetLines' => [
31
31
  address.address_one,
32
32
  ## address_two cannot be nil
33
- address.address_two ? address.address_two : ''
33
+ address.address_two || ''
34
34
  ],
35
35
  'City' => address.city,
36
36
  'StateOrProvinceCode' => address.state,
@@ -50,7 +50,7 @@ module FedexLocationService
50
50
  'RequiredLocationAttributes' => [
51
51
  'WEEKDAY_EXPRESS_HOLD_AT_LOCATION'
52
52
  ],
53
- 'ResultsRequested' => 5,
53
+ 'ResultsRequested' => 5
54
54
  ]
55
55
  }
56
56
  end
@@ -6,10 +6,16 @@ module FedexLocationService
6
6
  begin
7
7
  @response = client.call(:search_locations, message: message)
8
8
  rescue Savon::SOAPFault => error
9
- @response = error.to_hash[:fault][:detail]
9
+ @response = error
10
+ #@response = {
11
+ # message: error.to_hash[:fault][:detail],
12
+ # body: {
13
+ # search_locations_response: {
14
+ # highest_severity: 'ERROR'
15
+ # }
16
+ # }
17
+ #}
10
18
  end
11
-
12
- return @response
13
19
  end
14
20
  end
15
21
  end
@@ -0,0 +1,19 @@
1
+ module FedexLocationService
2
+ class Response
3
+ def self.build(message)
4
+ if message.class == Savon::Response
5
+ message.to_hash
6
+ elsif message.class == Savon::SOAPFault
7
+ original_message = message.to_hash
8
+
9
+ custom_error_message = {
10
+ search_locations_reply: {
11
+ highest_severity: 'FATAL'
12
+ }
13
+ }
14
+
15
+ original_message.merge(custom_error_message)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module FedexLocationService
2
- VERSION = "0.3.0"
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedex_location_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - odin - (Casey Ellett)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2018-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -202,6 +202,7 @@ files:
202
202
  - lib/fedex_location_service/locations.rb
203
203
  - lib/fedex_location_service/message.rb
204
204
  - lib/fedex_location_service/request.rb
205
+ - lib/fedex_location_service/response.rb
205
206
  - lib/fedex_location_service/version.rb
206
207
  homepage: https://github.com/odin/fedex_location_service
207
208
  licenses: