From 476456ceada4b151efe37a1d3a894fe27f2ba1ca Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 22 Feb 2018 23:17:32 -0300 Subject: [PATCH 01/26] feature/RC#32-teamwork-integration Add Task remote api - add dto for task_response for teamwork - add task_api for teamwork - Signed-off-by: Rachid Calazans --- .../remote/task/teamwork/dto/task_response.rb | 29 +++++++++++++++++++ .../remote/task/teamwork/task_api.rb | 27 +++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 lib/infrastructure/remote/task/teamwork/dto/task_response.rb create mode 100644 lib/infrastructure/remote/task/teamwork/task_api.rb diff --git a/lib/infrastructure/remote/task/teamwork/dto/task_response.rb b/lib/infrastructure/remote/task/teamwork/dto/task_response.rb new file mode 100644 index 0000000..4c1790f --- /dev/null +++ b/lib/infrastructure/remote/task/teamwork/dto/task_response.rb @@ -0,0 +1,29 @@ +module Infrastructure + module Remote + module Task + module Teamwork + module Dto + class TaskResponse + + attr_reader :id, :content, :description + + def initialize attributes = {} + check_attrs attributes + end + + private + + def check_attrs attrs + return if attrs.nil? + + attrs.each do |k, v| + instance_variable_set("@#{k}", v) if self.class.method_defined?(k) || self.private_methods.include?(k.to_sym) + end + end + end + + end + end + end + end +end diff --git a/lib/infrastructure/remote/task/teamwork/task_api.rb b/lib/infrastructure/remote/task/teamwork/task_api.rb new file mode 100644 index 0000000..89c9610 --- /dev/null +++ b/lib/infrastructure/remote/task/teamwork/task_api.rb @@ -0,0 +1,27 @@ +require 'http' +require_relative '../teamwork/dto/task_response.rb' + +module Infrastructure + module Remote + module Task + module Teamwork + class TaskApi + + def all_by(project_id:) + action = "https://rogalabs.teamwork.com/tasklists/#{project_id}/tasks.json" + r = JSON.parse(HTTP + .headers('Authorization': 'Basic dHdwX2FLRkZKUkk1eHB1eFFOdFJTQXJrb1Z5aDFRSG86') + .get(action).body)['todo-items'][0] + + Dto::TaskResponse.new(r) + end + + end + end + + end + end +end + +#api = Infrastructure::Remote::Task::Teamwork::TaskApi.new +#puts api.all_by(project_id: 551857).content From 4702c1d02d6ab88fe029acda4ea2cf942aa31870 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 22 Feb 2018 23:19:26 -0300 Subject: [PATCH 02/26] Update TaskApi Signed-off-by: Rachid Calazans --- lib/infrastructure/remote/task/teamwork/task_api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/infrastructure/remote/task/teamwork/task_api.rb b/lib/infrastructure/remote/task/teamwork/task_api.rb index 89c9610..e9d5608 100644 --- a/lib/infrastructure/remote/task/teamwork/task_api.rb +++ b/lib/infrastructure/remote/task/teamwork/task_api.rb @@ -10,7 +10,7 @@ class TaskApi def all_by(project_id:) action = "https://rogalabs.teamwork.com/tasklists/#{project_id}/tasks.json" r = JSON.parse(HTTP - .headers('Authorization': 'Basic dHdwX2FLRkZKUkk1eHB1eFFOdFJTQXJrb1Z5aDFRSG86') + .headers('Authorization': "Basic #{token}") .get(action).body)['todo-items'][0] Dto::TaskResponse.new(r) From d42d8756305be1cfebd8ea79b33defa4175309cd Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Mon, 5 Mar 2018 06:42:21 -0300 Subject: [PATCH 03/26] feature/RC#32-teamwork-integration Add Repo Injection on App module - add method to provide task repo Signed-off-by: Rachid Calazans --- app/injections/repositories.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 app/injections/repositories.rb diff --git a/app/injections/repositories.rb b/app/injections/repositories.rb new file mode 100644 index 0000000..a3579b6 --- /dev/null +++ b/app/injections/repositories.rb @@ -0,0 +1,27 @@ +module Injections + module Repositories + + def provide_task_repo(adapter:) + TASK_REPO[adapter.name].call(adapter) + end + + private + RequestApi = Struct(:headers, :body_params) + REQUESTS = { + teamwork: -> (adapter) { RequestApi.new(headers: {'Authorization': "Basic #{adapter.token}"}, body_params: {}) }, + trello: -> (adapter) { RequestApi.new(headers: {}, body_params: "key=#{adapter.key}&token=#{adapter.token}") } + } + + TASK_REPO = { + teamwork: -> (adapter) { ::Infrastructure::Remote::Task::Teamwork::TaskApi.new(request_api: REQUESTS[:teamwork].call(adapter)) }, + trello: -> (adapter) { ::Infrastructure::Remote::Task::Trello::TaskApi.new(request_api: REQUESTS[:trello].call(adapter)) } + } + end +end + +# trello token: 75bce39b08cc77d16bc652c24540665851fdc4763c7dda183570857ab8fe3abc +# trello key: 92eab9af2b2a2e2066940fb5796490df +# curl 'https://api.trello.com/1/members/me/boards?key=92eab9af2b2a2e2066940fb5796490df&token=75bce39b08cc77d16bc652c24540665851fdc4763c7dda183570857ab8fe3abc' +# +# curl 'https://api.trello.com/1/members/me/boards?key=92eab9af2b2a2e2066940fb5796490df&token=75bce39b08cc77d16bc652| 18 +# ▸ db/ |~' From 3cdf413ae66e18663716b16c87c2ca1ee18cb56d Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Mon, 5 Mar 2018 06:43:29 -0300 Subject: [PATCH 04/26] feature/RC#32-teamwork-integration Update TaskApi for Teamwork - add dependency injection with reqeust_api object Signed-off-by: Rachid Calazans --- lib/infrastructure/remote/task/teamwork/task_api.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/infrastructure/remote/task/teamwork/task_api.rb b/lib/infrastructure/remote/task/teamwork/task_api.rb index e9d5608..ae93dea 100644 --- a/lib/infrastructure/remote/task/teamwork/task_api.rb +++ b/lib/infrastructure/remote/task/teamwork/task_api.rb @@ -7,11 +7,16 @@ module Task module Teamwork class TaskApi + def initialize(request_api:) + @request_api = request_api + end + def all_by(project_id:) action = "https://rogalabs.teamwork.com/tasklists/#{project_id}/tasks.json" r = JSON.parse(HTTP - .headers('Authorization': "Basic #{token}") + .headers(@request_api.headers) .get(action).body)['todo-items'][0] + #.headers('Authorization': "Basic #{token}") Dto::TaskResponse.new(r) end From 34850a783827a12594f3597c1de2511b7418b998 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Mon, 5 Mar 2018 06:44:43 -0300 Subject: [PATCH 05/26] feature/RC#32-teamwork-integration Add Domain module with entity - add Task entity Signed-off-by: Rachid Calazans --- lib/domain/entity/task.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/domain/entity/task.rb diff --git a/lib/domain/entity/task.rb b/lib/domain/entity/task.rb new file mode 100644 index 0000000..78be9b8 --- /dev/null +++ b/lib/domain/entity/task.rb @@ -0,0 +1,7 @@ +module Domain + module Entity + class Task + + end + end +end From 346fd6a4746b184191c65e5ec9d3fb8c5fe53339 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:17:19 -0300 Subject: [PATCH 06/26] feature/RC#32 Add EntityBase on domain Signed-off-by: Rachid Calazans --- lib/domain/entity/base.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/domain/entity/base.rb diff --git a/lib/domain/entity/base.rb b/lib/domain/entity/base.rb new file mode 100644 index 0000000..097e210 --- /dev/null +++ b/lib/domain/entity/base.rb @@ -0,0 +1,19 @@ +module Domain + module Entity + module Base + + def initialize attributes = {} + check_attrs attributes + end + + private + def check_attrs attrs + return if attrs.nil? + + attrs.each do |k, v| + instance_variable_set("@#{k}", v) if self.class.method_defined?(k) || self.private_methods.include?(k.to_sym) + end + end + end + end +end From ec48a7f4acaa288c9cb60c9389cd90a4a38f73eb Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:17:41 -0300 Subject: [PATCH 07/26] feature/RC#32 Add ApiBase on infrastructure Signed-off-by: Rachid Calazans --- lib/infrastructure/remote/api_base.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/infrastructure/remote/api_base.rb diff --git a/lib/infrastructure/remote/api_base.rb b/lib/infrastructure/remote/api_base.rb new file mode 100644 index 0000000..b81433e --- /dev/null +++ b/lib/infrastructure/remote/api_base.rb @@ -0,0 +1,13 @@ +module Infrastructure + module Remote + module ApiBase + private + attr_reader :request_api + + public + def initialize(request_api:) + @request_api = request_api + end + end + end +end From c5d314d1c1acb946abae18cc9fe9b07921b23827 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:18:06 -0300 Subject: [PATCH 08/26] feature/RC#32 Add http gem Signed-off-by: Rachid Calazans --- Gemfile | 1 + Gemfile.lock | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Gemfile b/Gemfile index eb59055..db49cc8 100644 --- a/Gemfile +++ b/Gemfile @@ -64,3 +64,4 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'http' diff --git a/Gemfile.lock b/Gemfile.lock index 7964ba5..8096964 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,8 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) annotate (2.7.2) activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) @@ -70,6 +72,8 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.3) + domain_name (0.5.20170404) + unf (>= 0.0.5, < 1.0.0) dotenv (2.2.1) dotenv-rails (2.2.1) dotenv (= 2.2.1) @@ -84,6 +88,15 @@ GEM ffi (1.9.18) globalid (0.4.1) activesupport (>= 4.2.0) + http (3.0.0) + addressable (~> 2.3) + http-cookie (~> 1.0) + http-form_data (>= 2.0.0.pre.pre2, < 3) + http_parser.rb (~> 0.6.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + http-form_data (2.1.0) + http_parser.rb (0.6.0) i18n (0.9.1) concurrent-ruby (~> 1.0) jbuilder (2.7.0) @@ -117,6 +130,7 @@ GEM method_source (~> 0.9.0) pry-rails (0.3.6) pry (>= 0.10.4) + public_suffix (3.0.2) puma (3.10.0) pundit (1.1.0) activesupport (>= 3.0.0) @@ -208,6 +222,9 @@ GEM thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) warden (1.2.7) rack (>= 1.0) waterfall (1.2.0) @@ -233,6 +250,7 @@ DEPENDENCIES dotenv-rails factory_bot factory_bot_rails + http jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) From 67cb84158d375d2e091cd372d04d6bcae0281bf2 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:18:32 -0300 Subject: [PATCH 09/26] feature/RC#32 Update Task Entity attributes Signed-off-by: Rachid Calazans --- lib/domain/entity/task.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/domain/entity/task.rb b/lib/domain/entity/task.rb index 78be9b8..40a4c62 100644 --- a/lib/domain/entity/task.rb +++ b/lib/domain/entity/task.rb @@ -1,6 +1,9 @@ module Domain module Entity class Task + include ::Domain::Entity::Base + + attr_reader :id, :title, :description end end From 4c4a53192f9aac621f00e3d917078526fe4e63af Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:18:50 -0300 Subject: [PATCH 10/26] feature/RC#32 Update TaskResponse dto Signed-off-by: Rachid Calazans --- .../remote/task/teamwork/dto/task_response.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/infrastructure/remote/task/teamwork/dto/task_response.rb b/lib/infrastructure/remote/task/teamwork/dto/task_response.rb index 4c1790f..a2a97f7 100644 --- a/lib/infrastructure/remote/task/teamwork/dto/task_response.rb +++ b/lib/infrastructure/remote/task/teamwork/dto/task_response.rb @@ -4,24 +4,19 @@ module Task module Teamwork module Dto class TaskResponse + include ::Domain::Entity::Base attr_reader :id, :content, :description - def initialize attributes = {} - check_attrs attributes + def entity_attributes + { + id: id, + title: content, + description: description + } end - private - - def check_attrs attrs - return if attrs.nil? - - attrs.each do |k, v| - instance_variable_set("@#{k}", v) if self.class.method_defined?(k) || self.private_methods.include?(k.to_sym) - end - end end - end end end From e5f5500f047587607e965de01407b1c45e77fe80 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:19:09 -0300 Subject: [PATCH 11/26] feature/RC#32 Refactor TaskApi for Teamwork Signed-off-by: Rachid Calazans --- .../remote/task/teamwork/task_api.rb | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/infrastructure/remote/task/teamwork/task_api.rb b/lib/infrastructure/remote/task/teamwork/task_api.rb index ae93dea..3699e6b 100644 --- a/lib/infrastructure/remote/task/teamwork/task_api.rb +++ b/lib/infrastructure/remote/task/teamwork/task_api.rb @@ -1,32 +1,30 @@ -require 'http' -require_relative '../teamwork/dto/task_response.rb' - module Infrastructure module Remote module Task module Teamwork class TaskApi - - def initialize(request_api:) - @request_api = request_api - end + include ::Infrastructure::Remote::ApiBase def all_by(project_id:) - action = "https://rogalabs.teamwork.com/tasklists/#{project_id}/tasks.json" - r = JSON.parse(HTTP - .headers(@request_api.headers) - .get(action).body)['todo-items'][0] - #.headers('Authorization': "Basic #{token}") + action = "#{request_api.url_base}/tasklists/#{project_id}/tasks.json" + response = basic_auth.get(action) + json_body = JSON.parse(response.body) + + todo_items = json_body.fetch('todo-items', []) + + todo_items.map do |item| + dto = Dto::TaskResponse.new(item) + ::Domain::Entity::Task.new(dto.entity_attributes) + end - Dto::TaskResponse.new(r) end + private + def basic_auth + HTTP.basic_auth(user: request_api.user, pass: '') + end end end - end end end - -#api = Infrastructure::Remote::Task::Teamwork::TaskApi.new -#puts api.all_by(project_id: 551857).content From 97d0663a2c47b93a3aff2211166046ce4c6d9b05 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:19:25 -0300 Subject: [PATCH 12/26] feature/RC#32 Refactor InjectionsRepositories Signed-off-by: Rachid Calazans --- app/injections/repositories.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/injections/repositories.rb b/app/injections/repositories.rb index a3579b6..d0610b6 100644 --- a/app/injections/repositories.rb +++ b/app/injections/repositories.rb @@ -1,15 +1,25 @@ module Injections module Repositories + def build_teamwork_adapter(url_base:, token:) + Adapter.new(:teamwork, url_base, token, '') + end + + def build_trello_adapter(url_base:, token:, key:) + Adapter.new(:teamwork, url_base, token, key) + end + def provide_task_repo(adapter:) TASK_REPO[adapter.name].call(adapter) end private - RequestApi = Struct(:headers, :body_params) + Adapter = Struct.new(:name, :url_base, :token, :key) + + RequestApi = Struct.new(:url_base, :headers, :body_params, :user) REQUESTS = { - teamwork: -> (adapter) { RequestApi.new(headers: {'Authorization': "Basic #{adapter.token}"}, body_params: {}) }, - trello: -> (adapter) { RequestApi.new(headers: {}, body_params: "key=#{adapter.key}&token=#{adapter.token}") } + teamwork: -> (adapter) { RequestApi.new(adapter.url_base, {}, {}, adapter.token) }, + trello: -> (adapter) { RequestApi.new(adapter.url_base, {}, "key=#{adapter.key}&token=#{adapter.token}") } } TASK_REPO = { @@ -18,10 +28,3 @@ def provide_task_repo(adapter:) } end end - -# trello token: 75bce39b08cc77d16bc652c24540665851fdc4763c7dda183570857ab8fe3abc -# trello key: 92eab9af2b2a2e2066940fb5796490df -# curl 'https://api.trello.com/1/members/me/boards?key=92eab9af2b2a2e2066940fb5796490df&token=75bce39b08cc77d16bc652c24540665851fdc4763c7dda183570857ab8fe3abc' -# -# curl 'https://api.trello.com/1/members/me/boards?key=92eab9af2b2a2e2066940fb5796490df&token=75bce39b08cc77d16bc652| 18 -# ▸ db/ |~' From 68e3cd23d527f42d97bea164bc3d974de7c42553 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:29:51 -0300 Subject: [PATCH 13/26] feature/RC#32 Add Project Entity Signed-off-by: Rachid Calazans --- lib/domain/entity/project.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/domain/entity/project.rb diff --git a/lib/domain/entity/project.rb b/lib/domain/entity/project.rb new file mode 100644 index 0000000..a3db1c1 --- /dev/null +++ b/lib/domain/entity/project.rb @@ -0,0 +1,11 @@ +module Domain + module Entity + class Project + include ::Domain::Entity::Base + + attr_reader :id, :name, :description + + end + end +end + From 80d31775360885cd14f21d8c444bd6678d88f489 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:30:09 -0300 Subject: [PATCH 14/26] feature/RC#32 Add ProjectApi and Response Signed-off-by: Rachid Calazans --- .../project/teamwork/dto/project_response.rb | 25 ++++++++++++++++ .../remote/project/teamwork/project_api.rb | 30 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 lib/infrastructure/remote/project/teamwork/dto/project_response.rb create mode 100644 lib/infrastructure/remote/project/teamwork/project_api.rb diff --git a/lib/infrastructure/remote/project/teamwork/dto/project_response.rb b/lib/infrastructure/remote/project/teamwork/dto/project_response.rb new file mode 100644 index 0000000..8389203 --- /dev/null +++ b/lib/infrastructure/remote/project/teamwork/dto/project_response.rb @@ -0,0 +1,25 @@ +module Infrastructure + module Remote + module Project + module Teamwork + module Dto + class ProjectResponse + include ::Domain::Entity::Base + + attr_reader :id, :name, :description + + def entity_attributes + { + id: id, + name: name, + description: description + } + end + + end + end + end + end + end +end + diff --git a/lib/infrastructure/remote/project/teamwork/project_api.rb b/lib/infrastructure/remote/project/teamwork/project_api.rb new file mode 100644 index 0000000..4e60e41 --- /dev/null +++ b/lib/infrastructure/remote/project/teamwork/project_api.rb @@ -0,0 +1,30 @@ +module Infrastructure + module Remote + module Project + module Teamwork + class ProjectApi + include ::Infrastructure::Remote::ApiBase + + def all + action = "#{request_api.url_base}/projects.json" + response = basic_auth.get(action) + json_body = JSON.parse(response.body) + + projects = json_body.fetch('projects', []) + + projects.map do |item| + dto = Dto::ProjectResponse.new(item) + ::Domain::Entity::Project.new(dto.entity_attributes) + end + + end + + private + def basic_auth + HTTP.basic_auth(user: request_api.user, pass: '') + end + end + end + end + end +end From d7ea3fb6ac6fafae1410ee7f71d4e1f65f6dab58 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:30:27 -0300 Subject: [PATCH 15/26] feature/RC#32 Add new provide for Project repository Signed-off-by: Rachid Calazans --- app/injections/repositories.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/injections/repositories.rb b/app/injections/repositories.rb index d0610b6..d477c75 100644 --- a/app/injections/repositories.rb +++ b/app/injections/repositories.rb @@ -9,6 +9,11 @@ def build_trello_adapter(url_base:, token:, key:) Adapter.new(:teamwork, url_base, token, key) end + + def provide_project_repo(adapter:) + PROJECT_REPO[adapter.name].call(adapter) + end + def provide_task_repo(adapter:) TASK_REPO[adapter.name].call(adapter) end @@ -22,6 +27,10 @@ def provide_task_repo(adapter:) trello: -> (adapter) { RequestApi.new(adapter.url_base, {}, "key=#{adapter.key}&token=#{adapter.token}") } } + PROJECT_REPO = { + teamwork: -> (adapter) { ::Infrastructure::Remote::Project::Teamwork::ProjectApi.new(request_api: REQUESTS[:teamwork].call(adapter)) } + } + TASK_REPO = { teamwork: -> (adapter) { ::Infrastructure::Remote::Task::Teamwork::TaskApi.new(request_api: REQUESTS[:teamwork].call(adapter)) }, trello: -> (adapter) { ::Infrastructure::Remote::Task::Trello::TaskApi.new(request_api: REQUESTS[:trello].call(adapter)) } From f03dcba80feb6a64bcf12a9224e0616bbaea7adf Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:37:04 -0300 Subject: [PATCH 16/26] feature/RC#32 Add List Entity Signed-off-by: Rachid Calazans --- lib/domain/entity/list.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/domain/entity/list.rb diff --git a/lib/domain/entity/list.rb b/lib/domain/entity/list.rb new file mode 100644 index 0000000..e85a1f8 --- /dev/null +++ b/lib/domain/entity/list.rb @@ -0,0 +1,12 @@ +module Domain + module Entity + class List + include ::Domain::Entity::Base + + attr_reader :id, :name, :description + + end + end +end + + From 0b5112b08464066292fdcecddae4275890692f4e Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:37:21 -0300 Subject: [PATCH 17/26] feature/RC#32 Add ListApi and ListResponse Signed-off-by: Rachid Calazans --- .../remote/list/teamwork/dto/list_response.rb | 26 ++++++++++++++++ .../remote/list/teamwork/list_api.rb | 31 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 lib/infrastructure/remote/list/teamwork/dto/list_response.rb create mode 100644 lib/infrastructure/remote/list/teamwork/list_api.rb diff --git a/lib/infrastructure/remote/list/teamwork/dto/list_response.rb b/lib/infrastructure/remote/list/teamwork/dto/list_response.rb new file mode 100644 index 0000000..9b1583b --- /dev/null +++ b/lib/infrastructure/remote/list/teamwork/dto/list_response.rb @@ -0,0 +1,26 @@ +module Infrastructure + module Remote + module List + module Teamwork + module Dto + class ListResponse + include ::Domain::Entity::Base + + attr_reader :id, :name, :description + + def entity_attributes + { + id: id, + name: name, + description: description + } + end + + end + end + end + end + end +end + + diff --git a/lib/infrastructure/remote/list/teamwork/list_api.rb b/lib/infrastructure/remote/list/teamwork/list_api.rb new file mode 100644 index 0000000..e87cb93 --- /dev/null +++ b/lib/infrastructure/remote/list/teamwork/list_api.rb @@ -0,0 +1,31 @@ +module Infrastructure + module Remote + module List + module Teamwork + class ListApi + include ::Infrastructure::Remote::ApiBase + + def all_by(project_id:) + action = "#{request_api.url_base}/projects/#{project_id}/tasklists.json" + response = basic_auth.get(action) + json_body = JSON.parse(response.body) + + tasklists = json_body.fetch('tasklists', []) + + tasklists.map do |item| + dto = Dto::ListResponse.new(item) + ::Domain::Entity::List.new(dto.entity_attributes) + end + + end + + private + def basic_auth + HTTP.basic_auth(user: request_api.user, pass: '') + end + end + end + end + end +end + From 3290eb6040957353a6d7277126d107820494479d Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:37:32 -0300 Subject: [PATCH 18/26] feature/RC#32 Add new provide for Listt repository Signed-off-by: Rachid Calazans --- app/injections/repositories.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/injections/repositories.rb b/app/injections/repositories.rb index d477c75..4eff56e 100644 --- a/app/injections/repositories.rb +++ b/app/injections/repositories.rb @@ -14,6 +14,10 @@ def provide_project_repo(adapter:) PROJECT_REPO[adapter.name].call(adapter) end + def provide_list_repo(adapter:) + LIST_REPO[adapter.name].call(adapter) + end + def provide_task_repo(adapter:) TASK_REPO[adapter.name].call(adapter) end @@ -31,6 +35,10 @@ def provide_task_repo(adapter:) teamwork: -> (adapter) { ::Infrastructure::Remote::Project::Teamwork::ProjectApi.new(request_api: REQUESTS[:teamwork].call(adapter)) } } + LIST_REPO = { + teamwork: -> (adapter) { ::Infrastructure::Remote::List::Teamwork::ListApi.new(request_api: REQUESTS[:teamwork].call(adapter)) } + } + TASK_REPO = { teamwork: -> (adapter) { ::Infrastructure::Remote::Task::Teamwork::TaskApi.new(request_api: REQUESTS[:teamwork].call(adapter)) }, trello: -> (adapter) { ::Infrastructure::Remote::Task::Trello::TaskApi.new(request_api: REQUESTS[:trello].call(adapter)) } From 677539025280d1fe41d53afaa102431cb7b2af8c Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:46:43 -0300 Subject: [PATCH 19/26] feature/RC#32 Update Injection Repositories Signed-off-by: Rachid Calazans --- app/injections/repositories.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/injections/repositories.rb b/app/injections/repositories.rb index 4eff56e..e84fc47 100644 --- a/app/injections/repositories.rb +++ b/app/injections/repositories.rb @@ -6,7 +6,7 @@ def build_teamwork_adapter(url_base:, token:) end def build_trello_adapter(url_base:, token:, key:) - Adapter.new(:teamwork, url_base, token, key) + Adapter.new(:trello, url_base, token, key) end @@ -40,8 +40,7 @@ def provide_task_repo(adapter:) } TASK_REPO = { - teamwork: -> (adapter) { ::Infrastructure::Remote::Task::Teamwork::TaskApi.new(request_api: REQUESTS[:teamwork].call(adapter)) }, - trello: -> (adapter) { ::Infrastructure::Remote::Task::Trello::TaskApi.new(request_api: REQUESTS[:trello].call(adapter)) } + teamwork: -> (adapter) { ::Infrastructure::Remote::Task::Teamwork::TaskApi.new(request_api: REQUESTS[:teamwork].call(adapter)) } } end end From 1fe43beda8141f903e0ec9dc2ccfc7abc3142e8d Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 21:47:04 -0300 Subject: [PATCH 20/26] feature/RC#32 Add method on TaskApi Signed-off-by: Rachid Calazans --- .../remote/task/teamwork/task_api.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/infrastructure/remote/task/teamwork/task_api.rb b/lib/infrastructure/remote/task/teamwork/task_api.rb index 3699e6b..21d4fcf 100644 --- a/lib/infrastructure/remote/task/teamwork/task_api.rb +++ b/lib/infrastructure/remote/task/teamwork/task_api.rb @@ -5,8 +5,8 @@ module Teamwork class TaskApi include ::Infrastructure::Remote::ApiBase - def all_by(project_id:) - action = "#{request_api.url_base}/tasklists/#{project_id}/tasks.json" + def all_by_project(project_id:) + action = "#{request_api.url_base}/projects/#{project_id}/tasks.json" response = basic_auth.get(action) json_body = JSON.parse(response.body) @@ -16,7 +16,19 @@ def all_by(project_id:) dto = Dto::TaskResponse.new(item) ::Domain::Entity::Task.new(dto.entity_attributes) end + end + + def all_by_list(list_id:) + action = "#{request_api.url_base}/tasklists/#{list_id}/tasks.json" + response = basic_auth.get(action) + json_body = JSON.parse(response.body) + + todo_items = json_body.fetch('todo-items', []) + todo_items.map do |item| + dto = Dto::TaskResponse.new(item) + ::Domain::Entity::Task.new(dto.entity_attributes) + end end private From 806c2c005eaff320c44540803031491f8d43d357 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 22:32:05 -0300 Subject: [PATCH 21/26] feature/RC#32 Update Gemfile.lock - update to solve the action cable problem for old version from Rails Signed-off-by: Rachid Calazans --- Gemfile.lock | 128 +++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8096964..6c4ff63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,39 +1,39 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.1.4) - actionpack (= 5.1.4) + actioncable (5.1.5) + actionpack (= 5.1.5) nio4r (~> 2.0) websocket-driver (~> 0.6.1) - actionmailer (5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) + actionmailer (5.1.5) + actionpack (= 5.1.5) + actionview (= 5.1.5) + activejob (= 5.1.5) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.4) - actionview (= 5.1.4) - activesupport (= 5.1.4) + actionpack (5.1.5) + actionview (= 5.1.5) + activesupport (= 5.1.5) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.1.4) - activesupport (= 5.1.4) + actionview (5.1.5) + activesupport (= 5.1.5) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.4) - activesupport (= 5.1.4) + activejob (5.1.5) + activesupport (= 5.1.5) globalid (>= 0.3.6) - activemodel (5.1.4) - activesupport (= 5.1.4) - activerecord (5.1.4) - activemodel (= 5.1.4) - activesupport (= 5.1.4) + activemodel (5.1.5) + activesupport (= 5.1.5) + activerecord (5.1.5) + activemodel (= 5.1.5) + activesupport (= 5.1.5) arel (~> 8.0) - activesupport (5.1.4) + activesupport (5.1.5) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) @@ -44,16 +44,16 @@ GEM activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) arel (8.0.0) - autoprefixer-rails (7.1.6) + autoprefixer-rails (8.1.0.1) execjs bcrypt (3.1.11) bindex (0.5.0) - bootstrap (4.0.0.beta2.1) + bootstrap (4.0.0) autoprefixer-rails (>= 6.0.3) - popper_js (>= 1.12.3, < 2) + popper_js (>= 1.12.9, < 2) sass (>= 3.5.2) builder (3.2.3) - byebug (9.1.0) + byebug (10.0.0) coderay (1.1.2) coffee-rails (4.2.2) coffee-script (>= 2.2.0) @@ -63,7 +63,7 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.0.5) - crass (1.0.2) + crass (1.0.3) database_cleaner (1.6.2) devise (4.4.1) bcrypt (~> 3.0) @@ -78,14 +78,14 @@ GEM dotenv-rails (2.2.1) dotenv (= 2.2.1) railties (>= 3.2, < 5.2) - erubi (1.7.0) + erubi (1.7.1) execjs (2.7.0) factory_bot (4.8.2) activesupport (>= 3.0.0) factory_bot_rails (4.8.2) factory_bot (~> 4.8.2) railties (>= 3.0.0) - ffi (1.9.18) + ffi (1.9.23) globalid (0.4.1) activesupport (>= 4.2.0) http (3.0.0) @@ -97,7 +97,7 @@ GEM domain_name (~> 0.5) http-form_data (2.1.0) http_parser.rb (0.6.0) - i18n (0.9.1) + i18n (0.9.5) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) @@ -109,7 +109,7 @@ GEM listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - loofah (2.1.1) + loofah (2.2.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.0) @@ -117,37 +117,37 @@ GEM method_source (0.9.0) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.10.3) - multi_json (1.12.2) - nio4r (2.1.0) - nokogiri (1.8.1) + minitest (5.11.3) + multi_json (1.13.1) + nio4r (2.2.0) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) - pg (0.21.0) - popper_js (1.12.5) - pry (0.11.2) + pg (1.0.0) + popper_js (1.12.9) + pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) pry-rails (0.3.6) pry (>= 0.10.4) public_suffix (3.0.2) - puma (3.10.0) + puma (3.11.3) pundit (1.1.0) activesupport (>= 3.0.0) - rack (2.0.3) - rack-test (0.7.0) + rack (2.0.4) + rack-test (0.8.3) rack (>= 1.0, < 3) - rails (5.1.4) - actioncable (= 5.1.4) - actionmailer (= 5.1.4) - actionpack (= 5.1.4) - actionview (= 5.1.4) - activejob (= 5.1.4) - activemodel (= 5.1.4) - activerecord (= 5.1.4) - activesupport (= 5.1.4) + rails (5.1.5) + actioncable (= 5.1.5) + actionmailer (= 5.1.5) + actionpack (= 5.1.5) + actionview (= 5.1.5) + activejob (= 5.1.5) + activemodel (= 5.1.5) + activerecord (= 5.1.5) + activesupport (= 5.1.5) bundler (>= 1.3.0) - railties (= 5.1.4) + railties (= 5.1.5) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) @@ -158,21 +158,21 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (5.1.4) - actionpack (= 5.1.4) - activesupport (= 5.1.4) + railties (5.1.5) + actionpack (= 5.1.5) + activesupport (= 5.1.5) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.2.1) - rb-fsevent (0.10.2) + rake (12.3.0) + rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.3) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) - rspec-core (3.7.0) + rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) @@ -180,7 +180,7 @@ GEM rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) - rspec-rails (3.7.1) + rspec-rails (3.7.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -188,13 +188,13 @@ GEM rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) - rspec-support (3.7.0) - sass (3.5.3) + rspec-support (3.7.1) + sass (3.5.5) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.6) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -215,12 +215,12 @@ GEM thor (0.20.0) thread_safe (0.3.6) tilt (2.0.8) - turbolinks (5.0.1) - turbolinks-source (~> 5) - turbolinks-source (5.0.3) - tzinfo (1.2.4) + turbolinks (5.1.0) + turbolinks-source (~> 5.1) + turbolinks-source (5.1.0) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.1.6) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext @@ -258,7 +258,7 @@ DEPENDENCIES pry-rails puma (~> 3.0) pundit - rails (~> 5.1) + rails (~> 5.1.5) rails-controller-testing redis (= 3.3.3) rspec-rails (~> 3.5) From 8c97b3e1f89da4951dbf5988e33594f217663fe0 Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Thu, 8 Mar 2018 22:34:29 -0300 Subject: [PATCH 22/26] feature/RC#32 Update REAMD with new Rails version Signed-off-by: Rachid Calazans --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8dc96ec..2c787cb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Dependencies * Ruby version 2.5.0 -* Rails version 5.1 +* Rails version ~> 5.1 * Postgres >= 9.5 You must have redis installed and running on the default port:6379 (or configure it in config/redis/cable.yml). From 3a2aea42d26d75bd899a3349e041c521a8eacd8b Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Sun, 11 Mar 2018 16:27:19 -0300 Subject: [PATCH 23/26] feature/RC#32-teamwork-integration Update ruby version on Travis config - change to version 2.5.0 Signed-off-by: Rachid Calazans --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cf32bfb..abe6b57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.4.2 + - 2.5.0 env: - DB =pgsql services: From 9769a48eec7238d52888fc158f1e7ad75627541a Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Sun, 11 Mar 2018 16:32:33 -0300 Subject: [PATCH 24/26] feature/RC#32-teamwork-integration Update travis config - replace bundle install to bundle update command Signed-off-by: Rachid Calazans --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index abe6b57..be57be3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: services: - postgresql before_script: - - bundle install + - bundle update - RAILS_ENV=test bundle exec rake db:create - RAILS_ENV=test bundle exec rake db:migrate dist: trusty From 959ee0ce799893c6d211164abd59be73e77b572d Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Sun, 11 Mar 2018 16:34:29 -0300 Subject: [PATCH 25/26] feature/RC#32-teamwork-integration Update travis config - replace command bundle update to bundle install Signed-off-by: Rachid Calazans --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index be57be3..abe6b57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: services: - postgresql before_script: - - bundle update + - bundle install - RAILS_ENV=test bundle exec rake db:create - RAILS_ENV=test bundle exec rake db:migrate dist: trusty From 0e9c46fe05d68f8e2248e81fda2f3f7efca85b1a Mon Sep 17 00:00:00 2001 From: Rachid Calazans Date: Fri, 16 Mar 2018 12:37:25 -0300 Subject: [PATCH 26/26] feature/RC#32-teamwork-integration Update rails version on Gemfile.lock - change to 5.1 Signed-off-by: Rachid Calazans --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6c4ff63..bafab74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -258,7 +258,7 @@ DEPENDENCIES pry-rails puma (~> 3.0) pundit - rails (~> 5.1.5) + rails (~> 5.1) rails-controller-testing redis (= 3.3.3) rspec-rails (~> 3.5)