Sha256: 948da606d1e03d98e663ce84cd88e43ac43da912eaf03da5085859067ea5a467

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

module Billogram
  class Client
    include HTTParty
    format :json

    def initialize(username, password, base_uri)
      self.class.default_options.merge!(base_uri: base_uri, basic_auth: {username: username, password: password})
    end

    def get(*args)
      handle_request(:get, *args)
    end

    def post(*args)
      handle_request(:post, *args)
    end

    def put(*args)
      handle_request(:put, *args)
    end

    def delete(*args)
      handle_request(:delete, *args)
    end

    def handle_request(method, *args)
      response = self.class.send(method, *args)
      return response.parsed_response["data"] if response.success?
      raise Billogram::Error.from_response(response)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
billogram-0.4.2 lib/billogram/client.rb