Class: SixSaferpay::Client
- Inherits:
-
Object
- Object
- SixSaferpay::Client
- Defined in:
- lib/six_saferpay/client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#request ⇒ Object
writeonly
Sets the attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object) ⇒ Client
constructor
A new instance of Client.
- #post ⇒ Object
Constructor Details
#initialize(object) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/six_saferpay/client.rb', line 5 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/six_saferpay/client.rb', line 3 def object @object end |
#request=(value) ⇒ Object
Sets the attribute request
3 4 5 |
# File 'lib/six_saferpay/client.rb', line 3 def request=(value) @request = value end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/six_saferpay/client.rb', line 3 def response @response end |
Class Method Details
.post(object) ⇒ Object
9 10 11 |
# File 'lib/six_saferpay/client.rb', line 9 def self.post(object) new(object).post end |
Instance Method Details
#post ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/six_saferpay/client.rb', line 13 def post https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true @response = https.request(request) hash = @response.body hash = JSON.parse(hash, symbolize_names: true) hash = transform_response_hash(hash) if @response.code == '200' @object.response_class.new(**hash) else raise SixSaferpay::Error.new(**hash) end end |