Class: AdaptivePayments::AbstractRequest
- Defined in:
- lib/pp-adaptive/abstract_request.rb
Overview
AbstractRequest is a JsonModel that defines some default behaviour for all requests
A request defines the operation it executes and provides a method for building the corresponding response. All requests provide a RequestEnvelope by default. There is no need to re-define it in descendants.
Direct Known Subclasses
CancelPreapprovalRequest, ConvertCurrencyRequest, ExecutePaymentRequest, GetPaymentOptionsRequest, PayRequest, PaymentDetailsRequest, PreapprovalDetailsRequest, PreapprovalRequest, RefundRequest, SetPaymentOptionsRequest
Class Method Summary collapse
-
.build_response(json) ⇒ AbstractResponse
Given a JSON string, return the corresponding response.
-
.for_operation(name) ⇒ AbstractRequest
Get the request class for the given operation.
-
.operation(name = nil) ⇒ Symbol
Set or get the API operation for the request class.
Methods included from Aliases
Methods included from JsonModel::Parsing
Methods included from JsonModel::Writing
Class Method Details
.build_response(json) ⇒ AbstractResponse
Given a JSON string, return the corresponding response.
49 50 51 52 |
# File 'lib/pp-adaptive/abstract_request.rb', line 49 def build_response(json) klass = AdaptivePayments.const_get(operation.to_s + "Response") klass.from_json(json.to_s) end |
.for_operation(name) ⇒ AbstractRequest
Get the request class for the given operation.
38 39 40 |
# File 'lib/pp-adaptive/abstract_request.rb', line 38 def for_operation(name) AdaptivePayments.const_get(name.to_s + "Request") end |
.operation(name = nil) ⇒ Symbol
Set or get the API operation for the request class
26 27 28 29 |
# File 'lib/pp-adaptive/abstract_request.rb', line 26 def operation(name = nil) @operation = name unless name.nil? @operation end |