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 = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
# File 'lib/credly/api/base.rb', line 11

def initialize(options = {})
  @client = options.delete(:client)
  options.each_pair do |key, value|
    if self.respond_to?("#{key}=")
      self.send("#{key}=", value)
    end
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#before_request(*args) ⇒ Object



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

def before_request(*args)
end

#build_objectObject



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

def build_object
  MultiJson.load(@response)
end

#delete(*args) ⇒ Object



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

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

#get(*args) ⇒ Object



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

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

#patch(*args) ⇒ Object



51
52
53
54
55
# File 'lib/credly/api/base.rb', line 51

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

#post(*args) ⇒ Object



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

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

#put(*args) ⇒ Object



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

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