Class: NexboardApi
- Inherits:
-
Object
- Object
- NexboardApi
- Defined in:
- lib/nexboard_api.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://nexboard.nexenio.com/portal/api/public/'.freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#template_project_id ⇒ Object
readonly
Returns the value of attribute template_project_id.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #create_board_for_project(project_id:, title:, description:, template_id: nil) ⇒ Object
- #create_project(title:, description:) ⇒ Object
- #get_boards_for_project(project_id:) ⇒ Object
- #get_project_ids ⇒ Object
- #get_template_boards ⇒ Object
-
#initialize(api_key:, user_id:, template_project_id: nil, base_url: nil) ⇒ NexboardApi
constructor
A new instance of NexboardApi.
Constructor Details
#initialize(api_key:, user_id:, template_project_id: nil, base_url: nil) ⇒ NexboardApi
Returns a new instance of NexboardApi.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nexboard_api.rb', line 6 def initialize(api_key:, user_id:, template_project_id: nil, base_url: nil) @api_key = api_key @user_id = user_id @template_project_id = template_project_id unless template_project_id.nil? @base_url = if base_url.nil? DEFAULT_BASE_URL else base_url end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/nexboard_api.rb', line 4 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/nexboard_api.rb', line 4 def base_url @base_url end |
#template_project_id ⇒ Object (readonly)
Returns the value of attribute template_project_id.
4 5 6 |
# File 'lib/nexboard_api.rb', line 4 def template_project_id @template_project_id end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
4 5 6 |
# File 'lib/nexboard_api.rb', line 4 def user_id @user_id end |
Instance Method Details
#create_board_for_project(project_id:, title:, description:, template_id: nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/nexboard_api.rb', line 49 def create_board_for_project(project_id:, title:, description:, template_id: nil) data = { project_id: project_id, title: title, description: description, user_id: @user_id } data.merge!(template_id: template_id) unless template_id.nil? Restify.new(@base_url + 'boards') .post(data, token: @api_key) .value! end |
#create_project(title:, description:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nexboard_api.rb', line 25 def create_project(title:, description:) data = { title: title, description: description, user_id: @user_id } Restify.new(@base_url + 'projects') .post(data, token: @api_key) .value! end |
#get_boards_for_project(project_id:) ⇒ Object
37 38 39 40 41 |
# File 'lib/nexboard_api.rb', line 37 def get_boards_for_project(project_id:) Restify.new(@base_url + "projects/#{project_id}/boards") .get(token: @api_key, userId: @user_id) .value! end |
#get_project_ids ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/nexboard_api.rb', line 17 def get_project_ids projects = Restify.new(@base_url + 'projects') .get(userId: @user_id, token: @api_key) .value! projects.data.map{|project| project['project_id']} end |
#get_template_boards ⇒ Object
43 44 45 46 47 |
# File 'lib/nexboard_api.rb', line 43 def get_template_boards return [] if @template_project_id.nil? template_boards = get_boards_for_project(project_id: @template_project_id) template_boards.data.map{ |board| {board_id: board['boardId'], title: board['title'] } } end |