class PMP::Client
Public Class Methods
new(options={}) { |self| ... }
click to toggle source
# File lib/pmp/client.rb, line 7 def initialize(options={}, &block) apply_configuration(options) yield(self) if block_given? end
Public Instance Methods
credentials(opts={})
click to toggle source
# File lib/pmp/client.rb, line 12 def credentials(opts={}) @credentials = nil if (opts != {}) @credentials ||= PMP::Credential.new(options.merge(opts)) end
doc_of_type(type, opts={})
click to toggle source
# File lib/pmp/client.rb, line 32 def doc_of_type(type, opts={}) doc = PMP::CollectionDocument.new(options.merge(root:root(opts)).merge(opts)) doc.links['profile'] = Link.new(href: profile_href_for_type(type), type: "application/vnd.collection.doc+json") doc end
method_missing(method, *args)
click to toggle source
assume you want to make a call on the root doc for stuff it can do
# File lib/pmp/client.rb, line 45 def method_missing(method, *args) self.root.send(method, *args) end
new_root(opts={})
click to toggle source
# File lib/pmp/client.rb, line 27 def new_root(opts={}) root_options = options.merge(opts).merge(href: endpoint) PMP::CollectionDocument.new(root_options).tap{|r| r.root = r } end
profile_href_for_type(type)
click to toggle source
private
# File lib/pmp/client.rb, line 40 def profile_href_for_type(type) "#{endpoint}profiles/#{type}" end
root(opts={})
click to toggle source
# File lib/pmp/client.rb, line 22 def root(opts={}) @root = nil if (opts != {}) @root ||= new_root(opts) end
token(opts={})
click to toggle source
# File lib/pmp/client.rb, line 17 def token(opts={}) @token = nil if (opts != {}) @token ||= PMP::Token.new(options.merge(opts)).get_token end