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
- #domain_lti_by_domain_and_lti(domain_name, lti_identifier) ⇒ Object
- #domain_ltis(**params) ⇒ Object
- #domain_ltis_by_domain(domain_name) ⇒ Object
- #domain_ltis_by_lti(lti_identifier) ⇒ Object
- #domains(**params) ⇒ Object
-
#initialize(secret) ⇒ Client
constructor
A new instance of Client.
- #lti_by_identifier(identifier) ⇒ Object
- #ltis(**params) ⇒ Object
- #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 |
#domain_lti_by_domain_and_lti(domain_name, lti_identifier) ⇒ Object
84 85 86 87 88 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 84 def domain_lti_by_domain_and_lti(domain_name, lti_identifier) path = "api/v1/domains/#{domain_name}/ltis/#{lti_identifier}/" body = get(path) list_of_models(models::DomainLti, body) end |
#domain_ltis(**params) ⇒ Object
66 67 68 69 70 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 66 def domain_ltis(**params) path = 'api/v1/domainLtis/' body = get(path, params) list_of_models(models::DomainLti, body) end |
#domain_ltis_by_domain(domain_name) ⇒ Object
72 73 74 75 76 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 72 def domain_ltis_by_domain(domain_name) path = "api/v1/domains/#{domain_name}/ltis/" body = get(path) list_of_models(models::DomainLti, body) end |
#domain_ltis_by_lti(lti_identifier) ⇒ Object
78 79 80 81 82 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 78 def domain_ltis_by_lti(lti_identifier) path = "api/v1/domainLtis/?lti__identifier=#{lti_identifier}" body = get(path) list_of_models(models::DomainLti, 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 |
#lti_by_identifier(identifier) ⇒ Object
96 97 98 99 100 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 96 def lti_by_identifier(identifier) path = "api/v1/ltis/#{identifier}/" body = get(path) models::Lti.new(body) end |
#ltis(**params) ⇒ Object
90 91 92 93 94 |
# File 'lib/platform_sdk/id_mapper/client.rb', line 90 def ltis(**params) path = 'api/v1/ltis/' body = get(path, params) list_of_models(models::Lti, 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 |