Class: PaymobRuby::Login
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- PaymobRuby::Login
- Defined in:
- lib/paymob_ruby/api/login.rb
Instance Method Summary collapse
Methods inherited from ApplicationService
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/paymob_ruby/api/login.rb', line 3 def call url = "#{BASE_URI}/auth/tokens" response = ::Faraday.post(url, { api_key: PaymobRuby.api_key }.to_json, "Content-Type" => "application/json") raise AuthenticationError.new("Invalid API key", http_status: response.status, http_body: response.body) unless response.success? response_json = JSON.parse(response.body) success(response_json["token"]) end |