Class: IdonethisCli::Client::Entry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Entry

Returns a new instance of Entry.



6
7
8
# File 'lib/idonethis_cli/client/entry.rb', line 6

def initialize(token)
  @token = token
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/idonethis_cli/client/entry.rb', line 4

def error
  @error
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/idonethis_cli/client/entry.rb', line 4

def token
  @token
end

Instance Method Details

#create(team_id, body) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/idonethis_cli/client/entry.rb', line 10

def create(team_id, body)
  response = token.post(API_PATH + '/entries', 
                        params: { body: body, team_id: team_id})
  JSON.parse(response.body)
rescue => e
  @error = e.response
  false
end

#list(team_id) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/idonethis_cli/client/entry.rb', line 19

def list(team_id)
  response = token.get(API_PATH + '/entries', { team_id: team_id })
  entries  = JSON.parse(response.body)
rescue => e
  @error = e.response
  false
end