class Workarea::Forter::Gateway

Attributes

options[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/workarea/forter/gateway.rb, line 6
def initialize(options = {})
  @options = options
end

Public Instance Methods

create_decision(order_id, order_details) click to toggle source
# File lib/workarea/forter/gateway.rb, line 10
def create_decision(order_id, order_details)
  body = order_details.to_json

  connection.post do |req|
    req.url "v2/orders/#{order_id}", {}
    req.body = body
  end
end
update_order_status(order_id, order_details) click to toggle source
# File lib/workarea/forter/gateway.rb, line 19
def update_order_status(order_id, order_details)
  body = order_details.to_json

  connection.put do |req|
    req.url "v2/status/#{order_id}", {}
    req.body = body
  end
end

Private Instance Methods

api_version() click to toggle source
# File lib/workarea/forter/gateway.rb, line 52
def api_version
  options[:api_version] || "2.2"
end
connection() click to toggle source
# File lib/workarea/forter/gateway.rb, line 34
def connection
  headers = {
    "Content-Type" => "application/json",
    "x-forter-siteid" => site_id,
    "api-version" => api_version
  }

  request_timeouts = {
    timeout: Workarea.config.forter[:api_timeout],
    open_timeout: Workarea.config.forter[:open_timeout]
  }

  conn = Faraday.new(url: rest_endpoint, headers: headers, request: request_timeouts)
  conn.basic_auth(secret_key, nil)

  conn
end
rest_endpoint() click to toggle source
# File lib/workarea/forter/gateway.rb, line 30
def rest_endpoint
  "https://api.forter-secure.com"
end
secret_key() click to toggle source
# File lib/workarea/forter/gateway.rb, line 56
def secret_key
  options[:secret_key]
end
site_id() click to toggle source
# File lib/workarea/forter/gateway.rb, line 60
def site_id
  options[:site_id]
end