Automatic multi account status

Just create a new worker, insert this script and enter in your API key under v.mainapikey (the one sent the email) and all accounts API keys you want to check in the v.keys array.

💡

Remember to update the array numbers going up from 0.

As long as your have the email alert type turned on you will get an update when ever the worker runs. You can then set when it will run by clicking the button directly under the workers image on the menu to set how often it will get triggered.

Example of email

Hey **** ****, Here is the current status of your accounts *** *** @*** Email: *** Balance: $99.99 Containers: 105 Week Cost: $2.99 *** *** @*** Email: *** Balance: $99.99 Containers: 32 Week Cost: $2.99 *** *** @*** Email: *** Balance: $99.99 Containers: 2 Week Cost: $2.99

v.mainapikey="PUTYOURKEYHERE"

v.keys[0]="PUTYOURKEYHERE"
v.keys[1]="PUTYOURKEYHERE"
v.keys[2]="PUTYOURKEYHERE"
v.keys[3]="PUTYOURKEYHERE"

v.title="NodeHost Overview"
v.message="Here is the current status of your accounts"

v.count=s.array_count(v.keys)

v.number=0
while v.number<v.count

    v.check=v.keys[v.number]
    v.printback=f.checkaccount("v.check")
    v.message="v.message v.printback"

    v.number+1
end

f.checkaccount{
    v.key=v.function_passed[0]
    v.getuserinfo=s.http_request_get("https://api.nodehost.cloud/get_account_info?api_key=v.key")
    v.userinfo=s.json_decode(v.getuserinfo)
    if set v.userinfo[data][credit]
        v.credit=v.userinfo[data][credit]
        v.credit/100
    end
    
    v.getweekcost=s.http_request_get("https://api.nodehost.cloud/get_account_billing_usage?api_key=v.key&days=7")
    v.weekcost=s.json_decode(v.getweekcost)
    if set v.weekcost[data][ammount]
        v.cost=v.weekcost[data][ammount]
    else
        v.cost="unknown"
    end
    
    v.getcontainers=s.http_request_get("https://api.nodehost.cloud/get_services_containers_list?api_key=v.key")
    v.containers=s.json_decode(v.getcontainers)
    if notset v.containers[data][error]
        v.countcontainers=s.array_count(v.containers[data]) 
    else
        v.countcontainers="unknown"
    end
  
    s.echo("<BR>")
    s.echo("<div><strong>v.userinfo[data][first_name] v.userinfo[data][last_name]</strong> @v.userinfo[data][username]</div>")
    s.echo("<div>Email: v.userinfo[data][email]</div>")
    s.echo("<div>Balance: $v.credit</div>")
    s.echo("<div>Containers: v.countcontainers</div>")
    s.echo("<div>Week Cost: $v.cost</div>")
  
}

v.message=s.base64_encode(v.message)

v.data[subject]=v.title
v.data[message]=v.message

v.sendemail=s.http_request_post("https://api.nodehost.cloud/post_account_email_create?api_key=v.mainapikey&type=alert&encoded=true",v.data)
v.response=s.json_decode(v.sendemail)
if notset v.response[data][error]
	s.echo("EMAIL SENT")
else
	s.echo("EMAIL DID NOT SEND")
end