diff --git a/geekyants/trelloservice/src/Services/ActionService.php b/geekyants/trelloservice/src/Services/ActionService.php index eaaaedf..6fe712f 100644 --- a/geekyants/trelloservice/src/Services/ActionService.php +++ b/geekyants/trelloservice/src/Services/ActionService.php @@ -73,7 +73,7 @@ function fetchCard($queryParams = []) return $this->verifyIdThenSendRequest($requestOptions); } - function fetchDisplayInfo($queryParams = []) + function fetchDisplay($queryParams = []) { $requestOptions = [ "id" => $this->id, @@ -192,148 +192,4 @@ function deleteComment($queryParams = []) ]; return $this->verifyIdThenSendRequest($requestOptions); } - - function fetchAdmins($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "actions", - $this->id, - "admins" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchSignupUrl($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "actions", - $this->id, - "signupUrl" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchMembers($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "actions", - $this->id, - "members" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function isOrganizationTransferableToEnterprise($idOrganization) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "actions", - $this->id, - "transferrable", - "organization", $idOrganization - ], - ]; - - return $this->verifyIdThenSendRequest($requestOptions); - } - - function deactivateMember($idMember, $queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "PUT", - "path" => [ - "actions", - $this->id, - "members", - $idMember, "deactivated" - ], - "queryParams" => $queryParams, - ]; - - if (!array_key_exists("value", $queryParams)) { - return ["error" => "value should be present in query params"]; - } - return $this->verifyIdThenSendRequest($requestOptions); - } - - function tranferOrganization($queryParams) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "PUT", - "path" => [ - "actions", - $this->id, - "organizations" - ], - "queryParams" => $queryParams - ]; - if (!array_key_exists("idOrganization", $queryParams)) { - return ["error" => "idOrganization should be present in query params"]; - } - return $this->verifyIdThenSendRequest($requestOptions); - } - - function makeAdmin($idMember) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "PUT", - "path" => [ - "actions", - $this->id, - "admins", - $idMember - ], - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function removeOrganization($idOrganization) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "DELETE", - "path" => [ - "actions", - $this->id, - "organizations", - $idOrganization - ], - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function removeAdmin($idMember) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "DELETE", - "path" => [ - "actions", - $this->id, - "admins", - $idMember - ], - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } } diff --git a/geekyants/trelloservice/src/Services/BoardService.php b/geekyants/trelloservice/src/Services/BoardService.php index 28d8413..ac565e5 100644 --- a/geekyants/trelloservice/src/Services/BoardService.php +++ b/geekyants/trelloservice/src/Services/BoardService.php @@ -258,7 +258,7 @@ function update($queryParams = []) return $this->verifyIdThenSendRequest($requestOptions); } - function addMemberByEmail($queryParams, $headers, $bodyParams) + function addMemberByEmail($queryParams, $headers, $bodyParams = []) { $requestOptions = [ "id" => $this->id, @@ -266,14 +266,15 @@ function addMemberByEmail($queryParams, $headers, $bodyParams) "path" => [ "boards", $this->id, + "members" ], "queryParams" => $queryParams, "headers" => $headers, "bodyParams" => $bodyParams ]; - + if (!array_key_exists("email", $queryParams)) { - return ["error" => "Email should be present in query params"]; + return ["error" => "email should be present in query params"]; } if (!array_key_exists("type", $headers)) { return ["error" => "member type should be present in headers"]; @@ -296,7 +297,7 @@ function addMemberById($idMember, $queryParams) ]; if (!array_key_exists("type", $queryParams)) { - return ["error" => "Type should be present in query params"]; + return ["error" => "type should be present in query params"]; } return $this->verifyIdThenSendRequest($requestOptions); @@ -316,7 +317,7 @@ function addMembershipById($queryParams) ]; if (!array_key_exists("type", $queryParams)) { - return ["error" => "Type should be present in query params"]; + return ["error" => "type should be present in query params"]; } if (!array_key_exists("idMembership", $queryParams)) { @@ -464,7 +465,7 @@ function create($queryParams) { if (!array_key_exists('name', $queryParams)) { - return ["error" => "Name must be provided to create a Board"]; + return ["error" => "name should be present in query params"]; } $requestOptions = [ @@ -482,7 +483,7 @@ function create($queryParams) return $res; } - function enablePlugin($queryParams) + function enablePlugin($queryParams = []) { $requestOptions = [ "id" => $this->id, @@ -517,12 +518,29 @@ function generateEmailKey() "requestMethod" => "POST", "path" => [ "boards", - $this->id, "EmailKey", + $this->id, "emailKey", "generate", ], ]; return $this->verifyIdThenSendRequest($requestOptions); } + + + function addTag($queryParams){ + $requestOptions = [ + "id" => $this->id, + "requestMethod" => "POST", + "path" => [ + "boards", + $this->id, "idTags", + ], + "queryParams" => $queryParams, + ]; + if (!array_key_exists("value", $queryParams)) { + return ["error" => "value should be present in query params"]; + } + + } function createLabel($queryParams) { @@ -585,7 +603,7 @@ function enablePowerUp($queryParams) "requestMethod" => "POST", "path" => [ "boards", - $this->id, "lists", + $this->id, "powerUps", ], "queryParams" => $queryParams, ]; diff --git a/geekyants/trelloservice/src/Services/CardService.php b/geekyants/trelloservice/src/Services/CardService.php index 5d3d433..f0ed574 100644 --- a/geekyants/trelloservice/src/Services/CardService.php +++ b/geekyants/trelloservice/src/Services/CardService.php @@ -29,7 +29,7 @@ function fetch($queryParams = []) return $this->verifyIdThenSendRequest($requestOptions); } - function fetchFeild($field, $queryParams = []) + function fetchField($field, $queryParams = []) { $requestOptions = [ "id" => $this->id, @@ -273,8 +273,8 @@ function update($queryParams = []) function updateComment($idAction, $queryParams = []) { - if (!array_key_exists("Text", $queryParams) || !$this->utils->isNotEmpty($queryParams["Text"])) { - return ["error" => "Text should be present in query params"]; + if (!array_key_exists("text", $queryParams)) { + return ["error" => "text should be present in query params"]; } $requestOptions = [ "id" => $this->id, @@ -343,7 +343,7 @@ function updateSticker($idSticker, $queryParams = []) function create($queryParams) { - if (!array_key_exists("idList", $queryParams) || !$this->utils->isNotEmpty($queryParams["idList"])) { + if (!array_key_exists("idList", $queryParams)) { return ["error" => "idList should be present in query params"]; } $requestOptions = [ @@ -363,15 +363,16 @@ function create($queryParams) function addComment($queryParams) { - if (!array_key_exists("text", $queryParams) || !$this->utils->isNotEmpty($queryParams["text"])) { + if (!array_key_exists("text", $queryParams)) { return ["error" => "text should be present in query params"]; } $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", $this->id, - "action", + "actions", "comments" ], "queryParams" => $queryParams, @@ -383,6 +384,7 @@ function addComment($queryParams) function addAttachment($queryParams = []) { $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -398,6 +400,7 @@ function addAttachment($queryParams = []) function addChecklist($queryParams = []) { $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -413,6 +416,7 @@ function addChecklist($queryParams = []) function addLabels($queryParams = []) { $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -428,6 +432,7 @@ function addLabels($queryParams = []) function addMembers($queryParams = []) { $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -439,12 +444,13 @@ function addMembers($queryParams = []) return $this->verifyIdThenSendRequest($requestOptions); } - function addNewLable($queryParams) + function addNewLabel($queryParams) { - if (!array_key_exists("label", $queryParams) || !$this->utils->isNotEmpty($queryParams["label"])) { - return ["error" => "label should be present in query params"]; + if (!array_key_exists("color", $queryParams)) { + return ["error" => "color should be present in query params"]; } $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -459,6 +465,7 @@ function addNewLable($queryParams) function markNotificationsRead($queryParams = []) { $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -476,6 +483,7 @@ function voteByMember($queryParams) return ["error" => "value should be present in query params"]; } $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -506,6 +514,7 @@ function addSticker($queryParams) } $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "cards", @@ -599,7 +608,7 @@ function removeLabel($idLabel) "path" => [ "cards", $this->id, - "idLabel", + "idLabels", $idLabel ] ]; diff --git a/geekyants/trelloservice/src/Services/CheckListService.php b/geekyants/trelloservice/src/Services/CheckListService.php index 24b278f..2515bd7 100644 --- a/geekyants/trelloservice/src/Services/CheckListService.php +++ b/geekyants/trelloservice/src/Services/CheckListService.php @@ -16,8 +16,8 @@ function __construct($id = null) function create($queryParams) { - if (!array_key_exists('idCard', $queryParams)) { - return ["error" => "The ID of the card that the checklist should be added to must be provided to create a checklist"]; + if (!array_key_exists("idCard", $queryParams)) { + return ["error" => "idCard should be present in query params"]; } $requestOptions = [ @@ -36,11 +36,12 @@ function create($queryParams) function createCheckItem($queryParams) { - if (!array_key_exists('name', $queryParams)) { - return ["error" => "name must be provided to create a check Item in query Params"]; + if (!array_key_exists("name", $queryParams)) { + return ["error" => "name should be present in query params"]; } $requestOptions = [ + "id" => $this->id, "requestMethod" => "POST", "path" => [ "checklists", @@ -50,7 +51,7 @@ function createCheckItem($queryParams) "queryParams" => $queryParams, ]; - $this->verifyIdThenSendRequest($requestOptions); + return $this->verifyIdThenSendRequest($requestOptions); } function fetch($queryParams = []) @@ -69,9 +70,6 @@ function fetch($queryParams = []) function fetchField($field, $queryParams = []) { - if ($field == null || trim($field) == "") { - return ["error" => "Field must be provided"]; - } $requestOptions = [ "id" => $this->id, "requestMethod" => "GET", @@ -101,7 +99,7 @@ function fetchBoard($queryParams = []) } - function fetchCard($queryParams = []) + function fetchCards($queryParams = []) { $requestOptions = [ "id" => $this->id, @@ -133,9 +131,6 @@ function fetchCheckItems($queryParams = []) function fetchCheckItem($idCheckItem, $queryParams = []) { - if ($idCheckItem == null || trim($idCheckItem) == "") { - return ["error" => "Id of checkItem must be provided"]; - } $requestOptions = [ "id" => $this->id, "requestMethod" => "GET", diff --git a/geekyants/trelloservice/src/Services/CustomFields.php b/geekyants/trelloservice/src/Services/CustomFields.php index ee4225a..023a1fa 100644 --- a/geekyants/trelloservice/src/Services/CustomFields.php +++ b/geekyants/trelloservice/src/Services/CustomFields.php @@ -19,20 +19,20 @@ function __construct($id = null) function create($bodyParams) { try { - if (!array_key_exists('idModel', $bodyParams)) { - throw new Exception("idModel i.e. The ID of the model for which the Custom Field is being defined. This should always be the ID of a board, must be provided to create a Custom Field"); + if (!array_key_exists("idModel", $bodyParams)) { + throw new Exception("idModel should be present in query params"); } if (!array_key_exists('modelType', $bodyParams)) { - throw new Exception("modelType i.e. The type of model that the Custom Field is being defined on. This should always be 'board', must be provided to create a Custom Field"); + throw new Exception("modelType should be present in query params"); } if (!array_key_exists('name', $bodyParams)) { - throw new Exception("The name of custom field must br provided to create a Custom Field"); + throw new Exception("name should be present in query params"); } if (!array_key_exists('type', $bodyParams)) { - throw new Exception("The type of custom field must br provided to create a Custom Field"); + throw new Exception("type should be present in query params"); } if (!array_key_exists('pos', $bodyParams)) { - throw new Exception("The pos of custom field must br provided to create a Custom Field"); + throw new Exception("pos should be present in query params"); } $requestOptions = [ @@ -52,7 +52,7 @@ function create($bodyParams) } } - function updateCustomField($bodyParams) + function updateCustomField($bodyParams = []) { $requestOptions = [ "requestMethod" => "PUT", @@ -100,7 +100,7 @@ function fetchOptions($queryParams = []) "id" => $this->id, "requestMethod" => "GET", "path" => [ - "checklists", + "customFields", $this->id, "options" ], @@ -111,14 +111,11 @@ function fetchOptions($queryParams = []) function fetchOption($idCustomFieldOption, $queryParams = []) { - if ($idCustomFieldOption == null || trim($idCustomFieldOption) == "") { - return ["error" => "The id of custom feild option must be provided"]; - } $requestOptions = [ "id" => $this->id, "requestMethod" => "GET", "path" => [ - "checklists", + "customFields", $this->id, "options", $idCustomFieldOption @@ -145,10 +142,6 @@ function addOption($bodyParams) function deleteOption($idCustomFieldOption) { - if (!$this->utils->isNotEmpty($idCustomFieldOption)) { - return ["error" => "Id of custom field option must be provided to delete"]; - } - $requestOptions = [ "id" => $this->id, "requestMethod" => "DELETE", @@ -204,135 +197,4 @@ function fetchAllFromBoard($idBoard, $queryParams = []) ]; return $this->sendRequest($requestOptions); } - - function fetchField($field, $queryParams = []) - { - if ($field == null || trim($field) == "") { - return ["error" => "Field must be provided"]; - } - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "checklists", - $this->id, - $field - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchBoard($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "checklists", - $this->id, - "board" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchCard($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "checklists", - $this->id, - "cards" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchCheckItems($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "checklists", - $this->id, - "checkItems" - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function fetchCheckItem($idCheckItem, $queryParams = []) - { - if ($idCheckItem == null || trim($idCheckItem) == "") { - return ["error" => "Id of checkItem must be provided"]; - } - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "GET", - "path" => [ - "checklists", - $this->id, - "checkItems", - $idCheckItem - ], - "queryParams" => $queryParams, - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } - - function update($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "PUT", - "path" => [ - "checklists", - $this->id - ], - "queryParams" => $queryParams, - ]; - - return $this->verifyIdThenSendRequest($requestOptions); - } - - function updateName($queryParams = []) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "PUT", - "path" => [ - "checklists", - $this->id, - "name" - ], - "queryParams" => $queryParams, - ]; - - if (!array_key_exists("value", $queryParams)) { - return ["error" => "value should be present in query params"]; - } - return $this->verifyIdThenSendRequest($requestOptions); - } - - function deleteCheckItem($idCheckItem) - { - $requestOptions = [ - "id" => $this->id, - "requestMethod" => "DELETE", - "path" => [ - "checklists", - $this->id, - "checkItems", - $idCheckItem - ], - ]; - return $this->verifyIdThenSendRequest($requestOptions); - } } diff --git a/geekyants/trelloservice/src/Services/EnterpriseService.php b/geekyants/trelloservice/src/Services/EnterpriseService.php index 1a1930b..55c10fc 100644 --- a/geekyants/trelloservice/src/Services/EnterpriseService.php +++ b/geekyants/trelloservice/src/Services/EnterpriseService.php @@ -120,7 +120,7 @@ function isOrganizationTransferableToEnterprise($idOrganization) return $this->verifyIdThenSendRequest($requestOptions); } - function deactivateMember($idMember, $queryParams = []) + function deactivateMember($idMember, $queryParams) { $requestOptions = [ "id" => $this->id, diff --git a/geekyants/trelloservice/src/Services/MemberService.php b/geekyants/trelloservice/src/Services/MemberService.php index bf58e7a..249fb3d 100644 --- a/geekyants/trelloservice/src/Services/MemberService.php +++ b/geekyants/trelloservice/src/Services/MemberService.php @@ -28,7 +28,7 @@ function fetch($queryParams = []) return $this->verifyIdThenSendRequest($requestOptions); } - function fetchFeild($field, $queryParams = []) + function fetchField($field, $queryParams = []) { $requestOptions = [ "id" => $this->id, diff --git a/geekyants/trelloservice/src/Services/OrganizationService.php b/geekyants/trelloservice/src/Services/OrganizationService.php index 66a026f..303b43c 100644 --- a/geekyants/trelloservice/src/Services/OrganizationService.php +++ b/geekyants/trelloservice/src/Services/OrganizationService.php @@ -289,7 +289,7 @@ function create($queryParams) return $res; } - function setLogo($queryParams) + function setLogo($queryParams =[]) { $requestOptions = [ @@ -326,7 +326,7 @@ function createTag($queryParams) return $this->verifyIdThenSendRequest($requestOptions); } - function export($queryParams) + function export($queryParams=[]) { $requestOptions = [ "id" => $this->id, diff --git a/geekyants/trelloservice/src/Services/TokenService.php b/geekyants/trelloservice/src/Services/TokenService.php index 267ea81..8fa981f 100644 --- a/geekyants/trelloservice/src/Services/TokenService.php +++ b/geekyants/trelloservice/src/Services/TokenService.php @@ -7,10 +7,14 @@ class TokenService extends Trello { - function __construct($value) + function __construct($value = null) { parent::__construct(); $this->id = $value; + if ($this->id == null) { + $this->id = $this->keyToken["token"]; + } + $this->utils = new Utils(); }