Class: CardConnect::Service::ServiceEndpoint
- Inherits:
-
Object
- Object
- CardConnect::Service::ServiceEndpoint
- Includes:
- Utils
- Defined in:
- lib/cardconnect/services/service_endpoint.rb
Direct Known Subclasses
Authorization, Bin, Capture, Inquire, Profile, Refund, SettlementStatus, Void
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#rest_method ⇒ Object
readonly
Returns the value of attribute rest_method.
Instance Method Summary collapse
- #build_request(params = {}) ⇒ Object
-
#initialize(connection = CardConnect.connection) ⇒ Object
constructor
Parent for service endpoints (Authorization, Capture, etc.) This class shouldn’t be called directly.
- #path ⇒ Object
- #submit ⇒ Object
Methods included from Utils
#set_attributes, #symbolize_keys
Constructor Details
#initialize(connection = CardConnect.connection) ⇒ Object
Parent for service endpoints (Authorization, Capture, etc.) This class shouldn’t be called directly. Rather call the end service directly.
13 14 15 16 17 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 13 def initialize(connection = CardConnect.connection) @resource_name = '/' @config = CardConnect.configuration @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 6 def connection @connection end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 6 def request @request end |
#resource_name ⇒ Object (readonly)
Returns the value of attribute resource_name.
6 7 8 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 6 def resource_name @resource_name end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 6 def response @response end |
#rest_method ⇒ Object (readonly)
Returns the value of attribute rest_method.
6 7 8 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 6 def rest_method @rest_method end |
Instance Method Details
#build_request(params = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 23 def build_request(params = {}) req = symbolize_keys(params) req = req.merge(merchid: @config.merchant_id) unless req.key?(:merchid) @request = request_class.new(req) end |
#path ⇒ Object
19 20 21 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 19 def path base_api_path + resource_name end |
#submit ⇒ Object
29 30 31 32 33 |
# File 'lib/cardconnect/services/service_endpoint.rb', line 29 def submit raise CardConnect::Error, 'Request has not been built' if request.nil? raise CardConnect::Error, 'Rest method is required' if rest_method.nil? @response = send(rest_method) end |