Class: UpsPickup::PickupRequest
- Inherits:
-
Object
- Object
- UpsPickup::PickupRequest
- Includes:
- HTTParty
- Defined in:
- lib/ups_pickup/pickup_request.rb
Direct Known Subclasses
Constant Summary collapse
- LIVE_URL =
"https://onlinetools.ups.com/webservices/Pickup"- TEST_URL =
"https://wwwcie.ups.com/webservices/Pickup"
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#client_response ⇒ Object
Returns the value of attribute client_response.
-
#error ⇒ Object
Returns the value of attribute error.
-
#license ⇒ Object
Returns the value of attribute license.
-
#options ⇒ Object
Returns the value of attribute options.
-
#password ⇒ Object
Returns the value of attribute password.
-
#response ⇒ Object
Returns the value of attribute response.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Instance Method Summary collapse
-
#access_request ⇒ Object
Set security passed in client request block.
- #http_error? ⇒ Boolean
-
#initialize(user_name, password, license, options = {}) ⇒ PickupRequest
constructor
A new instance of PickupRequest.
-
#set_soap_namespace ⇒ Object
Set name space ns2 for pickup.
-
#set_wsdl_endpoint ⇒ Object
For Test environment set test url.
- #soap_fault? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(user_name, password, license, options = {}) ⇒ PickupRequest
Returns a new instance of PickupRequest.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ups_pickup/pickup_request.rb', line 9 def initialize(user_name, password, license, ={}) @user_name,@password,@license, = user_name,password,license, @client=Savon::Client.new(File.("../../schema/Pickup.wsdl", __FILE__)) @request_body = {} set_wsdl_endpoint set_soap_namespace if ([:test] == true) self.class.base_uri TEST_URL elsif [:url] && [LIVE_URL,TEST_URL].include?([:url]) self.class.base_uri [:url] end end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def client @client end |
#client_response ⇒ Object
Returns the value of attribute client_response.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def client_response @client_response end |
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def error @error end |
#license ⇒ Object
Returns the value of attribute license.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def license @license end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def password @password end |
#response ⇒ Object
Returns the value of attribute response.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def response @response end |
#user_name ⇒ Object
Returns the value of attribute user_name.
8 9 10 |
# File 'lib/ups_pickup/pickup_request.rb', line 8 def user_name @user_name end |
Instance Method Details
#access_request ⇒ Object
Set security passed in client request block
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ups_pickup/pickup_request.rb', line 42 def access_request { "ns3:UPSSecurity" => { "ns3:UsernameToken"=>{ "ns3:Username"=>@user_name, "ns3:Password" => @password }, "ns3:ServiceAccessToken"=>{ "ns3:AccessLicenseNumber"=> @license } } } end |
#http_error? ⇒ Boolean
59 60 61 |
# File 'lib/ups_pickup/pickup_request.rb', line 59 def http_error? @client_response.is_a?(Savon::Error) end |
#set_soap_namespace ⇒ Object
Set name space ns2 for pickup
35 36 37 38 39 |
# File 'lib/ups_pickup/pickup_request.rb', line 35 def set_soap_namespace # @client.wsdl.namespaces["xmlns:ns2"] = "http://www.ups.com/XMLSchema/XOLTWS/Pickup/v1.1" # @client.wsdl.namespaces["xmlns:ns3"] = "http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0" end |
#set_wsdl_endpoint ⇒ Object
For Test environment set test url
26 27 28 29 30 31 32 |
# File 'lib/ups_pickup/pickup_request.rb', line 26 def set_wsdl_endpoint if [:test] == true @client.wsdl.endpoint = TEST_URL else @client.wsdl.endpoint = LIVE_URL end end |
#soap_fault? ⇒ Boolean
55 56 57 |
# File 'lib/ups_pickup/pickup_request.rb', line 55 def soap_fault? @client_response.is_a?(Savon::SOAP::Fault) end |
#success? ⇒ Boolean
63 64 65 |
# File 'lib/ups_pickup/pickup_request.rb', line 63 def success? @client_response.is_a?(Savon::SOAP::Response) end |