### Get All Devices for a Make Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Fetches all device models and their marketing names associated with a specific manufacturer. This is useful for exploring the range of devices from a particular brand. ```APIDOC ## GET /wurfl/device/make/{make} ### Description Returns all device models and marketing names for a specific manufacturer/brand. ### Method GET ### Endpoint /wurfl/device/make/{make} ### Parameters #### Path Parameters - **make** (string) - Required - The name of the device manufacturer (e.g., "Apple", "Nokia"). #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **devices** (array[object]) - An array of device objects, each containing `modelName` and `marketingName`. - **modelName** (string) - The internal model name of the device. - **marketingName** (string) - The publicly marketed name of the device. #### Response Example ```json [ { "modelName": "iPad", "marketingName": "iPad" }, { "modelName": "iPad 2", "marketingName": "iPad 2" }, { "modelName": "iPad Air", "marketingName": "iPad Air" }, { "modelName": "iPad Mini", "marketingName": "iPad Mini" }, { "modelName": "iPad Pro", "marketingName": "iPad Pro" }, { "modelName": "iPhone", "marketingName": "iPhone" }, { "modelName": "iPhone 11", "marketingName": "iPhone 11" }, { "modelName": "iPhone 11 Pro", "marketingName": "iPhone 11 Pro" }, { "modelName": "iPhone 12", "marketingName": "iPhone 12" }, "..." ] ``` ``` -------------------------------- ### Get All Devices for a Make - Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Fetches all device models and marketing names for a specified manufacturer using the WURFL microservice client in Scala. The example demonstrates retrieving Apple devices, sorting them by model name, and printing a subset, then repeats for Nokia. Requires the WURFL Scala client library. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") // Get all Apple devices val appleDevices = client.getAllDevicesForMake("Apple") // Sort by model name val sortedDevices = appleDevices.sortWith(_.modelName < _.modelName) println(s"Total Apple devices: ${appleDevices.length}") println("First 15 Apple devices:") for (i <- 0 until Math.min(15, sortedDevices.length)) { val device = sortedDevices(i) println(s" - Model: ${device.modelName}, Marketing Name: ${device.marketingName}") } // Get Nokia devices val nokiaDevices = client.getAllDevicesForMake("Nokia") println(s"\nTotal Nokia devices: ${nokiaDevices.length}") client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Get Operating Systems and Versions Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Provides endpoints to retrieve all available operating system names and, for a given OS, all its supported versions from the WURFL database. ```APIDOC ## GET /wurfl/os ## GET /wurfl/os/{osName}/versions ### Description Retrieves all unique operating system names available in the WURFL database. Additionally, for a specified operating system, it returns all its known versions. ### Method GET ### Endpoint - `/wurfl/os` (to get all OS names) - `/wurfl/os/{osName}/versions` (to get versions for a specific OS) ### Parameters #### Path Parameters - **osName** (string) - Optional (for `/wurfl/os/{osName}/versions`) - The name of the operating system (e.g., "Android", "iOS"). #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - For `/wurfl/os`: **oses** (array[string]) - An array containing all unique operating system names. - For `/wurfl/os/{osName}/versions`: **versions** (array[string]) - An array containing all known versions for the specified operating system. #### Response Example (for `/wurfl/os`) ```json [ "Android", "Bada", "BlackBerry OS", "Chrome OS", "Firefox OS", "iOS", "Linux", "Mac OS X", "Nintendo", "PlayStation", "Symbian", "Windows", "Windows Mobile", "Windows Phone", "Windows RT", "..." ] ``` #### Response Example (for `/wurfl/os/Android/versions`) ```json [ "10.0", "11.0", "12.0", "13.0", "14.0", "..." ] ``` ``` -------------------------------- ### Get Operating Systems and Versions - Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Retrieves all available operating system names and their versions from the WURFL database using the Scala client. It lists all OSes, then specifically retrieves and displays recent versions for Android and the total count for iOS. Requires the WURFL Scala client library. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient import scala.util.Sorting.quickSort try { val client = WmClient.apply("http", "localhost", "8080", "") // Get all operating systems val oses = client.getAllOSes() quickSort(oses) println(s"Total operating systems: ${oses.length}") println("Available OSes:") for (os <- oses) { println(s" - $os") } // Get all Android versions val androidVersions = client.getAllVersionsForOS("Android") quickSort(androidVersions) println(s"\nAndroid versions (${androidVersions.length} total):") for (ver <- androidVersions.takeRight(15)) { // Show latest 15 println(s" - $ver") } // Get iOS versions val iosVersions = client.getAllVersionsForOS("iOS") quickSort(iosVersions) println(s"\niOS versions: ${iosVersions.length} total") client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Capability Availability Check Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt This section details how to check if a specific static or virtual capability is supported by the WURFL client. It includes examples for both `hasStaticCapability` and `hasVirtualCapability`. ```APIDOC ## hasStaticCapability / hasVirtualCapability - Check Capability Availability ### Description Checks whether a specific static or virtual capability is supported by the client. ### Method `hasStaticCapability(capabilityName: String): Boolean` `hasVirtualCapability(capabilityName: String): Boolean` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```scala import com.scientiamobile.wurfl.wmclient.scala.WmClient val client = WmClient.apply("http", "localhost", "8080", "") // Check static capabilities println(s" brand_name: ${client.hasStaticCapability("brand_name")}") // Check virtual capabilities println(s" is_app: ${client.hasVirtualCapability("is_app")}") ``` ### Response #### Success Response (Boolean) - `true`: The capability is supported. - `false`: The capability is not supported. #### Response Example ``` true ``` ``` -------------------------------- ### Get All Device Makes - Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Retrieves an array of all device manufacturer names from the WURFL database using the WURFL microservice client in Scala. It sorts the results and prints the total count and the first 20 brands. Requires the WURFL Scala client library. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient import scala.util.Sorting.quickSort try { val client = WmClient.apply("http", "localhost", "8080", "") val deviceMakes = client.getAllDeviceMakes() quickSort(deviceMakes) println(s"Total device manufacturers: ${deviceMakes.length}") println("First 20 brands:") for (i <- 0 until 20) { println(s" - ${deviceMakes(i)}") } client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Get All Device Manufacturers Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Retrieves a list of all unique device manufacturer names available in the WURFL database. The response is an array of strings, which can be sorted for easier processing. ```APIDOC ## GET /wurfl/device/makes ### Description Returns an array of all device brand/manufacturer names available in the WURFL database. ### Method GET ### Endpoint /wurfl/device/makes ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **deviceMakes** (array[string]) - An array containing all unique device manufacturer names. #### Response Example ```json [ "3Q", "4Good", "7Mobile", "A1", "Acer", "Advan", "Ainol", "Alcatel", "AllCall", "Allview", "..." ] ``` ``` -------------------------------- ### Initialize and Use WURFL Microservice Client in Scala Source: https://github.com/wurfl/wurfl-microservice-client-scala/blob/master/README.md Demonstrates how to instantiate the WmClient, retrieve server information, perform device detection based on a User-Agent string, and query device manufacturers and models. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient import scala.util.Sorting.quickSort object Example { def main(args: Array[String]) { val client = WmClient.apply("http", "localhost", "8080", "") val info = client.getInfo() val ua = "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36" client.setCacheSize(100000) client.setRequestedStaticCapabilities(Array[String]("brand_name", "model_name")) client.setRequestedVirtualCapabilities(Array[String]("is_smartphone", "form_factor")) val device = client.lookupUseragent(ua) if (device.error != null && device.error.length > 0) println("An error occurred: " + device.error) else { val capabilities = device.capabilities println("Detected device WURFL ID: " + capabilities.get("wurfl_id")) } val deviceMakes = client.getAllDeviceMakes quickSort(deviceMakes) val devNames = client.getAllDevicesForMake("Apple") devNames.sortWith(_.modelName >= _.modelName) } } ``` -------------------------------- ### Retrieve and Print OS Names using WURFL Microservice Client (Scala) Source: https://github.com/wurfl/wurfl-microservice-client-scala/blob/master/README.md This snippet demonstrates how to use the WURFL Microservice client in Scala to fetch all available operating system names. It then sorts these names using a `quickSort` function and prints them to the console. The `client.getAllOSes` method is used for retrieval, and `client.destroyConnection` is called to clean up resources. ```scala // Now call the WM server to get all operative system names println("Print the list of OSes") val oses = client.getAllOSes // Sort and print all OS names quickSort(oses) for (os <- oses) { printf(" - %s\n", os) } // Cleans all client resources. Any call on client API methods after this one will throw a WmException client.destroyConnection } catch { case e: WmException => // problems such as network errors or internal server problems // note that WmException comes from the Java wrapped API println("An error has occurred: " + e.getMessage) } } } ``` -------------------------------- ### Create WURFL Microservice Client Instance (Scala) Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Creates a new WURFL Microservice client instance by connecting to a WM server at the specified host and port. This factory method is used for all client instance creations. It requires the WURFL Microservice Java client API and Scala 2.13+. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { // Create client connecting to WM server val client = WmClient.apply("http", "localhost", "8080", "") // Verify connection by getting server info val info = client.getInfo() println(s"Connected to WM server version: ${info.getWmVersion}") println(s"WURFL API version: ${info.getWurflApiVersion}") println(s"WURFL file info: ${info.getWurflInfo}") // Clean up when done client.destroyConnection() } catch { case e: WmException => println(s"Connection error: ${e.getMessage}") } ``` -------------------------------- ### Manage Client Connection Lifecycle in Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Illustrates the proper cleanup of client resources using the destroyConnection method. It highlights that subsequent attempts to use the client after destruction will result in a WmException. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") val device = client.lookupUseragent("Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X)") client.destroyConnection() println("Connection destroyed successfully") try { client.lookupUseragent("Mozilla/5.0") } catch { case e: WmException => println(s"Expected error after destroy: ${e.getMessage}") } } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Retrieve and Print Android OS Versions using WURFL Microservice Client (Scala) Source: https://github.com/wurfl/wurfl-microservice-client-scala/blob/master/README.md This Scala code snippet shows how to retrieve all versions for a specific operating system, in this case, 'Android', using the WURFL Microservice client. It fetches the versions using `client.getAllVersionsForOS("Android")`, sorts them using `quickSort`, and then prints each version to the console. The client connection is subsequently destroyed. ```scala // Let's call the WM server to get all version of the Android OS println("Print all versions for the Android OS") val osVersions = client.getAllVersionsForOS("Android") // Sort all Android version numbers and print them. quickSort(osVersions) for (ver <- osVersions) { printf(" - %s\n", ver) } // Cleans all client resources. Any call on client API methods after this one will throw a WmException client.destroyConnection } catch { case e: WmException => // problems such as network errors or internal server problems // note that WmException comes from the Java wrapped API println("An error has occurred: " + e.getMessage) } } } ``` -------------------------------- ### Server Information Retrieval Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt This section describes the `getInfo` method, which retrieves detailed information about the WURFL Microservice server, including API versions, WURFL file details, and available capabilities. ```APIDOC ## getInfo - Get Server Information ### Description Returns information about the WURFL Microservice server including API version, WURFL file version, and available capabilities. ### Method `getInfo(): ServerInfo` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```scala import com.scientiamobile.wurfl.wmclient.scala.WmClient val client = WmClient.apply("http", "localhost", "8080", "") val info = client.getInfo() println(s" WM Server Version: ${info.getWmVersion}") println(s" WURFL File Info: ${info.getWurflInfo}") ``` ### Response #### Success Response (ServerInfo Object) - `getWmVersion()`: String - The version of the WURFL Microservice server. - `getWurflApiVersion()`: String - The version of the WURFL API. - `getWurflInfo()`: String - Information about the WURFL file (e.g., filename and date). - `getStaticCaps()`: Array[String] - An array of available static capability names. - `getVirtualCaps()`: Array[String] - An array of available virtual capability names. #### Response Example ```json { "wmVersion": "2.1.1", "wurflApiVersion": "1.12.7.1", "wurflInfo": "wurfl-2024-01-15.xml.gz", "staticCaps": [...], "virtualCaps": [...] } ``` ``` -------------------------------- ### Check Capability Availability in Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Demonstrates how to verify if specific static or virtual capabilities are supported by the WURFL client. It uses the hasStaticCapability and hasVirtualCapability methods to distinguish between hardware properties and computed virtual values. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") // Check static capabilities (hardware properties) println("Static capabilities:") println(s" brand_name: ${client.hasStaticCapability("brand_name")}") println(s" model_name: ${client.hasStaticCapability("model_name")}") println(s" is_smarttv: ${client.hasStaticCapability("is_smarttv")}") println(s" resolution_width: ${client.hasStaticCapability("resolution_width")}") println(s" is_app (virtual): ${client.hasStaticCapability("is_app")}") // Check virtual capabilities (computed values) println("\nVirtual capabilities:") println(s" is_app: ${client.hasVirtualCapability("is_app")}") println(s" is_smartphone: ${client.hasVirtualCapability("is_smartphone")}") println(s" form_factor: ${client.hasVirtualCapability("form_factor")}") println(s" is_app_webview: ${client.hasVirtualCapability("is_app_webview")}") println(s" brand_name (static): ${client.hasVirtualCapability("brand_name")}") client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Retrieve Server Information in Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Retrieves metadata about the WURFL Microservice server, including API versions, WURFL file info, and supported headers. This is useful for diagnostic purposes and verifying the environment configuration. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") val info = client.getInfo() println("WURFL Microservice Server Information:") println(s" WM Server Version: ${info.getWmVersion}") println(s" WURFL API Version: ${info.getWurflApiVersion}") println(s" WURFL File Info: ${info.getWurflInfo}") val importantHeaders = client.getImportantHeaders() println(s"\nImportant headers for detection (${importantHeaders.length}):") for (header <- importantHeaders.take(10)) { println(s" - $header") } client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Enable Client-Side Caching with setCacheSize Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Activates an internal cache to store detection results, significantly improving performance for repeated lookups. It tracks cache usage for both User-Agent strings and Device IDs. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") client.setCacheSize(100000) val ua = "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36" val device1 = client.lookupUseragent(ua) println(s"Cache size after first lookup: ${client.getActualCacheSizes()(0)}") val device2 = client.lookupUseragent(ua) println(s"Cache size after second lookup: ${client.getActualCacheSizes()(0)}") client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Connection Management Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt This section covers the `destroyConnection` method, used to deallocate resources held by the client. It also explains the behavior after the connection is destroyed. ```APIDOC ## destroyConnection - Clean Up Resources ### Description Deallocates all resources used by the client. Any subsequent API calls will throw a WmException. ### Method `destroyConnection(): Unit` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```scala import com.scientiamobile.wurfl.wmclient.scala.WmClient val client = WmClient.apply("http", "localhost", "8080", "") // Use the client... // Clean up resources when done client.destroyConnection() println("Connection destroyed successfully") // Any further calls will fail try { client.lookupUseragent("Mozilla/5.0") } catch { case e: WmException => println(s"Expected error: ${e.getMessage}") } ``` ### Response #### Success Response (Unit) This method does not return a value upon successful execution. #### Response Example ``` Connection destroyed successfully Expected error: Client has been destroyed ``` ``` -------------------------------- ### Detect Device by User-Agent String (Scala) Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Performs device detection using a User-Agent string and returns device capabilities. This method is useful for identifying devices when only the User-Agent string is available. It requires the WURFL Microservice Java client API and Scala 2.13+. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") // Detect a mobile device val mobileUA = "Mozilla/5.0 (Linux; Android 14; SM-S921N Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/134.0.6998.135 Mobile Safari/537.36" val device = client.lookupUseragent(mobileUA) if (device.error != null && device.error.length > 0) { println(s"Error: ${device.error}") } else { val capabilities = device.capabilities println(s"WURFL ID: ${capabilities.get("wurfl_id")}") println(s"Brand: ${capabilities.get("brand_name")}") println(s"Model: ${capabilities.get("model_name")}") println(s"Form factor: ${capabilities.get("form_factor")}") println(s"Is smartphone: ${capabilities.get("is_smartphone")}") println(s"Is SmartTV: ${capabilities.get("is_smarttv")}") println(s"Device OS: ${capabilities.get("device_os")}") println(s"Device OS version: ${capabilities.get("device_os_version")}") } client.destroyConnection() } catch { case e: WmException => println(s"Detection error: ${e.getMessage}") } ``` -------------------------------- ### Detect Device from Header Map using Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Performs device detection by analyzing a map of HTTP request headers. Headers are treated as case-insensitive. This function requires the `wurfl-microservice-client-scala` library and establishes a connection to the WURFL service. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient import java.util try { val client = WmClient.apply("http", "localhost", "8080", "") // Create headers map (keys should be lowercase) val headers = new util.HashMap[String, String]() headers.put("user-agent", "Mozilla/5.0 (Nintendo Switch; WebApplet) AppleWebKit/601.6 (KHTML, like Gecko) NF/4.0.0.5.9 NintendoBrowser/5.1.0.13341") headers.put("content-type", "gzip, deflate") headers.put("accept-encoding", "application/json") headers.put("x-ucbrowser-device-ua", "Mozilla/5.0 (Nintendo Switch; ShareApplet) AppleWebKit/601.6 (KHTML, like Gecko) NF/4.0.0.5.9 NintendoBrowser/5.1.0.13341") headers.put("device-stock-ua", "Mozilla/5.0 (Nintendo Switch; WifiWebAuthApplet) AppleWebKit/601.6 (KHTML, like Gecko) NF/4.0.0.5.9 NintendoBrowser/5.1.0.13341") val device = client.lookupHeaders(headers) val capabilities = device.capabilities println(s"WURFL ID: ${capabilities.get("wurfl_id")}") println(s"Complete device name: ${capabilities.get("complete_device_name")}") println(s"Form factor: ${capabilities.get("form_factor")}") println(s"Brand: ${capabilities.get("brand_name")}") client.destroyConnection() } catch { case e: WmException => println(s"Detection error: ${e.getMessage}") } ``` -------------------------------- ### Detect Device from HttpServletRequest (Scala) Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Performs device detection using an HttpServletRequest object, commonly used in Java web applications. This method automatically extracts relevant headers for accurate device identification. It requires the WURFL Microservice Java client API and Scala 2.13+. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient import javax.servlet.http.HttpServletRequest // In a servlet or web application context def detectDevice(request: HttpServletRequest): Unit = { try { val client = WmClient.apply("http", "localhost", "8080", "") val device = client.lookupRequest(request) val capabilities = device.capabilities println(s"WURFL ID: ${capabilities.get("wurfl_id")}") println(s"Complete device name: ${capabilities.get("complete_device_name")}") println(s"Form factor: ${capabilities.get("form_factor")}") println(s"Is app: ${capabilities.get("is_app")}") println(s"Is app webview: ${capabilities.get("is_app_webview")}") println(s"Advertised browser version: ${capabilities.get("advertised_browser_version")}") println(s"Advertised device OS: ${capabilities.get("advertised_device_os")}") client.destroyConnection() } catch { case e: WmException => println(s"Detection error: ${e.getMessage}") } } ``` -------------------------------- ### Lookup Device by WURFL ID using Scala Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Retrieves device information for a specific WURFL device identifier. This is useful when the WURFL ID is already known. The function requires the `wurfl-microservice-client-scala` library and connects to the WURFL service. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") // Lookup a specific device by its WURFL ID val device = client.lookupDeviceId("nokia_generic_series40") val capabilities = device.capabilities println(s"WURFL ID: ${capabilities.get("wurfl_id")}") println(s"Brand: ${capabilities.get("brand_name")}") println(s"Model: ${capabilities.get("model_name")}") println(s"Is Android: ${capabilities.get("is_android")}") println(s"Resolution width: ${capabilities.get("resolution_width")}") // Lookup another device val operaDevice = client.lookupDeviceId("generic_opera_mini_version1") println(s"\nOpera Mini device brand: ${operaDevice.capabilities.get("brand_name")}") client.destroyConnection() } catch { case e: WmException => println(s"Lookup error: ${e.getMessage}") // Example: "device is missing" for invalid WURFL IDs } ``` -------------------------------- ### Filter Capabilities with setRequestedStaticCapabilities and setRequestedVirtualCapabilities Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Configures the client to return only specific hardware (static) or computed (virtual) properties. This reduces payload size by limiting the returned data to only what is required for the application. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") client.setRequestedStaticCapabilities(Array[String]( "brand_name", "model_name", "physical_screen_width", "device_os" )) client.setRequestedVirtualCapabilities(Array[String]( "is_smartphone", "form_factor", "is_app", "is_app_webview" )) val ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1" val device = client.lookupUseragent(ua) val capabilities = device.capabilities println(s"Capabilities count: ${capabilities.size}") client.setRequestedStaticCapabilities(null) client.setRequestedVirtualCapabilities(null) client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` -------------------------------- ### Set Mixed Capabilities Filter with setRequestedCapabilities Source: https://context7.com/wurfl/wurfl-microservice-client-scala/llms.txt Sets a combined list of both static and virtual capabilities in a single operation. This is a convenient method for filtering the detection response when a mix of property types is needed. ```scala import com.scientiamobile.wurfl.wmclient.WmException import com.scientiamobile.wurfl.wmclient.scala.WmClient try { val client = WmClient.apply("http", "localhost", "8080", "") val reqCaps = Array( "brand_name", "model_name", "physical_screen_width", "device_os", "is_android", "is_ios", "is_app" ) client.setRequestedCapabilities(reqCaps) val ua = "Mozilla/5.0 (Nintendo Switch; WebApplet) AppleWebKit/601.6 (KHTML, like Gecko) NF/4.0.0.5.9 NintendoBrowser/5.1.0.13341" val device = client.lookupUseragent(ua) println(s"Capabilities returned: ${device.capabilities.size}") client.destroyConnection() } catch { case e: WmException => println(s"Error: ${e.getMessage}") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.