Sha256: 0879c3291f2ac28887770874107fb21e8b83d07a7305774e6783b38b164d8176

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 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 [: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

1 entries across 1 versions & 1 rubygems

Version Path
pin_up-0.10.1 lib/pin_up/client.rb