Skip to content

Latest commit

 

History

History
230 lines (171 loc) · 5.89 KB

wmclient.md

File metadata and controls

230 lines (171 loc) · 5.89 KB

wmclient

-- import "github.com/wurfl/wurfl-microservice-client-golang/v2/scientiamobile/wmclient"

Usage

func GetAPIVersion

func GetAPIVersion() string

GetAPIVersion returns the version number of WM Client API

type JSONDeviceData

type JSONDeviceData struct {
	APIVersion   string            `json:"apiVersion"`
	Capabilities map[string]string `json:"capabilities"`
	Error        string            `json:"error, omitempty"`
	Mtime        int64             `json:"mtime"` 
	Ltime        string            `json:"ltime"` // time of last wurfl.xml file load
}

JSONDeviceData models a WURFL device data in JSON string only format

type JSONDeviceOsVersions

type JSONDeviceOsVersions struct {
	OsName    string `json:"device_os"`
	OsVersion string `json:"device_os_version"`
}

JSONDeviceOsVersions holds device os name and version

type JSONInfoData

type JSONInfoData struct {
	WurflAPIVersion  string   `json:"wurfl_api_version"`
	WurflInfo        string   `json:"wurfl_info"`
	WmVersion        string   `json:"wm_version"`
	ImportantHeaders []string `json:"important_headers"`
	StaticCaps       []string `json:"static_caps"`
	VirtualCaps      []string `json:"virtual_caps"`
	Ltime            string   `json:"ltime"`
}

JSONInfoData - server and API informations

type JSONModelMktName

type JSONModelMktName struct {
	ModelName     string `json:"model_name"`
	MarketingName string `json:"marketing_name,omitempty"`
}

JSONModelMktName holds model_name and marketing_name

type Request

type Request struct {
	LookupHeaders  map[string]string `json:"lookup_headers"`
	RequestedCaps  []string          `json:"requested_caps"`
	RequestedVCaps []string          `json:"requested_vcaps, omitempty"`
	WurflID        string            `json:"wurfl_id, omitempty"`
	TacCode        string            `json:"tac_code, omitempty"`
}

Request - data object that is sent to the WM server in POST requests

type WmClient

type WmClient struct {
	StaticCaps  []string
	VirtualCaps []string

	ImportantHeaders []string
}

WmClient holds http connection data to WM server and the list of static and virtual capabilities it must return in response.

func Create

func Create(Scheme string, Host string, Port string, BaseURI string) (*WmClient, error)

Create : creates object, checks for server visibility

func (*WmClient) DestroyConnection

func (c *WmClient) DestroyConnection()

DestroyConnection - Disposes resources used in connection to server and clears cache and other shared data structures

func (*WmClient) GetActualCacheSizes

func (c *WmClient) GetActualCacheSizes() (int, int)

GetActualCacheSizes return the values of cache size. The first value being the device-id based cache, the second value being the size of the headers-based one

func (*WmClient) GetAllDeviceMakes

func (c *WmClient) GetAllDeviceMakes() ([]string, error)

GetAllDeviceMakes returns a slice of all devices brand_name capabilities in WM server

func (*WmClient) GetAllDevicesForMake

func (c *WmClient) GetAllDevicesForMake(brandName string) ([]JSONModelMktName, error)

GetAllDevicesForMake returns a slice of an aggregate containing model_names and marketing_names for the given brand_name

func (*WmClient) GetAllOSes

func (c *WmClient) GetAllOSes() ([]string, error)

GetAllOSes returns a slice of all devices device_os capabilities in WM server

func (*WmClient) GetAllVersionsForOS

func (c *WmClient) GetAllVersionsForOS(osName string) ([]string, error)

GetAllVersionsForOS returns a slice of an aggregate containing device_os_version for the given os_name

func (*WmClient) GetInfo

func (c *WmClient) GetInfo() (*JSONInfoData, error)

GetInfo - Returns information about the running WM server and API

func (*WmClient) HasStaticCapability

func (c *WmClient) HasStaticCapability(CapName string) bool

HasStaticCapability - returns true if the given CapName exist in this client' static capability set, false otherwise

func (*WmClient) HasVirtualCapability

func (c *WmClient) HasVirtualCapability(CapName string) bool

HasVirtualCapability - returns true if the given CapName exist in this client' virtual capability set, false otherwise

func (*WmClient) LookupDeviceID

func (c *WmClient) LookupDeviceID(deviceID string) (*JSONDeviceData, error)

LookupDeviceID - Searches WURFL device data using its wurfl_id value

func (*WmClient) LookupRequest

func (c *WmClient) LookupRequest(request http.Request) (*JSONDeviceData, error)

LookupRequest - detects a device and returns its data in JSON format

func (*WmClient) LookupUserAgent

func (c *WmClient) LookupUserAgent(userAgent string) (*JSONDeviceData, error)

LookupUserAgent - Searches WURFL device data using the given user-agent for detection

func (*WmClient) SetCacheSize

func (c *WmClient) SetCacheSize(uaMaxEntries int)

SetCacheSize : set UA cache size

func (*WmClient) SetHTTPTimeout

func (c *WmClient) SetHTTPTimeout(connection int, transfer int)

SetHTTPTimeout sets the connection and transfer timeouts for this client in seconds. This function should be called before performing any connection to WM server

func (*WmClient) SetRequestedCapabilities

func (c *WmClient) SetRequestedCapabilities(CapsList []string)

SetRequestedCapabilities - set the given capability names to the set they belong

func (*WmClient) SetRequestedStaticCapabilities

func (c *WmClient) SetRequestedStaticCapabilities(CapsList []string)

SetRequestedStaticCapabilities - set list of standard static capabilities to return

func (*WmClient) SetRequestedVirtualCapabilities

func (c *WmClient) SetRequestedVirtualCapabilities(CapsList []string)

SetRequestedVirtualCapabilities - set list of virtual capabilities to return