Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Check if customer has an active subscription
has_active_subscription = client.customers.has_active_subscription("test-customer-key")
print(has_active_subscription) # True or False
if has_active_subscription:
print("Customer has an active subscription")
else:
print("Customer does not have an active subscription")
import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
// Check if customer has an active subscription
const hasActiveSubscription = await metrifoxClient.customers.checkActiveSubscription("test-customer-key");
console.log(hasActiveSubscription); // true or false
if (hasActiveSubscription) {
console.log("Customer has an active subscription");
} else {
console.log("Customer does not have an active subscription");
}
require 'metrifox-sdk'
# Initialize with configuration
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
# Check if customer has an active subscription
has_active_subscription = MetrifoxSDK.customers.has_active_subscription?(customer_key: "test-customer-key")
puts has_active_subscription # true or false
if has_active_subscription
puts "Customer has an active subscription"
else
puts "Customer does not have an active subscription"
end
curl -X GET "https://api.metrifox.com/api/v1/customers/test-customer-key/check-active-subscription" \
-H "x-api-key: your-api-key"
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription")
.header("x-api-key", "<api-key>")
.asString();{
"statusCode": 200,
"message": "",
"data": {
"has_active_subscription": true
}
}Customers
Check Active Subscription
Check if a customer has an active subscription
GET
/
api
/
v1
/
customers
/
{customer_key}
/
check-active-subscription
Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Check if customer has an active subscription
has_active_subscription = client.customers.has_active_subscription("test-customer-key")
print(has_active_subscription) # True or False
if has_active_subscription:
print("Customer has an active subscription")
else:
print("Customer does not have an active subscription")
import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
// Check if customer has an active subscription
const hasActiveSubscription = await metrifoxClient.customers.checkActiveSubscription("test-customer-key");
console.log(hasActiveSubscription); // true or false
if (hasActiveSubscription) {
console.log("Customer has an active subscription");
} else {
console.log("Customer does not have an active subscription");
}
require 'metrifox-sdk'
# Initialize with configuration
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
# Check if customer has an active subscription
has_active_subscription = MetrifoxSDK.customers.has_active_subscription?(customer_key: "test-customer-key")
puts has_active_subscription # true or false
if has_active_subscription
puts "Customer has an active subscription"
else
puts "Customer does not have an active subscription"
end
curl -X GET "https://api.metrifox.com/api/v1/customers/test-customer-key/check-active-subscription" \
-H "x-api-key: your-api-key"
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{defaultHost}/api/v1/customers/{customer_key}/check-active-subscription")
.header("x-api-key", "<api-key>")
.asString();{
"statusCode": 200,
"message": "",
"data": {
"has_active_subscription": true
}
}⌘I

