Created
July 20, 2020 19:41
-
-
Save gspfranc/1134b0d5b25c7b3b4bb3269e2852a693 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
#!/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 } |
@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 !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.