class Dude::ProjectManagement::Trello::FetchCurrentTask

Attributes

client[R]
id[R]

Public Class Methods

new(client, id:) click to toggle source
# File lib/dude/project_management/trello/fetch_current_task.rb, line 7
def initialize(client, id:)
  @client = client
  @id = id
end

Public Instance Methods

call() click to toggle source
# File lib/dude/project_management/trello/fetch_current_task.rb, line 12
def call
  response = client.get("/1/boards/#{Dude::SETTINGS.dig(:jira, :board_id)}/cards/#{id}")
  create_issue JSON.parse(response.body)
end

Private Instance Methods

create_issue(issue) click to toggle source
# File lib/dude/project_management/trello/fetch_current_task.rb, line 21
def create_issue(issue)
  Entities::Issue.new(
    id: issue['idShort'],
    title: issue['name'],
    description: issue['desc'],
    status: Dude::SETTINGS[:in_progress_list_name], # OMG, let's fix this later
    assignee: members(issue),
    url: issue['shortUrl']
  )
end
members(issue) click to toggle source
# File lib/dude/project_management/trello/fetch_current_task.rb, line 32
def members(issue)
  people = issue['idMembers'].map do |person|
    JSON.parse(client.get("/1/members/#{person}", fields: 'fullName').body)['fullName']
  end
  people.empty? ? nil : people.join(', ')
end