Created
July 28, 2021 11:55
-
-
Save excid3/768a796286c96b7a69356b89641d23cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Request | |
attr_reader :exception, :response | |
def initialize(context = {}) | |
@context = context | |
end | |
def execute | |
@response ||= Response.call(execute_request) | |
self | |
rescue RestClient::BadRequest => err | |
@exception = err | |
self | |
end | |
def success? | |
@exception.nil? && @response.present? | |
end | |
private | |
def execute_request | |
RestClient::Request.execute(request_data) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment