Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Created December 24, 2024 17:19
Show Gist options
  • Save Beyarz/d36af1fa4f71f5fa93f5279ab45e51c3 to your computer and use it in GitHub Desktop.
Save Beyarz/d36af1fa4f71f5fa93f5279ab45e51c3 to your computer and use it in GitHub Desktop.
Create plans on howbout.app
# frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
require 'securerandom'
MY_API_KEY = "..."
BEARER = "..."
BAGGAGE = "..."
SentryTrace = "..."
activities = [
"Go for a walk",
# ...
]
locations = [
"At home",
# ...
]
events = []
index = 0
activities.each do |activity|
events << { title: activity, location: locations[index] }
index += 1
if (index > locations.length - 1)
index = 0
end
end
# From this date, it will automatically increment a new date with random interval for next activity
start_time = Time.new(2024, 12, 25, 0, 0, 0, 0)
events.each do |event|
generated_uuid = SecureRandom.uuid
location = event[:location]
start_date = start_time.strftime("%Y-%m-%dT%H:%M:%S.%L") + "Z"
# The end date is automatically set
end_time = start_time + rand(60 * 60 * 1 .. 60 * 60 * 24)
end_date = end_time.strftime("%Y-%m-%dT%H:%M:%S.%L") + "Z"
uri = URI.parse("https://api.howbout.app/api/events?api_key=#{MY_API_KEY}")
request = Net::HTTP::Post.new(uri)
request.content_type = 'application/json'
request['Host'] = 'api.howbout.app'
request['Accept'] = 'application/json, text/plain, */*'
request['Baggage'] = BAGGAGE
request['Authorization'] = "Bearer #{BEARER}"
request['Sentry-Trace'] = SentryTrace
request['Sec-Fetch-Site'] = 'cross-site'
request['Appversion'] = '10.5.2'
request['Accept-Language'] = 'en-GB,sv;q=0.9'
request['Sec-Fetch-Mode'] = 'cors'
request['Accept-Encoding'] = 'gzip, deflate, br'
request['Origin'] = 'capacitor://localhost'
request['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)'
request['Sec-Fetch-Dest'] = 'empty'
request['Connection'] = 'keep-alive'
request.body = {
uuid: generated_uuid,
type: "plan",
title: event[:title],
chat_muted: true,
calendar: "ZYNG",
visibility: "friends",
availability_override: "free",
alerts: "0,00",
start: start_date,
end: end_date,
# user_ids of your friends (don't do this, it's kinda rude)
user_ids:[],
}.to_json
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
response = http.request(request)
puts "#{response.code} - #{event}"
start_time = end_time
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment