Class: PlayNicely::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/playnicely/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/playnicely/client.rb', line 7

def initialize(username, password)
  @username = username
  @password = password
  
  # call HTTParty
  self.class.basic_auth(@username, @password)
end

Instance Method Details

#create_item(project_id, data) ⇒ Object



51
52
53
# File 'lib/playnicely/client.rb', line 51

def create_item(project_id, data)
  auth_post("/project/#{project_id}/item/create/", :body => data.to_json)
end

#current_user(detail = 'compact') ⇒ Object



23
24
25
# File 'lib/playnicely/client.rb', line 23

def current_user(detail='compact')
  auth_get('/user/current/show/', {:query => {:detail => detail}})
end

#current_user_projects(detail = 'compact') ⇒ Object



31
32
33
# File 'lib/playnicely/client.rb', line 31

def current_user_projects(detail='compact')
  auth_get("/user/current/project/list/",  {:query => {:detail => detail}})
end

#item(project_id, item_id, detail = 'compact') ⇒ Object



43
44
45
# File 'lib/playnicely/client.rb', line 43

def item(project_id, item_id, detail='compact')
  auth_get("/project/#{project_id}/item/#{item_id}/show/",  {:query => {:detail => detail}})
end

#milestone(project_id, milestone_id, detail = 'compact') ⇒ Object



35
36
37
# File 'lib/playnicely/client.rb', line 35

def milestone(project_id, milestone_id, detail='compact')
  auth_get("/project/#{project_id}/milestone/#{milestone_id}/show/",  {:query => {:detail => detail}})
end

#project(project_id, detail = 'compact') ⇒ Object



15
16
17
# File 'lib/playnicely/client.rb', line 15

def project(project_id, detail='compact')
  auth_get("/project/#{project_id}/show/", {:query => {:detail => detail}})
end

#project_items(project_id, detail = 'compact') ⇒ Object



47
48
49
# File 'lib/playnicely/client.rb', line 47

def project_items(project_id, detail='compact')
  auth_get("/project/#{project_id}/item/list/",  {:query => {:detail => detail}})
end

#project_milestones(project_id, detail = 'compact') ⇒ Object



39
40
41
# File 'lib/playnicely/client.rb', line 39

def project_milestones(project_id, detail='compact')
  auth_get("/project/#{project_id}/milestone/list/", {:query => {:detail => detail}})
end

#update_item(project_id, item_id, data) ⇒ Object



55
56
57
# File 'lib/playnicely/client.rb', line 55

def update_item(project_id, item_id, data)
  auth_post("/project/#{project_id}/item/#{item_id}/update/", :body => data.to_json)
end

#user(user_id, detail = 'compact') ⇒ Object



19
20
21
# File 'lib/playnicely/client.rb', line 19

def user(user_id, detail='compact')
  auth_get("/user/#{user_id}/show/", {:query => {:detail => detail}})
end

#user_projects(user_id, detail = 'compact') ⇒ Object



27
28
29
# File 'lib/playnicely/client.rb', line 27

def user_projects(user_id, detail='compact')
  auth_get("/user/#{user_id}/project/list/", {:query => {:detail => detail}})
end