Class: GuestyAPI::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/guesty_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(username:, password: nil, auth_mode: :basic) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
# File 'lib/guesty_api/client.rb', line 11

def initialize(username:, password: nil, auth_mode: :basic)
  @username = username
  @password = password
  @auth_mode = auth_mode
end

Instance Method Details

#delete(url:) ⇒ Object



29
30
31
# File 'lib/guesty_api/client.rb', line 29

def delete(url:)
  self.class.delete(url, **auth)
end

#get(url:, data: nil) ⇒ Object



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

def get(url:, data: nil)
  self.class.get(url, query: data, **auth)
end

#post(url:, data:) ⇒ Object



21
22
23
# File 'lib/guesty_api/client.rb', line 21

def post(url:, data:)
  self.class.post(url, body: data.to_json, **auth)
end

#put(url:, data:) ⇒ Object



25
26
27
# File 'lib/guesty_api/client.rb', line 25

def put(url:, data:)
  self.class.put(url, body: data.to_json, **auth)
end