Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add devices_count method.

  • Loading branch information...
commit 25bbc8b82024bcd02dc0f817558c52f726d84582 1 parent 42bd5e2
@pr1001 pr1001 authored
View
8 src/main/scala/com/bubblefoundry/bfurbanairship/UrbanAirship.scala
@@ -25,6 +25,8 @@ object Device {
case class DevicesPage(device_tokens_count: Int, device_tokens: List[Device], current_page: Int, num_pages: Int, active_device_tokens_count: Int)
+case class DevicesCount(device_tokens_count: Int, active_device_tokens_count: Int)
+
abstract trait APS
object APS {
def apply(alert: String): APSString = APSString(alert, None, None)
@@ -98,6 +100,12 @@ class UrbanAirship(app_token: String, app_secret: Box[String], app_master_secret
})
}) ?~ "App Master Secret Required"
+ def devices_count: Box[DevicesCount] = app_master_secret.flatMap(secret => {
+ import LiftJsonHelpers._
+ val req = devicesReq / "count" / "" as (app_token, secret)
+ Helpers.tryo(http(req ># (_.extract[DevicesCount])))
+ }) ?~ "App Master Secret Required"
+
def push[T <: APS](message: PushMessage[T]): Box[String] = app_master_secret.flatMap(secret => {
import LiftJsonHelpers._
val req = pushReq / "" << write(message) <:< Map("Content-Type" -> "application/json") as (app_token, secret)
Please sign in to comment.
Something went wrong with that request. Please try again.