Class: Wirecard::Base
- Inherits:
-
Object
- Object
- Wirecard::Base
- Defined in:
- lib/wirecard/base.rb
Direct Known Subclasses
Wirecard::Backend::Base, DataStorage::Base, PaymentProcess::Init
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #defaults ⇒ Object
- #implicit_fingerprint_order ⇒ Object
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method_name, *args, &block) ⇒ Object
- #post ⇒ Object (also: #save)
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/wirecard/base.rb', line 33 def method_missing(method_name, *args, &block) if response && (response.key?(method_name.to_sym) || response.key?(method_name)) response[method_name.to_sym] || response[method_name] else super end end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/wirecard/base.rb', line 6 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
4 5 6 |
# File 'lib/wirecard/base.rb', line 4 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/wirecard/base.rb', line 6 def response @response end |
Class Method Details
.create(attributes = {}) ⇒ Object
49 50 51 52 53 |
# File 'lib/wirecard/base.rb', line 49 def self.create(attributes = {}) object = new(attributes) object.save object end |
Instance Method Details
#defaults ⇒ Object
8 9 10 11 12 13 |
# File 'lib/wirecard/base.rb', line 8 def defaults @defaults ||= { customer_id: Wirecard.config.customer_id, shop_id: Wirecard.config.shop_id } end |
#implicit_fingerprint_order ⇒ Object
45 46 47 |
# File 'lib/wirecard/base.rb', line 45 def implicit_fingerprint_order nil end |
#post ⇒ Object Also known as: save
23 24 25 26 27 28 29 |
# File 'lib/wirecard/base.rb', line 23 def post http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true self.response = Wirecard::Response.new(http.request(request.to_post)).to_hash self end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
41 42 43 |
# File 'lib/wirecard/base.rb', line 41 def respond_to_missing?(method_name, include_private = false) response && (response.key?(method_name.to_sym) || response.key?(method_name)) || super end |