Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions drivers/solutions2/pms.cr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,21 @@ class PMS < PlaceOS::Driver
request("GET", "/api/parking/full-notifications")
end

def upload_vehicle_documents(vehicle_id : String, file_name : String, file_in_base64 : String)
method = "POST"
resource = "/api/vehicles/upload-documents/#{vehicle_id}"
payload = {
"Files" => [{"FileName" => file_name, "Base64" => file_in_base64}]
}.to_json
headers = get_headers
headers["Content-Length"] = payload.bytesize.to_s

logger.debug { {msg: "#{method} #{resource}:", headers: headers.to_json, payload: payload} } if @debug_payload
response = http(method: method, path: resource, headers: headers, body: payload)
logger.debug { "RESPONSE code: #{response.status_code}, body: #{response.body}" } if @debug_payload
raise "failed to #{method} #{resource}, code #{response.status_code}, body: #{response.body}" unless response.success?
end

private def request(method : String, resource : String, payload : String? = nil, params : Hash(String, String?) | URI::Params = URI::Params.new)
headers = get_headers("application/x-www-form-urlencoded")
logger.debug { {msg: "#{method} #{resource}:", headers: headers.to_json, payload: payload} } if @debug_payload
Expand Down
Loading