Class: PlatformSdk::IdMapper::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/platform_sdk/id_mapper/client.rb

Overview

IdMapper::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/platform_sdk/id_mapper/client.rb', line 9

def initialize(secret)
  @token = secret[:token]
  @domain = secret[:domain]
  @token ||= PlatformSdk::IdMapper.token
  @domain ||= PlatformSdk::IdMapper.domain

  @conn = Faraday.new("https://#{@domain}") do |faraday|
    faraday.headers = headers
    faraday.adapter Faraday.default_adapter
    faraday.response :json, content_type: /\bjson$/
    faraday.response :raise_error
  end
end

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



7
8
9
# File 'lib/platform_sdk/id_mapper/client.rb', line 7

def conn
  @conn
end

#domainObject (readonly)

Returns the value of attribute domain.



7
8
9
# File 'lib/platform_sdk/id_mapper/client.rb', line 7

def domain
  @domain
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/platform_sdk/id_mapper/client.rb', line 7

def token
  @token
end

Instance Method Details

#pairs(guid) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/platform_sdk/id_mapper/client.rb', line 23

def pairs(guid)
  begin
    response = @conn.get("api/v1/pairs/#{guid}")
  rescue Faraday::ResourceNotFound
    raise PlatformSdk::IdMapper::PairNotFoundError, msg = guid
  end
  response.body
end