Class: Vpago::PayoutProfiles::Payway::BasePayoutProfileRequest
- Inherits:
-
Object
- Object
- Vpago::PayoutProfiles::Payway::BasePayoutProfileRequest
- Defined in:
- app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#error_messages ⇒ Object
readonly
Returns the value of attribute error_messages.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(profile) ⇒ BasePayoutProfileRequest
constructor
A new instance of BasePayoutProfileRequest.
-
#request_path ⇒ Object
to be override.
- #request_to_payway ⇒ Object
Constructor Details
#initialize(profile) ⇒ BasePayoutProfileRequest
Returns a new instance of BasePayoutProfileRequest.
12 13 14 15 16 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 12 def initialize(profile) @base_url = profile.preferred_base_url @profile = profile @error_messages = [] end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
7 8 9 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 7 def base_url @base_url end |
#error_messages ⇒ Object (readonly)
Returns the value of attribute error_messages.
7 8 9 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 7 def @error_messages end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
7 8 9 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 7 def profile @profile end |
Instance Method Details
#connection ⇒ Object
18 19 20 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 18 def connection Faraday::Connection.new(url: base_url) end |
#request_path ⇒ Object
to be override
10 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 10 def request_path; end |
#request_to_payway ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/vpago/payout_profiles/payway/base_payout_profile_request.rb', line 22 def request_to_payway response = connection.post(request_path) do |request| request.headers['language'] = 'en' request.headers['Content-Type'] = 'application/json' request.body = PayoutProfileRequestParamsBuilder.new(Date.current, profile).request_params.to_json end json_response = JSON.parse(response.body) @error_messages << response.body if json_response.nil? || json_response['status'].nil? json_response end |