Class: Roqua::RomApi::Sessions::BasicAuthSession

Inherits:
Object
  • Object
show all
Defined in:
lib/roqua/rom_api/sessions/basic_auth_session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rom_host: ENV['ROM_SITE'], username: ENV['ROM_BASICAUTH_ID'], password: ENV['ROM_BASICAUTH_SECRET']) ⇒ BasicAuthSession

Returns a new instance of BasicAuthSession.



9
10
11
12
13
14
15
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 9

def initialize(rom_host: ENV['ROM_SITE'],
               username: ENV['ROM_BASICAUTH_ID'],
               password: ENV['ROM_BASICAUTH_SECRET'])
  @rom_host = rom_host
  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



7
8
9
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 7

def password
  @password
end

#rom_hostObject (readonly)

Returns the value of attribute rom_host.



5
6
7
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 5

def rom_host
  @rom_host
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 6

def username
  @username
end

Instance Method Details

#delete(path, params = {}) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 43

def delete(path, params = {})
  perform_request_or_fail do
    HTTParty.delete(full_url_for(path),
                    query: params,
                    basic_auth: basic_auth)
  end
end

#get(path, params = {}) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 17

def get(path, params = {})
  perform_request_or_fail do
    HTTParty.get(full_url_for(path),
                 query: params,
                 basic_auth: basic_auth)
  end
end

#patch(path, params = {}) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 34

def patch(path, params = {})
  perform_request_or_fail do
    HTTParty.patch(full_url_for(path),
                   headers: {'Content-Type' => 'application/json'},
                   body: params.to_json,
                   basic_auth: basic_auth)
  end
end

#post(path, params = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/roqua/rom_api/sessions/basic_auth_session.rb', line 25

def post(path, params = {})
  perform_request_or_fail do
    HTTParty.post(full_url_for(path),
                  headers: {'Content-Type' => 'application/json'},
                  body: params.to_json,
                  basic_auth: basic_auth)
  end
end