ottoflux | 2019-07-03 14:00:34 UTC | #1
Hi there - It looks like billing - subscription overview would be really nice to have for a customer I have monitoring PureCloud with a monitoring package. They prepay X licenses but want to know what their current license usage count is.
Right now you have to (not public, I know) wrap a direct rest call and dynamic out the data you need, but it would be helpful to have.
Here's some incomplete (no error handling) code of what I'm doing to get this. I have another post open on license reporting in general but it doesn't seem to give us the numbers (and licenses) we get from here and this is really what they need in the end.
It looks like it's using (on the billing summary page) ticks for the first day of the current month for the period. Can you use any current (rolling) time or should it only work with the first of the month?
public int LicenseCount(String licenseName) { int retVal = -1; var edgeAPI = new TelephonyProvidersEdgeApi(); //DateTimeOffset periodEnding = new DateTimeOffset(new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1, 0, 0, 0)); String reportURI = "/api/v2/billing/subscriptionoverview?periodEndingTimestamp=" + ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds().ToString();
RestRequest req = new RestRequest(reportURI, Method.GET, DataFormat.Json); req.AddHeader("Authorization", "Bearer " + _authTokenInfo.AccessToken); RestClient rc = new RestClient(edgeAPI.GetBasePath()); var result = rc.Execute(req).Content; dynamic dynJSON = JObject.Parse(result);
var prods = dynJSON.enabledProducts; var usages = dynJSON.usages;
foreach (var usage in usages) { if(usage.name == licenseName) { retVal = usage.usageQuantity; } }
return retVal; }
Thanks! Jason
tim.smith | 2019-07-03 20:32:52 UTC | #2
The publicly available APIs for billing are documented at https://developer.mypurecloud.com/api/rest/v2/billing/. You can request additional APIs, features, and share your use case at https://purecloud.ideas.aha.io/ideas.
ottoflux | 2019-07-03 20:33:34 UTC | #3
Yeah - it's just because the other ones weren't working, so I'm opening a case now.
ottoflux | 2019-07-03 20:34:59 UTC | #4
So those should give me the same numbers on a rolling X days once the problem is fixed?
tim.smith | 2019-07-03 20:38:47 UTC | #5
I'm not sure what problem you're referring to.
ottoflux | 2019-07-03 21:08:14 UTC | #6
Sorry - you have a lot of conversations going on over here. This one:
https://developer.mypurecloud.com/forum/t/getbillingreportsbillableusage-timing-out-failing-when-using-full-datetime/5475
system | 2019-08-03 21:19:08 UTC | #7
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5486