Class: Credly::Api::Base

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Requierable
Defined in:
lib/credly/api/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Requierable

#require_at_least_one_file, #require_present

Constructor Details

#initialize(options = Hash.new) ⇒ Base

Returns a new instance of Base.



11
12
13
# File 'lib/credly/api/base.rb', line 11

def initialize(options = Hash.new)
  @client = options[:client]
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



9
10
11
# File 'lib/credly/api/base.rb', line 9

def response
  @response
end

Instance Method Details

#before_request(*args) ⇒ Object



19
20
# File 'lib/credly/api/base.rb', line 19

def before_request(*args)
end

#build_objectObject



15
16
17
# File 'lib/credly/api/base.rb', line 15

def build_object
  return OpenStruct.new(MultiJson.load(@response))
end

#delete(*args) ⇒ Object



40
41
42
43
44
# File 'lib/credly/api/base.rb', line 40

def delete(*args)
  before_request(*args)
  @response = @client.delet(*args)
  build_object
end

#get(*args) ⇒ Object



22
23
24
25
26
# File 'lib/credly/api/base.rb', line 22

def get(*args)
  before_request(*args)
  @response = @client.get(*args)
  build_object
end

#patch(*args) ⇒ Object



46
47
48
49
50
# File 'lib/credly/api/base.rb', line 46

def patch(*args)
  before_request(*args)
  @response = @client.patch(*args)
  build_object
end

#post(*args) ⇒ Object



28
29
30
31
32
# File 'lib/credly/api/base.rb', line 28

def post(*args)
  before_request(*args)
  @response = @client.post(*args)
  build_object
end

#put(*args) ⇒ Object



34
35
36
37
38
# File 'lib/credly/api/base.rb', line 34

def put(*args)
  before_request(*args)
  @response = @client.put(*args)
  build_object
end