Created
May 26, 2022 11:58
-
-
Save beanieboi/aedd40cd31a8538d88aa95f2538c47b7 to your computer and use it in GitHub Desktop.
ISTA Ecotrend
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
require "bundler" | |
Bundler.setup | |
require 'json' | |
require 'excon' | |
# get token | |
login_response = Excon.post('https://api.prod.eed.ista.com/login', | |
body: '{"email":"email", "password":"password","fromMobileApp":true}', | |
headers: { "Content-Type" => "application/json" } | |
) | |
accessToken = JSON.parse(login_response.body)["accessToken"] | |
# get consumption unit | |
account_response = Excon.get('https://api.prod.eed.ista.com/account', | |
headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{accessToken}" } | |
) | |
consumption_unit = JSON.parse(account_response.body)["activeConsumptionUnit"] | |
consumption_response = Excon.get("https://api.prod.eed.ista.com/consumptions?consumptionUnitUuid=#{consumption_unit}", | |
headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{accessToken}" } | |
) | |
puts JSON.parse(consumption_response.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment