Sha256: 5b2a6bd1ce59c4cf48e915bd5504f3b7b95de950414d0bad1e040bf202a2ce3a

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

module Pin
  class Client
    def initialize(method, args, base_url, auth)
        @method = method
        @args = args
        @base_url = base_url
        @auth = auth
    end

    ##
    # Sends an authenticated request to pin's server
    # args: method (Symbol), args (Hash)
    # eg. args => { url: 'cards', options: { ... } }
    def make_request(times)
      if %i(get post put patch delete).include? @method
        HTTParty.send(@method, "#{@base_url}#{@args[:url]}", body: @args[:options], basic_auth: @auth)
      else
        Pin::PinError.handle_bad_request
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pin_up-1.0.0 lib/pin_up/client.rb
pin_up-0.10.0 lib/pin_up/client.rb