Sha256: 49d2064298345926461801e0cc40e7ed086f2fe683264abee90967954088ef16
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
require "httparty" require 'multi_json' module BillysBilling # Defines HTTP request methods module Request # Perform an HTTP DELETE request def delete_request(path, params={}, options={}) request(:delete, path, params, options) end # Perform an HTTP GET request def get_request(path, params={}, options={}) request(:get, path, params, options) end # Perform an HTTP POST request def post_request(path, params={}, options={}) request(:post, path, params, options) end # Perform an HTTP PUT request def put_request(path, params={}, options={}) request(:put, path, params, options) end private # Perform an HTTP request def request(method, path, params, options) params = params.billyfy_keys! auth = {username: api_key, password: ""} case method.to_sym when :get response = HTTParty.get(endpoint + path, :query => params, :basic_auth => auth) when :post response = HTTParty.post(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth) when :delete response = HTTParty.delete(endpoint + path, :query => params, :basic_auth => auth) when :put response = HTTParty.put(endpoint + path, :body => MultiJson.encode(params), :basic_auth => auth) else end options[:raw] ? response : response.parsed_response.rubyify_keys! end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
billysbilling-rails-1.1.2 | lib/billys_billing/request.rb |
billysbilling-rails-1.1.1 | lib/billys_billing/request.rb |
billysbilling-rails-1.1.0 | lib/billys_billing/request.rb |