Sha256: ba0b4c157725fb0267e6086c40ceea25b0c547315670d8732641ab62cb0ae102

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

module StatRaptor
  class Client
    module Users
      def create_user(params = {})
        post("/api/v1/users.json", :user => params)
      end

      def delete_user(user_credentials)
        delete("/api/v1/users/#{user_credentials}.json")
      end

      def get_users
        get("/api/v1/users.json")
      end

      def find_or_create_user(params = {})
        users = get_users
        user = users.detect{|u| (u['email'] == params[:email]) && (u['chargify_api_key'] == params[:chargify_api_key])}
        !!user ? user : create_user(params)
      end

      # This StatRaptor API endpoint isn't available yet
      def get_user(user_credentials)
        raise NotImplementedError
        get("/api/v1/users/#{user_credentials}.json")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
statraptor-0.2.6 lib/statraptor/client/users.rb
statraptor-0.2.5 lib/statraptor/client/users.rb
statraptor-0.2.4 lib/statraptor/client/users.rb
statraptor-0.2.3 lib/statraptor/client/users.rb