Permalink
Browse files

Add devices_count method.

  • Loading branch information...
1 parent 42bd5e2 commit 25bbc8b82024bcd02dc0f817558c52f726d84582 @pr1001 pr1001 committed Jan 30, 2011
Showing with 8 additions and 0 deletions.
  1. +8 −0 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)

0 comments on commit 25bbc8b

Please sign in to comment.