Class: Pin::Client
- Inherits:
-
Object
- Object
- Pin::Client
- Defined in:
- lib/pin_up/client.rb
Instance Method Summary collapse
-
#initialize(method, args, base_url, auth, timeout) ⇒ Client
constructor
A new instance of Client.
-
#make_request ⇒ Object
Sends an authenticated request to pin’s server args: method (Symbol), args (Hash) eg.
Constructor Details
#initialize(method, args, base_url, auth, timeout) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 |
# File 'lib/pin_up/client.rb', line 3 def initialize(method, args, base_url, auth, timeout) @method = method @args = args @base_url = base_url @auth = auth @timeout = timeout end |
Instance Method Details
#make_request ⇒ Object
Sends an authenticated request to pin’s server args: method (Symbol), args (Hash) eg. args => { url: ‘cards’, options: { … } }
15 16 17 18 19 20 21 |
# File 'lib/pin_up/client.rb', line 15 def make_request if %i(get post put patch delete).include? @method HTTParty.send(@method, "#{@base_url}#{@args[:url]}", body: @args[:options], basic_auth: @auth, timeout: @timeout) else Pin::PinError.handle_bad_request end end |