Contact

cat me.json

# previews the file

{ "name": "Pedro Henrique", "email": "pedro_hga@proton.me", "currentLocation": "São Paulo, Brazil", "mobile": "+55 11 986-786-862", "linkedin": "in/pedrohga", "github": "pedro-hga" }

ruby contact(me.json)

# feel free to say hi!

require 'json' require 'uri' def contact(json) begin response = fetch(json); if !response.ok? raise 'Failed to fetch the JSON file.'; end personal_info = JSON.parse(response); recipient = json.email subject = 'Hi!'; body = 'Write your email here'; mail_to = "mailto:#{recipient}?subject=#{URI.encode_www_form_component(subject)}&body=#{URI.encode_www_form_component(body)}"; return JSON.pretty_generate(personal_info); } rescue => error return { error: error.message }; end end contact('me.json')