Class: Billogram::Client
- Inherits:
-
Object
- Object
- Billogram::Client
- Includes:
- HTTParty
- Defined in:
- lib/billogram/client.rb
Instance Method Summary collapse
- #delete(*args) ⇒ Object
- #get(*args) ⇒ Object
- #handle_request(method, *args) ⇒ Object
-
#initialize(username, password, base_uri) ⇒ Client
constructor
A new instance of Client.
- #post(*args) ⇒ Object
- #put(*args) ⇒ Object
Constructor Details
#initialize(username, password, base_uri) ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/billogram/client.rb', line 6 def initialize(username, password, base_uri) self.class..merge!(base_uri: base_uri, basic_auth: {username: username, password: password}) end |
Instance Method Details
#delete(*args) ⇒ Object
22 23 24 |
# File 'lib/billogram/client.rb', line 22 def delete(*args) handle_request(:delete, *args) end |
#get(*args) ⇒ Object
10 11 12 |
# File 'lib/billogram/client.rb', line 10 def get(*args) handle_request(:get, *args) end |
#handle_request(method, *args) ⇒ Object
26 27 28 29 30 |
# File 'lib/billogram/client.rb', line 26 def handle_request(method, *args) response = self.class.send(method, *args) return response.parsed_response["data"] if response.code == 200 raise Billogram::Error.from_response(response) end |
#post(*args) ⇒ Object
14 15 16 |
# File 'lib/billogram/client.rb', line 14 def post(*args) handle_request(:post, *args) end |
#put(*args) ⇒ Object
18 19 20 |
# File 'lib/billogram/client.rb', line 18 def put(*args) handle_request(:put, *args) end |