Class: Ulule::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ulule/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ulule/client.rb', line 7

def initialize(options = {})

  @key = options.fetch(:key) { ENV.fetch('ULULE_API_KEY') }
  @username = options.fetch(:username) { ENV.fetch('ULULE_USERNAME') }
  @host = options.fetch(:host) { 'https://api.ulule.com/v1/' }
  @projects = 'projects'
  @comments = 'comments'
  @supporters = 'supporters'
  @news = 'news'
  @users = 'users'

end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



5
6
7
# File 'lib/ulule/client.rb', line 5

def key
  @key
end

#usernameObject

Returns the value of attribute username.



5
6
7
# File 'lib/ulule/client.rb', line 5

def username
  @username
end

Instance Method Details

#meObject



20
21
22
# File 'lib/ulule/client.rb', line 20

def me
  get("#{@users}/#{@username}")
end

#my_projects(options = {}) ⇒ Object



24
25
26
# File 'lib/ulule/client.rb', line 24

def my_projects(options = {})
  get("#{@users}/#{@username}/#{@projects}", options)
end

#news(id) ⇒ Object



44
45
46
# File 'lib/ulule/client.rb', line 44

def news id
  get("#{@news}/#{id}")
end

#news_comments(id, options = {}) ⇒ Object



48
49
50
# File 'lib/ulule/client.rb', line 48

def news_comments(id, options = {})
  get("#{@news}/#{id}/#{@comments}", options)
end

#project(slug) ⇒ Object



32
33
34
# File 'lib/ulule/client.rb', line 32

def project slug
  get("#{@projects}/#{slug}")
end

#project_comments(slug, options = {}) ⇒ Object



36
37
38
# File 'lib/ulule/client.rb', line 36

def project_comments(slug, options = {})
  get("#{@projects}/#{slug}/#{@comments}", options)
end

#project_news(slug) ⇒ Object



40
41
42
# File 'lib/ulule/client.rb', line 40

def project_news slug
  get("#{@projects}/#{slug}/#{@news}")
end

#projects(user, options = {}) ⇒ Object



28
29
30
# File 'lib/ulule/client.rb', line 28

def projects(user, options = {})
  get("#{@users}/#{user}/#{@projects}", options)
end

#supporters(slug) ⇒ Object



52
53
54
# File 'lib/ulule/client.rb', line 52

def supporters slug
  get ("#{@projects}/#{slug}/#{@supporters}")
end