Module: SambaApi::Categories

Included in:
Init
Defined in:
lib/samba_api/categories.rb

Overview

category class

Instance Method Summary collapse

Instance Method Details

#all_categories(project_id) ⇒ Object



7
8
9
10
11
# File 'lib/samba_api/categories.rb', line 7

def all_categories(project_id)
  endpoint_url = base_url + 'categories' + access_token + '&pid=' + project_id.to_s
  response = self.class.get(endpoint_url)
  JSON.parse(response.body)
end

#category(category_id, project_id) ⇒ Object



13
14
15
16
17
# File 'lib/samba_api/categories.rb', line 13

def category(category_id, project_id)
  endpoint_url = category_base_url + category_id.to_s + access_token + '&pid=' + project_id.to_s
  response = self.class.get(endpoint_url)
  JSON.parse(response.body)
end

#create_category(project_id, options = {}) ⇒ Object



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

def create_category(project_id, options = {})
  endpoint_url = category_base_url + access_token + '&pid=' + project_id.to_s
  body = { 'name' => options[:name], 'parent' => options[:parent], 'genre' => options[:genre], 'connectedAccounts' => options[:connectedAccounts], 'children' => options[:children]}.to_json
  response = self.class.post(endpoint_url, body: body, headers: header_request)
  JSON.parse response.body, symbolize_names: true
end

#delete_category(category_id, project_id) ⇒ Object



34
35
36
37
38
# File 'lib/samba_api/categories.rb', line 34

def delete_category(category_id, project_id)
  endpoint_url = category_base_url + category_id.to_s + access_token + '&pid=' + project_id.to_s
  response = self.class.delete(endpoint_url, header_request)
  JSON.parse(response.body)
end

#update_category(category_id, project_id, options = {}) ⇒ Object

TODO incorrect formating body to send request



27
28
29
30
31
32
# File 'lib/samba_api/categories.rb', line 27

def update_category(category_id, project_id, options = {})
  # endpoint_url = category_base_url + category_id.to_s + access_token + '&pid=' + project_id.to_s
  # body = { "name" => options[:name], "parent" => options[:parent], "genre" => options[:genre], "connectedAccounts" => options[:connectedAccounts], "children" => options[:children]}.to_json
  # response = self.class.put(endpoint_url, body: body.to_json, headers: header_request)
  # JSON.parse response.body, symbolize_names: true
end