Class: ProcessOut::Device
- Inherits:
-
Object
- Object
- ProcessOut::Device
- Defined in:
- lib/processout/device.rb
Instance Attribute Summary collapse
-
#app_color_depth ⇒ Object
Returns the value of attribute app_color_depth.
-
#app_java_enabled ⇒ Object
Returns the value of attribute app_java_enabled.
-
#app_language ⇒ Object
Returns the value of attribute app_language.
-
#app_screen_height ⇒ Object
Returns the value of attribute app_screen_height.
-
#app_screen_width ⇒ Object
Returns the value of attribute app_screen_width.
-
#app_timezone_offset ⇒ Object
Returns the value of attribute app_timezone_offset.
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#header_accept ⇒ Object
Returns the value of attribute header_accept.
-
#header_referer ⇒ Object
Returns the value of attribute header_referer.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#request_origin ⇒ Object
Returns the value of attribute request_origin.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#fill_with_data(data) ⇒ Object
- Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API.
- Fills the object with data coming from the API Params:
-
#initialize(client, data = {}) ⇒ Device
constructor
- Initializes the Device object Params:
client
ProcessOut
client instancedata
-
data that can be used to fill the object.
- Initializes the Device object Params:
-
#new(data = {}) ⇒ Object
Create a new Device using the current client.
-
#prefill(data) ⇒ Object
- Prefills the object with the data passed as parameters Params:
data
-
Hash
of data.
- Prefills the object with the data passed as parameters Params:
-
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want.
Constructor Details
#initialize(client, data = {}) ⇒ Device
Initializes the Device object Params:
client
-
ProcessOut
client instance data
-
data that can be used to fill the object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/processout/device.rb', line 83 def initialize(client, data = {}) @client = client self.request_origin = data.fetch(:request_origin, nil) self.id = data.fetch(:id, nil) self.channel = data.fetch(:channel, nil) self.ip_address = data.fetch(:ip_address, nil) self.user_agent = data.fetch(:user_agent, nil) self.header_accept = data.fetch(:header_accept, nil) self.header_referer = data.fetch(:header_referer, nil) self.app_color_depth = data.fetch(:app_color_depth, nil) self.app_java_enabled = data.fetch(:app_java_enabled, nil) self.app_language = data.fetch(:app_language, nil) self.app_screen_height = data.fetch(:app_screen_height, nil) self.app_screen_width = data.fetch(:app_screen_width, nil) self.app_timezone_offset = data.fetch(:app_timezone_offset, nil) end |
Instance Attribute Details
#app_color_depth ⇒ Object
Returns the value of attribute app_color_depth.
18 19 20 |
# File 'lib/processout/device.rb', line 18 def app_color_depth @app_color_depth end |
#app_java_enabled ⇒ Object
Returns the value of attribute app_java_enabled.
19 20 21 |
# File 'lib/processout/device.rb', line 19 def app_java_enabled @app_java_enabled end |
#app_language ⇒ Object
Returns the value of attribute app_language.
20 21 22 |
# File 'lib/processout/device.rb', line 20 def app_language @app_language end |
#app_screen_height ⇒ Object
Returns the value of attribute app_screen_height.
21 22 23 |
# File 'lib/processout/device.rb', line 21 def app_screen_height @app_screen_height end |
#app_screen_width ⇒ Object
Returns the value of attribute app_screen_width.
22 23 24 |
# File 'lib/processout/device.rb', line 22 def app_screen_width @app_screen_width end |
#app_timezone_offset ⇒ Object
Returns the value of attribute app_timezone_offset.
23 24 25 |
# File 'lib/processout/device.rb', line 23 def app_timezone_offset @app_timezone_offset end |
#channel ⇒ Object
Returns the value of attribute channel.
13 14 15 |
# File 'lib/processout/device.rb', line 13 def channel @channel end |
#header_accept ⇒ Object
Returns the value of attribute header_accept.
16 17 18 |
# File 'lib/processout/device.rb', line 16 def header_accept @header_accept end |
#header_referer ⇒ Object
Returns the value of attribute header_referer.
17 18 19 |
# File 'lib/processout/device.rb', line 17 def header_referer @header_referer end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/processout/device.rb', line 12 def id @id end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
14 15 16 |
# File 'lib/processout/device.rb', line 14 def ip_address @ip_address end |
#request_origin ⇒ Object
Returns the value of attribute request_origin.
11 12 13 |
# File 'lib/processout/device.rb', line 11 def request_origin @request_origin end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
15 16 17 |
# File 'lib/processout/device.rb', line 15 def user_agent @user_agent end |
Instance Method Details
#fill_with_data(data) ⇒ Object
Fills the object with data coming from the API Params:
data
-
Hash
of data coming from the API
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/processout/device.rb', line 129 def fill_with_data(data) if data.nil? return self end if data.include? "request_origin" self.request_origin = data["request_origin"] end if data.include? "id" self.id = data["id"] end if data.include? "channel" self.channel = data["channel"] end if data.include? "ip_address" self.ip_address = data["ip_address"] end if data.include? "user_agent" self.user_agent = data["user_agent"] end if data.include? "header_accept" self.header_accept = data["header_accept"] end if data.include? "header_referer" self.header_referer = data["header_referer"] end if data.include? "app_color_depth" self.app_color_depth = data["app_color_depth"] end if data.include? "app_java_enabled" self.app_java_enabled = data["app_java_enabled"] end if data.include? "app_language" self.app_language = data["app_language"] end if data.include? "app_screen_height" self.app_screen_height = data["app_screen_height"] end if data.include? "app_screen_width" self.app_screen_width = data["app_screen_width"] end if data.include? "app_timezone_offset" self.app_timezone_offset = data["app_timezone_offset"] end self end |
#new(data = {}) ⇒ Object
Create a new Device using the current client
103 104 105 |
# File 'lib/processout/device.rb', line 103 def new(data = {}) Device.new(@client, data) end |
#prefill(data) ⇒ Object
Prefills the object with the data passed as parameters Params:
data
-
Hash
of data
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/processout/device.rb', line 179 def prefill(data) if data.nil? return self end self.request_origin = data.fetch(:request_origin, self.request_origin) self.id = data.fetch(:id, self.id) self.channel = data.fetch(:channel, self.channel) self.ip_address = data.fetch(:ip_address, self.ip_address) self.user_agent = data.fetch(:user_agent, self.user_agent) self.header_accept = data.fetch(:header_accept, self.header_accept) self.header_referer = data.fetch(:header_referer, self.header_referer) self.app_color_depth = data.fetch(:app_color_depth, self.app_color_depth) self.app_java_enabled = data.fetch(:app_java_enabled, self.app_java_enabled) self.app_language = data.fetch(:app_language, self.app_language) self.app_screen_height = data.fetch(:app_screen_height, self.app_screen_height) self.app_screen_width = data.fetch(:app_screen_width, self.app_screen_width) self.app_timezone_offset = data.fetch(:app_timezone_offset, self.app_timezone_offset) self end |
#to_json(options) ⇒ Object
Overrides the JSON marshaller to only send the fields we want
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/processout/device.rb', line 108 def to_json() { "request_origin": self.request_origin, "id": self.id, "channel": self.channel, "ip_address": self.ip_address, "user_agent": self.user_agent, "header_accept": self.header_accept, "header_referer": self.header_referer, "app_color_depth": self.app_color_depth, "app_java_enabled": self.app_java_enabled, "app_language": self.app_language, "app_screen_height": self.app_screen_height, "app_screen_width": self.app_screen_width, "app_timezone_offset": self.app_timezone_offset, }.to_json end |