forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-mrr.sh
executable file
·48 lines (34 loc) · 1.15 KB
/
get-mrr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# You may need to install coreutils via homebrew to make this script work (gdate function below).
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Monthly Recurring Revenue
# @raycast.mode inline
# @raycast.refreshTime 1h
# Optional parameters:
# @raycast.icon images/baremetrics.png
# @raycast.packageName Baremetrics
# Documentation:
# @raycast.description Display Monthly Recurring Revenue (MRR)
# @raycast.author Valentin Chrétien
# @raycast.authorURL https://github.com/valentinchrt
# Configuration
# To create a new API token, do the following:
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
# 2. Copy your Live API Key
# 3. Insert your API token below
API_TOKEN=''
DATE=`gdate -d yesterday '+%Y-%m-%d'`
# Main program
if [[ -z "$API_TOKEN" ]]
then
echo "No API token provided"
exit 1
fi
MRR_BEFORE=$(curl -s GET \
--header 'Accept: application/json' \
--header "Authorization: Bearer ${API_TOKEN}" \
--url "https://api.baremetrics.com/v1/metrics/mrr?start_date=${DATE}&end_date=${DATE}" \
| jq '.metrics[0].value')
MRR=$(echo "$MRR_BEFORE * 0.01" | bc -l)
printf "€%'.0f\n" $MRR