-
-
Save gspfranc/1134b0d5b25c7b3b4bb3269e2852a693 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby | |
require "uri" | |
require "net/http" | |
require "json" | |
require 'active_support/all' | |
module URI | |
class HTTP | |
def empty? | |
false | |
end | |
end | |
end | |
#EVDUTY EMAIL AND PASSWORD | |
email = "test@test.com" | |
password = "password" | |
# max charging session to fetch | |
limit = 1000 | |
# get login token | |
url = URI("https://api-evduty.agylev.com/v1/account/login") | |
https = Net::HTTP.new(url.host, url.port); | |
https.use_ssl = true | |
request = Net::HTTP::Post.new(url) | |
request["Content-Type"] = "application/json" | |
request.body = "{\r\n \"TAG\": \"Account\",\r\n \"cars\": [],\r\n \"debuggingEnabled\": false,\r\n \"device\": {\r\n \"id\": \"a986c0de8d9aacb6\",\r\n \"model\": \"Android SDK built for x86_64\",\r\n \"type\": \"ANDROID\"\r\n },\r\n \"email\": \"#{email}\",\r\n \"emailConfirmed\": false,\r\n \"isLiveDebugging\": false,\r\n \"isOwner\": false,\r\n \"password\": \"#{password}\"\r\n}" | |
response = https.request(request) | |
if response.code == "200" | |
access_token = JSON.parse(response.body)["accessToken"] | |
end | |
# get charging session infos | |
url = URI("https://api-evduty.agylev.com/v2/sessions?limit=#{limit}&offset=0 ") | |
https = Net::HTTP.new(url.host, url.port); | |
https.use_ssl = true | |
request = Net::HTTP::Get.new(url) | |
request["Authorization"] = "Bearer #{access_token}" | |
response = https.request(request) | |
results = JSON.parse(response.body)["data"] | |
#write charging sessions to xml | |
xml_results = results.to_xml | |
File.open('evduty_session_exportation.xml', 'w'){ |f| f.write xml_results } |
It seems I've just found the answer :-)
They use this API now /v2/account/stations
@ionutbaban I'm trying your api path but seem not working anymore. Have you found the correct api call ?
@ionutbaban I'm trying your api path but seem not working anymore. Have you found the correct api call ?
I can't find the Postman requests right now, but what I've done was to install this app (https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture) on an Android phone, than install the EVDuty app and capture the network trace.
Than you just filter out the HTTP calls to and from https://api-evduty.agylev.com and you can see what you need to do in order to use their API
I guess this will change over time.
@ionutbaban I'm trying your api path but seem not working anymore. Have you found the correct api call ?
I can't find the Postman requests right now, but what I've done was to install this app (https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture) on an Android phone, than install the EVDuty app and capture the network trace.
Than you just filter out the HTTP calls to and from https://api-evduty.agylev.com and you can see what you need to do in order to use their API
I guess this will change over time.
Thx for responding with this walkthrough so fast !
Hi @gspfranc,
Any chance you can let me know if you still get a result from /v2/sessions?limit=10&offset=0
I get the below response although I have a bunch of sessions in the app
I have recorded the app communication but I don't see any call to /v2/sessions, only to /v1/sessions/current