Class: Itfollows::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, token) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/itfollowsclient.rb', line 7

def initialize(email, token)
  @email = email
  @token = token
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

#list(name) ⇒ Object



12
13
14
15
16
# File 'lib/itfollowsclient.rb', line 12

def list(name)
  uri = uri(name)
  response = get(name, uri, email, token)
  JSON.parse(response.body)
end

#new(name, payload) ⇒ Object



26
27
28
29
30
31
# File 'lib/itfollowsclient.rb', line 26

def new(name, payload)
  payload = {'line_entry' => {"data" => payload}}
  uri = uri(name)
  response = post(name, payload, uri, email, token)
  JSON.parse(response.body)
end

#new_followup(name, description, percentage, tasks, id) ⇒ Object



19
20
21
22
23
24
# File 'lib/itfollowsclient.rb', line 19

def new_followup(name, description, percentage, tasks, id)
  uri = uri_for_update(name, id)
  payload = {"line_entry"=>{"followups_attributes"=>{"0"=>{"description"=> description, "percentage"=> percentage, "tasks"=>tasks}}}, "id"=> id}
  response = patch(name, payload, uri, email, token)
  JSON.parse(response.body)
end

#show(name, id) ⇒ Object



33
34
35
36
37
# File 'lib/itfollowsclient.rb', line 33

def show(name, id)
  uri = uri_for_show(name, id)
  response = get(name, uri, email, token)
  JSON.parse(response.body)
end