Class: ParichkiBg::Request::Base
- Inherits:
-
Object
- Object
- ParichkiBg::Request::Base
- Defined in:
- lib/parichki_bg/request/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#pin ⇒ Object
readonly
Returns the value of attribute pin.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #checksum ⇒ Object
- #encoded_checksum ⇒ Object
- #encoded_data ⇒ Object
- #https ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #result ⇒ Object
- #send ⇒ Object
- #signed_request ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 |
# File 'lib/parichki_bg/request/base.rb', line 7 def initialize(attributes = {}) @amount = attributes.fetch :amount @pin = attributes.fetch :pin @user_id = attributes.fetch :user_id end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/parichki_bg/request/base.rb', line 5 def amount @amount end |
#pin ⇒ Object (readonly)
Returns the value of attribute pin.
5 6 7 |
# File 'lib/parichki_bg/request/base.rb', line 5 def pin @pin end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
5 6 7 |
# File 'lib/parichki_bg/request/base.rb', line 5 def user_id @user_id end |
Instance Method Details
#checksum ⇒ Object
28 29 30 |
# File 'lib/parichki_bg/request/base.rb', line 28 def checksum ParichkiBg.hmac to_json end |
#encoded_checksum ⇒ Object
32 33 34 |
# File 'lib/parichki_bg/request/base.rb', line 32 def encoded_checksum Base64.strict_encode64 checksum end |
#encoded_data ⇒ Object
36 37 38 |
# File 'lib/parichki_bg/request/base.rb', line 36 def encoded_data Base64.strict_encode64 to_json end |
#https ⇒ Object
13 14 15 16 17 18 |
# File 'lib/parichki_bg/request/base.rb', line 13 def https @http ||= Net::HTTP.new uri.host, uri.port @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_NONE @http end |
#result ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/parichki_bg/request/base.rb', line 40 def result if success? ActiveSupport::JSON.decode @response.body else {"error" => "UserNotFound"} end end |
#send ⇒ Object
20 21 22 |
# File 'lib/parichki_bg/request/base.rb', line 20 def send @response = https.get uri.request_uri end |
#signed_request ⇒ Object
24 25 26 |
# File 'lib/parichki_bg/request/base.rb', line 24 def signed_request encoded_checksum + "." + encoded_data end |