Class: Fex::ServiceFactory
- Inherits:
-
Object
- Object
- Fex::ServiceFactory
- Defined in:
- lib/fex/service_factory.rb
Constant Summary collapse
- PRODUCTION_ENDPOINT =
"https://ws.fedex.com:443/web-services"
Instance Attribute Summary collapse
-
#account_number ⇒ Object
readonly
credentials.
-
#client_options ⇒ Object
readonly
Returns the value of attribute client_options.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#key ⇒ Object
readonly
credentials.
-
#meter_number ⇒ Object
readonly
credentials.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
readonly
credentials.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#wsdl ⇒ Object
readonly
Returns the value of attribute wsdl.
Instance Method Summary collapse
- #authentication ⇒ Object
- #endpoint_options ⇒ Object
-
#initialize(name, options) ⇒ ServiceFactory
constructor
A new instance of ServiceFactory.
- #merged_client_options ⇒ Object
- #merged_defaults ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(name, options) ⇒ ServiceFactory
Returns a new instance of ServiceFactory.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fex/service_factory.rb', line 15 def initialize(name, ) @name = name @mode = .fetch(:mode) { "test" } @version = .fetch(:version) {{}} @client_options = .fetch(:client) {{}} @defaults = .fetch(:defaults) {{}} @credentials = .fetch(:credentials) @key = @credentials.fetch(:key) @password = @credentials.fetch(:password) @account_number = @credentials.fetch(:account_number) @meter_number = @credentials.fetch(:meter_number) @wsdl = [:wsdl] @response = [:response] || "Response" end |
Instance Attribute Details
#account_number ⇒ Object (readonly)
credentials
13 14 15 |
# File 'lib/fex/service_factory.rb', line 13 def account_number @account_number end |
#client_options ⇒ Object (readonly)
Returns the value of attribute client_options.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def @client_options end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def defaults @defaults end |
#key ⇒ Object (readonly)
credentials
13 14 15 |
# File 'lib/fex/service_factory.rb', line 13 def key @key end |
#meter_number ⇒ Object (readonly)
credentials
13 14 15 |
# File 'lib/fex/service_factory.rb', line 13 def meter_number @meter_number end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def mode @mode end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def name @name end |
#password ⇒ Object (readonly)
credentials
13 14 15 |
# File 'lib/fex/service_factory.rb', line 13 def password @password end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def response @response end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def version @version end |
#wsdl ⇒ Object (readonly)
Returns the value of attribute wsdl.
10 11 12 |
# File 'lib/fex/service_factory.rb', line 10 def wsdl @wsdl end |
Instance Method Details
#authentication ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/fex/service_factory.rb', line 47 def authentication { web_authentication_detail: { user_credential: { key: key, password: password } }, client_detail: { account_number: account_number, meter_number: meter_number } } end |
#endpoint_options ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/fex/service_factory.rb', line 60 def if mode.to_s == "production" { endpoint: PRODUCTION_ENDPOINT } else {} end end |
#merged_client_options ⇒ Object
56 57 58 |
# File 'lib/fex/service_factory.rb', line 56 def .deep_merge() end |
#merged_defaults ⇒ Object
43 44 45 |
# File 'lib/fex/service_factory.rb', line 43 def merged_defaults authentication.deep_merge(version: version).deep_merge(defaults) end |