class PMP::Credential
Constants
- CREDENTIAL_PARAMS
Attributes
root[RW]
Public Class Methods
new(options={}) { |self| ... }
click to toggle source
# File lib/pmp/credential.rb, line 14 def initialize(options={}, &block) apply_configuration(options) self.root = current_options.delete(:root) yield(self) if block_given? end
Public Instance Methods
create(params={})
click to toggle source
# File lib/pmp/credential.rb, line 27 def create(params={}) response = request(:post, create_credentials_url, create_params(params)) response.body end
create_credentials_url()
click to toggle source
# File lib/pmp/credential.rb, line 62 def create_credentials_url root.auth['urn:collectiondoc:form:createcredentials'].url end
create_params(params={})
click to toggle source
# File lib/pmp/credential.rb, line 37 def create_params(params={}) HashWithIndifferentAccess.new({ scope: 'read', token_expires_in: 60*60*24*30, label: "#{user}: #{Time.now}" }).merge(params.select{|k,v| CREDENTIAL_PARAMS.include?(k.to_sym)}) end
credentials_url()
click to toggle source
# File lib/pmp/credential.rb, line 58 def credentials_url root.auth['urn:collectiondoc:form:listcredentials'].url end
destroy(client_id)
click to toggle source
# File lib/pmp/credential.rb, line 32 def destroy(client_id) response = request(:delete, remove_credentials_url(client_id)) response.body end
list()
click to toggle source
# File lib/pmp/credential.rb, line 22 def list response = request(:get, credentials_url) response.body end
remove_credentials_url(client_id)
click to toggle source
# File lib/pmp/credential.rb, line 66 def remove_credentials_url(client_id) link = root.auth['urn:collectiondoc:form:removecredentials'] link.where(client_id: client_id).url end