Skip to content

Instantly share code, notes, and snippets.

@beanieboi
Created May 26, 2022 11:58
Show Gist options
  • Save beanieboi/aedd40cd31a8538d88aa95f2538c47b7 to your computer and use it in GitHub Desktop.
Save beanieboi/aedd40cd31a8538d88aa95f2538c47b7 to your computer and use it in GitHub Desktop.
ISTA Ecotrend
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