Class: Fizzy::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fizzy/client.rb

Constant Summary collapse

DEFAULT_BASE_URL =
"https://app.fizzy.do"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, account_slug:, base_url: DEFAULT_BASE_URL) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


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

def initialize(token:, account_slug:, base_url: DEFAULT_BASE_URL)
  @token = token
  @account_slug = 
  @base_url = base_url.chomp("/")
  raise ArgumentError, "Invalid URL (must be http or https): #{@base_url}" unless @base_url.match?(%r{\Ahttps?://})
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



9
10
11
# File 'lib/fizzy/client.rb', line 9

def base_url
  @base_url
end

Instance Method Details

#delete(path) ⇒ Object



30
31
32
# File 'lib/fizzy/client.rb', line 30

def delete(path)
  request(:delete, path)
end

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



18
19
20
# File 'lib/fizzy/client.rb', line 18

def get(path, params: {})
  request(:get, path, params: params)
end

#post(path, body: nil) ⇒ Object



22
23
24
# File 'lib/fizzy/client.rb', line 22

def post(path, body: nil)
  request(:post, path, body: body)
end

#put(path, body: nil) ⇒ Object



26
27
28
# File 'lib/fizzy/client.rb', line 26

def put(path, body: nil)
  request(:put, path, body: body)
end