Class: Cb::Clients::CoverLetters

Inherits:
Base
  • Object
show all
Defined in:
lib/cb/clients/cover_letters.rb

Class Method Summary collapse

Methods inherited from Base

cb_client

Class Method Details

.body(args) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/cb/clients/cover_letters.rb', line 46

def self.body(args)
  body = Hash.new
  body[:id] = args[:id] if args[:id]
  body[:text] = args[:text] if args[:text]
  body[:name] = args[:name] if args[:name]
  body.to_json
end

.create(args = {}) ⇒ Object



21
22
23
24
25
# File 'lib/cb/clients/cover_letters.rb', line 21

def self.create(args={})
  cb_client.cb_put(Cb.configuration.uri_cover_letters,
                   body: body(args),
                   headers: headers(args))
end

.delete(args = {}) ⇒ Object



27
28
29
30
# File 'lib/cb/clients/cover_letters.rb', line 27

def self.delete(args={})
  uri = "#{ Cb.configuration.uri_cover_letters }/#{ args[:id] }"
  cb_client.cb_delete(uri, body: body(args), headers: headers(args))
end

.get(args = {}) ⇒ Object



15
16
17
18
19
# File 'lib/cb/clients/cover_letters.rb', line 15

def self.get(args={})
  uri = Cb.configuration.uri_cover_letters
  uri += "/#{ args[:id] }" if args[:id]
  cb_client.cb_get(uri, headers: headers(args))
end

.headers(args) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/cb/clients/cover_letters.rb', line 38

def self.headers(args)
  {
      'Accept' => 'application/json',
      'Authorization' => "Bearer #{ args[:oauth_token] }",
      'Content-Type' => 'application/json'
  }
end

.update(args = {}) ⇒ Object



32
33
34
35
# File 'lib/cb/clients/cover_letters.rb', line 32

def self.update(args={})
  uri = "#{ Cb.configuration.uri_cover_letters }/#{ args[:id] }"
  cb_client.cb_post(uri, body: body(args), headers: headers(args))
end