Class: PaperCup::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/paper_cup/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/paper_cup/client.rb', line 5

def initialize(opts)
  @options = opts
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/paper_cup/client.rb', line 3

def options
  @options
end

Instance Method Details

#endpoint(path, opts = {}) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/paper_cup/client.rb', line 32

def endpoint(path, opts = {})
  opts = merged_opts_for_request opts.merge(path: path)
  opts.reject! do |k,v|
    k == :method
  end

  return self.class.new(opts)
end

#headersObject



13
14
15
# File 'lib/paper_cup/client.rb', line 13

def headers
  options[:headers] || {}
end

#paramsObject



17
18
19
# File 'lib/paper_cup/client.rb', line 17

def params
  options[:params] || {}
end

#urlObject



9
10
11
# File 'lib/paper_cup/client.rb', line 9

def url
  options.fetch(:url)
end