Class: DPay::DeviceInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/dpay/payment/device_info.rb,
sig/dpay/payment/device_info.rbs

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ DeviceInfo

Returns a new instance of DeviceInfo.

Parameters:

  • fields (Hash[String, untyped])


26
27
28
29
# File 'lib/dpay/payment/device_info.rb', line 26

def initialize(fields)
  @fields = fields
  @browser_java_enabled = nil
end

Class Method Details

.create(browser_accept_header:, browser_language:, browser_color_depth:, browser_screen_height:, browser_screen_width:, browser_tz:, browser_user_agent:, system_family:, geo_localization:, device_id:, application_name:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dpay/payment/device_info.rb', line 5

def self.create(browser_accept_header:, browser_language:, browser_color_depth:, browser_screen_height:,
                browser_screen_width:, browser_tz:, browser_user_agent:, system_family:, geo_localization:,
                device_id:, application_name:)
  new(
    { "browserAcceptHeader" => browser_accept_header, "browserLanguage" => browser_language,
      "browserColorDepth" => browser_color_depth, "browserScreenHeight" => browser_screen_height,
      "browserScreenWidth" => browser_screen_width, "browserTZ" => browser_tz,
      "browserUserAgent" => browser_user_agent, "systemFamily" => system_family,
      "geoLocalization" => geo_localization, "deviceID" => bounded(device_id, "Device ID"),
      "applicationName" => bounded(application_name, "Application name") }
  )
end

Instance Method Details

#to_hHash[String, untyped]

Returns:

  • (Hash[String, untyped])


36
37
38
39
40
# File 'lib/dpay/payment/device_info.rb', line 36

def to_h
  data = @fields.dup
  data["browserJavaEnabled"] = @browser_java_enabled ? "true" : "false" unless @browser_java_enabled.nil?
  data
end

#with_browser_java_enabled(enabled) ⇒ self

Parameters:

  • enabled (Boolean)

Returns:

  • (self)


31
32
33
34
# File 'lib/dpay/payment/device_info.rb', line 31

def with_browser_java_enabled(enabled)
  @browser_java_enabled = enabled
  self
end