Class: Scanii::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/scanii/target.rb

Overview

Scanii regional API endpoints.

Pass one of the predefined regional constants (e.g. US1) to Client#initialize via the endpoint: keyword. The constructor also accepts an arbitrary URL String for testing against scanii-cli or other local mocks:

Scanii::Client.new(key: "k", secret: "s", endpoint: Scanii::Target::US1)
Scanii::Client.new(key: "k", secret: "s", endpoint: Scanii::Target.new("http://localhost:4000"))

Scanii::Target::AUTO (latency-based routing) is intentionally not provided —customer data residency / chain-of-custody compliance requires an explicit regional choice.

Constant Summary collapse

US1 =
new("https://api-us1.scanii.com").freeze
EU1 =
new("https://api-eu1.scanii.com").freeze
EU2 =
new("https://api-eu2.scanii.com").freeze
AP1 =
new("https://api-ap1.scanii.com").freeze
AP2 =
new("https://api-ap2.scanii.com").freeze
CA1 =
new("https://api-ca1.scanii.com").freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Target

Returns a new instance of Target.

Parameters:

  • url (String)

    base URL for the target endpoint

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/scanii/target.rb', line 21

def initialize(url)
  raise ArgumentError, "Target URL must be a non-empty String" if url.nil? || url.to_s.empty?

  @url = url.to_s
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



18
19
20
# File 'lib/scanii/target.rb', line 18

def url
  @url
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



33
34
35
# File 'lib/scanii/target.rb', line 33

def ==(other)
  other.is_a?(Target) && other.url == @url
end

#hashObject



39
40
41
# File 'lib/scanii/target.rb', line 39

def hash
  @url.hash
end

#to_sObject

Coerce to String (the base URL). Lets Scanii::Target instances be used interchangeably with String URLs in endpoint:.



29
30
31
# File 'lib/scanii/target.rb', line 29

def to_s
  @url
end