Created
February 27, 2020 08:24
-
-
Save ttanimichi/148c00bb591e667af83ac6b2b74fac3e to your computer and use it in GitHub Desktop.
This file contains 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
# Current.time = Time.current | |
# Current.user = User.find(42) | |
# MyAPIClient.new.analyze | |
class MyAPIClient | |
URL = 'http://api.example.com' | |
def analyze | |
response = Faraday.post(URL, body_hash.to_json, headers) | |
JSON.parse(response.body) | |
end | |
private | |
def headers | |
{ 'Content-Type' => 'application/json' } | |
end | |
def body_hash | |
{ | |
timeStamp: Current.time.to_i, | |
userId: Current.user.id, | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment