Class: Device::Setting
- Inherits:
-
Object
- Object
- Device::Setting
- Defined in:
- lib/device/setting.rb
Constant Summary collapse
- FILE_PATH =
"./main/config.dat"
- HOST_PRODUCTION =
"switch.cloudwalk.io"
- HOST_STAGING =
"switch-staging.cloudwalk.io"
- HTTP_HOST_PRODUCTION =
"pos.cloudwalk.io"
- HTTP_HOST_STAGING =
"pos-staging.cloudwalk.io"
- HTTP_PORT =
"443"
- PORT_TCP =
"31415"
- PORT_TCP_SSL =
"31416"
- DEFAULT =
{ "host" => HOST_PRODUCTION, "host_port" => PORT_TCP_SSL, "ssl" => "1", #COMM "media_primary" => "", #COMM "user" => "", #GPRS "apn_password" => "", #GPRS "apn" => "", #GPRS "sim_pin" => "", #GPRS "sim_slot" => "0", #GPRS "sim_dual" => "0", #GPRS "wifi_password" => "", #WIFI "authentication" => "", #WIFI "essid" => "", #WIFI "bssid" => "", #WIFI "cipher" => "", #WIFI "mode" => "", #WIFI "channel" => "", #WIFI "media" => "", #COMM "ip" => "", #COMM "gateway" => "", #COMM "dns1" => "", #COMM "dns2" => "", #COMM "subnet" => "", #COMM "phone" => "", #PPOE "modem_speed" => "", #PPOE "logical_number" => "", #SYS "network_configured" => "", #SYS "touchscreen" => "", #SYS "environment" => "", #SYS "attach_gprs_timeout" => "", #COMM "attach_tries" => "", #COMM "notification_socket_timeout" => "", #SYS Period to create fiber "notification_timeout" => "", #SYS Time to wait message to read "notification_interval" => "", #SYS Check interval "notification_stream_timeout" => "", #SYS Time to wait stream message to read "cw_switch_version" => "", #SYS "cw_pos_timezone" => "", #SYS "tcp_recv_timeout" => "14", #COMM "iso8583_recv_tries" => "0", #COMM "iso8583_send_tries" => "0", #COMM "crypto_dukpt_slot" => "", #SYS "ctls" => "", #SYS "locale" => "pt-br", #SYS "heartbeat" => "", #SYS "boot" => "1", #SYS "company_name" => "", #SYS "metadata_timestamp" => "", "payment_channel_attempts" => "0", "payment_channel_date" => "", "infinitepay_cw_endpoint" => "1", "infinitepay_google_endpoint" => "0", "switch_http_enabled" => "0", "transaction_http_enabled" => "1", "transaction_http_host" => HTTP_HOST_PRODUCTION, "transaction_http_port" => HTTP_PORT, "emv_contactless_amount" => "0", "network_init" => "", "main_app_version" => "" }
Class Attribute Summary collapse
-
.file ⇒ Object
Returns the value of attribute file.
Class Method Summary collapse
- .attach_gprs_timeout ⇒ Object
- .check_environment! ⇒ Object
- .heartbeat ⇒ Object
- .logical_number ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
-
.payment_channel_set_attempts(time = nil, attempts = nil) ⇒ Object
helper.
- .production? ⇒ Boolean
- .setup ⇒ Object
- .staging? ⇒ Boolean
-
.tcp_recv_timeout ⇒ Object
Custom Attributes.
- .to_production! ⇒ Object
- .to_staging! ⇒ Object
- .update_attributes(*args) ⇒ Object
Class Attribute Details
.file ⇒ Object
Returns the value of attribute file.
75 76 77 |
# File 'lib/device/setting.rb', line 75 def file @file end |
Class Method Details
.attach_gprs_timeout ⇒ Object
158 159 160 161 |
# File 'lib/device/setting.rb', line 158 def self.attach_gprs_timeout value = (DaFunk::ParamsDat.file["attach_gprs_timeout"] || @file&.dig("attach_gprs_timeout")) value.to_s.empty? ? nil : value.to_s.to_i end |
.check_environment! ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/device/setting.rb', line 89 def self.check_environment! if self.staging? self.to_staging! else self.to_production! end end |
.heartbeat ⇒ Object
163 164 165 |
# File 'lib/device/setting.rb', line 163 def self.heartbeat DaFunk::ParamsDat.file["heartbeat"] || @file&.dig("heartbeat") end |
.logical_number ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/device/setting.rb', line 167 def self.logical_number if self.file["logical_number"].to_s.strip.empty? self.file["logical_number"] = Device::System.serial else self.file["logical_number"] end end |
.method_missing(method, *args, &block) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/device/setting.rb', line 125 def self.method_missing(method, *args, &block) setup unless @file param = method.to_s if @file[param] @file[param] elsif (param[-1..-1] == "=" && @file[param[0..-2]]) @file[param[0..-2]] = args.first else super end end |
.payment_channel_set_attempts(time = nil, attempts = nil) ⇒ Object
helper
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/device/setting.rb', line 138 def self.payment_channel_set_attempts(time = nil, attempts = nil) setup if time str = "%d-%02d-%02d" update_attributes({ "payment_channel_date" => (str % [time.year, time.mon, time.day]), "payment_channel_attempts" => (attempts || 1) }) else update_attributes({ "payment_channel_attempts" => (attempts || 1) }) end end |
.production? ⇒ Boolean
97 98 99 |
# File 'lib/device/setting.rb', line 97 def self.production? self.environment == "production" end |
.setup ⇒ Object
83 84 85 86 87 |
# File 'lib/device/setting.rb', line 83 def self.setup @file = FileDb.new(FILE_PATH, DEFAULT) self.check_environment! @file end |
.staging? ⇒ Boolean
101 102 103 |
# File 'lib/device/setting.rb', line 101 def self.staging? self.environment == "staging" end |
.tcp_recv_timeout ⇒ Object
Custom Attributes
154 155 156 |
# File 'lib/device/setting.rb', line 154 def self.tcp_recv_timeout DaFunk::ParamsDat.file["tcp_recv_timeout"] || @file&.dig("tcp_recv_timeout") end |
.to_production! ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/device/setting.rb', line 105 def self.to_production! if self.environment != "production" @file.update_attributes("company_name" => "", "environment" => "production", "host" => HOST_PRODUCTION, "transaction_http_host" => HTTP_HOST_PRODUCTION) return true end false end |
.to_staging! ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/device/setting.rb', line 113 def self.to_staging! if self.environment != "staging" @file.update_attributes("company_name" => "", "environment" => "staging", "host" => HOST_STAGING, "transaction_http_host" => HTTP_HOST_STAGING) return true end false end |
.update_attributes(*args) ⇒ Object
121 122 123 |
# File 'lib/device/setting.rb', line 121 def self.update_attributes(*args) @file.update_attributes(*args) end |