Skip to content

Commit 05feeac

Browse files
authored
New script commands: Baremetrics (raycast#764)
* New script commands: Baremetrics * Fixes from review
1 parent 9d9e37c commit 05feeac

File tree

6 files changed

+270
-0
lines changed

6 files changed

+270
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# You may need to install coreutils via homebrew to make this script work (gdate function below).
4+
5+
# Required parameters:
6+
# @raycast.schemaVersion 1
7+
# @raycast.title Average Revenue Per User
8+
# @raycast.mode inline
9+
# @raycast.refreshTime 1h
10+
11+
# Optional parameters:
12+
# @raycast.icon images/baremetrics.png
13+
# @raycast.packageName Baremetrics
14+
15+
# Documentation:
16+
# @raycast.description Display Average revenue per user (ARPU)
17+
# @raycast.author Valentin Chrétien
18+
# @raycast.authorURL https://github.com/valentinchrt
19+
20+
21+
# Configuration
22+
23+
# To create a new API token, do the following:
24+
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
25+
# 2. Copy your Live API Key
26+
# 3. Insert your API token below
27+
28+
API_TOKEN=''
29+
30+
DATE=`gdate -d yesterday '+%Y-%m-%d'`
31+
32+
33+
# Main program
34+
35+
if [[ -z "$API_TOKEN" ]]
36+
then
37+
echo "No API token provided"
38+
exit 1
39+
fi
40+
41+
ARPU_BEFORE=$(curl -s GET \
42+
--header 'Accept: application/json' \
43+
--header "Authorization: Bearer ${API_TOKEN}" \
44+
--url "https://api.baremetrics.com/v1/metrics/arpu?start_date=${DATE}&end_date=${DATE}" \
45+
| jq '.metrics[0].value')
46+
47+
ARPU=$(echo "$ARPU_BEFORE * 0.01" | bc -l)
48+
printf "€%'.0f\n" $ARPU
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# You may need to install coreutils via homebrew to make this script work (gdate function below).
4+
5+
# Required parameters:
6+
# @raycast.schemaVersion 1
7+
# @raycast.title Annual Recurring Revenue
8+
# @raycast.mode inline
9+
# @raycast.refreshTime 1h
10+
11+
# Optional parameters:
12+
# @raycast.icon images/baremetrics.png
13+
# @raycast.packageName Baremetrics
14+
15+
# Documentation:
16+
# @raycast.description Display Annual Recurring Revenue (ARR)
17+
# @raycast.author Valentin Chrétien
18+
# @raycast.authorURL https://github.com/valentinchrt
19+
20+
21+
# Configuration
22+
23+
# To create a new API token, do the following:
24+
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
25+
# 2. Copy your Live API Key
26+
# 3. Insert your API token below
27+
28+
API_TOKEN=''
29+
30+
DATE=`gdate -d yesterday '+%Y-%m-%d'`
31+
32+
33+
# Main program
34+
35+
if [[ -z "$API_TOKEN" ]]
36+
then
37+
echo "No API token provided"
38+
exit 1
39+
fi
40+
41+
ARR_BEFORE=$(curl -s GET \
42+
--header 'Accept: application/json' \
43+
--header "Authorization: Bearer ${API_TOKEN}" \
44+
--url "https://api.baremetrics.com/v1/metrics/arr?start_date=${DATE}&end_date=${DATE}" \
45+
| jq '.metrics[0].value')
46+
47+
ARR=$(echo "$ARR_BEFORE * 0.01" | bc -l)
48+
printf "€%'.0f\n" $ARR
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# You may need to install coreutils via homebrew to make this script work (gdate function below).
4+
5+
# Required parameters:
6+
# @raycast.schemaVersion 1
7+
# @raycast.title Lifetime Value
8+
# @raycast.mode inline
9+
# @raycast.refreshTime 1h
10+
11+
# Optional parameters:
12+
# @raycast.icon images/baremetrics.png
13+
# @raycast.packageName Baremetrics
14+
15+
# Documentation:
16+
# @raycast.description Display Lifetime Value (LTV)
17+
# @raycast.author Valentin Chrétien
18+
# @raycast.authorURL https://github.com/valentinchrt
19+
20+
21+
# Configuration
22+
23+
# To create a new API token, do the following:
24+
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
25+
# 2. Copy your Live API Key
26+
# 3. Insert your API token below
27+
28+
API_TOKEN=''
29+
30+
DATE=`gdate -d yesterday '+%Y-%m-%d'`
31+
32+
33+
# Main program
34+
35+
if [[ -z "$API_TOKEN" ]]
36+
then
37+
echo "No API token provided"
38+
exit 1
39+
fi
40+
41+
LTV_BEFORE=$(curl -s GET \
42+
--header 'Accept: application/json' \
43+
--header "Authorization: Bearer ${API_TOKEN}" \
44+
--url "https://api.baremetrics.com/v1/metrics/ltv?start_date=${DATE}&end_date=${DATE}" \
45+
| jq '.metrics[0].value')
46+
47+
LTV=$(echo "$LTV_BEFORE * 0.01" | bc -l)
48+
printf "€%'.0f\n" $LTV
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# You may need to install coreutils via homebrew to make this script work (gdate function below).
4+
5+
# Required parameters:
6+
# @raycast.schemaVersion 1
7+
# @raycast.title Monthly Recurring Revenue
8+
# @raycast.mode inline
9+
# @raycast.refreshTime 1h
10+
11+
# Optional parameters:
12+
# @raycast.icon images/baremetrics.png
13+
# @raycast.packageName Baremetrics
14+
15+
# Documentation:
16+
# @raycast.description Display Monthly Recurring Revenue (MRR)
17+
# @raycast.author Valentin Chrétien
18+
# @raycast.authorURL https://github.com/valentinchrt
19+
20+
21+
# Configuration
22+
23+
# To create a new API token, do the following:
24+
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
25+
# 2. Copy your Live API Key
26+
# 3. Insert your API token below
27+
28+
API_TOKEN=''
29+
30+
DATE=`gdate -d yesterday '+%Y-%m-%d'`
31+
32+
33+
# Main program
34+
35+
if [[ -z "$API_TOKEN" ]]
36+
then
37+
echo "No API token provided"
38+
exit 1
39+
fi
40+
41+
MRR_BEFORE=$(curl -s GET \
42+
--header 'Accept: application/json' \
43+
--header "Authorization: Bearer ${API_TOKEN}" \
44+
--url "https://api.baremetrics.com/v1/metrics/mrr?start_date=${DATE}&end_date=${DATE}" \
45+
| jq '.metrics[0].value')
46+
47+
MRR=$(echo "$MRR_BEFORE * 0.01" | bc -l)
48+
printf "€%'.0f\n" $MRR
4.68 KB
Loading
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# You may need to install coreutils via homebrew to make this script work (gdate function below).
4+
5+
# Required parameters:
6+
# @raycast.schemaVersion 1
7+
# @raycast.title Revenue
8+
# @raycast.mode inline
9+
# @raycast.refreshTime 1h
10+
11+
# Optional parameters:
12+
# @raycast.icon images/baremetrics.png
13+
# @raycast.packageName Baremetrics
14+
15+
# Documentation:
16+
# @raycast.description Display Revenue Dashboard
17+
# @raycast.author Valentin Chrétien
18+
# @raycast.authorURL https://github.com/valentinchrt
19+
20+
21+
# Configuration
22+
23+
# To create a new API token, do the following:
24+
# 1. Go to Settings > API (https://app.baremetrics.com/settings/api)
25+
# 2. Copy your Live API Key
26+
# 3. Insert your API token below
27+
28+
API_TOKEN=''
29+
30+
DATE=`gdate -d today '+%Y-%m-%d'`
31+
32+
33+
# Main program
34+
35+
if [[ -z "$API_TOKEN" ]]
36+
then
37+
echo "No API token provided"
38+
exit 1
39+
fi
40+
41+
ROUGH_MRR=$(curl -s GET \
42+
--header 'Accept: application/json' \
43+
--header "Authorization: Bearer ${API_TOKEN}" \
44+
--url "https://api.baremetrics.com/v1/metrics/mrr?start_date=${DATE}&end_date=${DATE}" \
45+
| jq '.metrics[0].value')
46+
47+
CLEANED_MRR=$(echo "$ROUGH_MRR * 0.01" | bc -l)
48+
MRR=$(printf "€%'.0f\n" $CLEANED_MRR)
49+
50+
ROUGH_ARR=$(curl -s GET \
51+
--header 'Accept: application/json' \
52+
--header "Authorization: Bearer ${API_TOKEN}" \
53+
--url "https://api.baremetrics.com/v1/metrics/arr?start_date=${DATE}&end_date=${DATE}" \
54+
| jq '.metrics[0].value')
55+
56+
CLEANED_ARR=$(echo "$ROUGH_ARR * 0.01" | bc -l)
57+
ARR=$(printf "€%'.0f\n" $CLEANED_ARR)
58+
59+
ROUGH_LTV=$(curl -s GET \
60+
--header 'Accept: application/json' \
61+
--header "Authorization: Bearer ${API_TOKEN}" \
62+
--url "https://api.baremetrics.com/v1/metrics/ltv?start_date=${DATE}&end_date=${DATE}" \
63+
| jq '.metrics[0].value')
64+
65+
CLEANED_LTV=$(echo "$ROUGH_LTV * 0.01" | bc -l)
66+
LTV=$(printf "€%'.0f\n" $CLEANED_LTV)
67+
68+
ROUGH_ARPU=$(curl -s GET \
69+
--header 'Accept: application/json' \
70+
--header "Authorization: Bearer ${API_TOKEN}" \
71+
--url "https://api.baremetrics.com/v1/metrics/arpu?start_date=${DATE}&end_date=${DATE}" \
72+
| jq '.metrics[0].value')
73+
74+
CLEANED_ARPU=$(echo "$ROUGH_ARPU * 0.01" | bc -l)
75+
ARPU=$(printf "€%'.0f\n" $CLEANED_ARPU)
76+
77+
# Display Revenue Dashboard
78+
echo "MRR: $MRR | ARR: $ARR | LTV: $LTV | ARPU: $ARPU"

0 commit comments

Comments
 (0)