Module: StatRaptor::Client::Users

Included in:
StatRaptor::Client
Defined in:
lib/statraptor/client/users.rb

Instance Method Summary collapse

Instance Method Details

#create_user(params = {}) ⇒ Object



4
5
6
# File 'lib/statraptor/client/users.rb', line 4

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

#delete_user(user_credentials) ⇒ Object



8
9
10
# File 'lib/statraptor/client/users.rb', line 8

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

#find_or_create_user(params = {}) ⇒ Object



16
17
18
19
20
# File 'lib/statraptor/client/users.rb', line 16

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

#get_user(user_credentials) ⇒ Object

This StatRaptor API endpoint isn’t available yet

Raises:

  • (NotImplementedError)


23
24
25
26
# File 'lib/statraptor/client/users.rb', line 23

def get_user(user_credentials)
  raise NotImplementedError
  get("/api/v1/users/#{user_credentials}.json")
end

#get_usersObject



12
13
14
# File 'lib/statraptor/client/users.rb', line 12

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