lib/pmp/client.rb in pmp-0.1.3 vs lib/pmp/client.rb in pmp-0.2.0
- old
+ new
@@ -8,16 +8,32 @@
def initialize(options={}, &block)
apply_configuration(options)
yield(self) if block_given?
end
+ def credentials(opts={})
+ @credentials ||= PMP::Credential.new(options.merge(opts))
+ end
+
def token(opts={})
@token ||= PMP::Token.new(options.merge(opts)).get_token
end
- def root(opts={}, &block)
+ def root(opts={})
opts = options.merge(href: endpoint).merge(opts)
- @root ||= PMP::CollectionDocument.new(opts, &block)
+ @root ||= PMP::CollectionDocument.new(opts)
+ end
+
+ def doc_of_type(type, opts={})
+ doc = PMP::CollectionDocument.new(options.merge(opts))
+ doc.links['profile'] = Link.new(href: profile_href_for_type(type), type: "application/vnd.pmp.collection.doc+json")
+ doc
+ end
+
+ # private
+
+ def profile_href_for_type(type)
+ "#{endpoint}profiles/#{type}"
end
end
end