Sha256: 52c2bbc7df2ad9daddd2bdcbb51b66a330a90c173061b73a4a7bb10c4236eaa5
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding: utf-8 -*- module PMP class Client include Configuration def initialize(options={}, &block) apply_configuration(options) yield(self) if block_given? end def credentials(opts={}) @credentials = nil if (opts != {}) @credentials ||= PMP::Credential.new(options.merge(opts)) end def token(opts={}) @token = nil if (opts != {}) @token ||= PMP::Token.new(options.merge(opts)).get_token end def root(opts={}) @root = nil if (opts != {}) opts = options.merge(href: endpoint).merge(opts) @root ||= PMP::CollectionDocument.new(opts) end 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 # private def profile_href_for_type(type) "#{endpoint}profiles/#{type}" end # assume you want to make a call on the root doc for stuff it can do def method_missing(method, *args) self.root.send(method, *args) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pmp-0.5.0 | lib/pmp/client.rb |
pmp-0.4.1 | lib/pmp/client.rb |
pmp-0.4.0 | lib/pmp/client.rb |