Sha256: 01e55f2f3297dfbb3e5d1669be5a3d0131949ecc2e2a238d9d84e7307d690978
Contents?: true
Size: 927 Bytes
Versions: 6
Compression:
Stored size: 927 Bytes
Contents
module Storyblok # This object represents a request that is to be made. It gets initialized by the client # with domain specific logic. The client later uses the Request's #url and #query methods # to execute the HTTP request. class Request attr_reader :client, :type, :query, :id, :endpoint def initialize(client, endpoint, query = {}, id = nil) @client = client @endpoint = endpoint @query = query if id @type = :single @id = URI.escape(id) else @type = :multi @id = nil end end # Returns the final URL, relative to a storyblok space def url "#{@endpoint}#{@type == :single ? "/#{id}" : ''}" end # Delegates the actual HTTP work to the client def get client.get(self) end # Returns a new Request object with the same data def copy Marshal.load(Marshal.dump(self)) end end end
Version data entries
6 entries across 6 versions & 1 rubygems