Class: PlatformSdk::IdMapper::Client
- Inherits:
- 
      Object
      
        - Object
- PlatformSdk::IdMapper::Client
 
- Defined in:
- lib/platform_sdk/id_mapper/client.rb
Overview
IdMapper::Client
Instance Attribute Summary collapse
- 
  
    
      #conn  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute conn. 
- 
  
    
      #domain  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute domain. 
- 
  
    
      #token  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute token. 
Instance Method Summary collapse
- #domain_by_name(name) ⇒ Object
- #domains(**params) ⇒ Object
- #domains_by_key(key) ⇒ Object
- 
  
    
      #initialize(secret)  ⇒ Client 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Client. 
- #pairs(guid) ⇒ Object
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
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
| 7 8 9 | # File 'lib/platform_sdk/id_mapper/client.rb', line 7 def conn @conn end | 
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
| 7 8 9 | # File 'lib/platform_sdk/id_mapper/client.rb', line 7 def domain @domain end | 
#token ⇒ Object (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
#domain_by_name(name) ⇒ Object
| 60 61 62 63 64 | # File 'lib/platform_sdk/id_mapper/client.rb', line 60 def domain_by_name(name) path = "api/v1/domains/#{name}/" body = get(path) models::Domain.new(body) end | 
#domains(**params) ⇒ Object
| 54 55 56 57 58 | # File 'lib/platform_sdk/id_mapper/client.rb', line 54 def domains(**params) path = 'api/v1/domains/' body = get(path, params) list_of_models(models::Domain, body) end | 
#domains_by_key(key) ⇒ Object
| 66 67 68 69 70 | # File 'lib/platform_sdk/id_mapper/client.rb', line 66 def domains_by_key(key) path = "api/v1/domains?key=#{key}" body = get(path) list_of_models(models::Domain, body) end | 
#pairs(guid) ⇒ Object
| 45 46 47 48 49 50 51 52 | # File 'lib/platform_sdk/id_mapper/client.rb', line 45 def pairs(guid) path = "api/v1/pairs/#{guid}" begin get(path) rescue Faraday::ResourceNotFound raise PlatformSdk::IdMapper::PairNotFoundError, msg = guid end end |