Skip to content

Commit

Permalink
Merge pull request #65 from Asana/rossgrambo-openapi-conversion
Browse files Browse the repository at this point in the history
Conversion to openapi spec
  • Loading branch information
rossgrambo-zz authored Feb 12, 2020
2 parents f6aa3cf + eca51cf commit 22bec8e
Show file tree
Hide file tree
Showing 53 changed files with 3,216 additions and 1,416 deletions.
5 changes: 5 additions & 0 deletions .swagger-codegen-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Swagger Codegen Ignore

test/*
docs/*
src/Asana/Client.php
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you use [Composer](https://getcomposer.org/) to manage dependencies you can i
```json
{
"require": {
"asana/asana": "^0.8.0"
"asana/asana": "^0.10.0"
}
}
```
Expand Down Expand Up @@ -108,12 +108,12 @@ The client's methods are divided into several resources: `attachments`, `events`
Methods that return a single object return that object directly:
```php
<?php
$me = $client->users->me();
$me = $client->users->getUser("me");
echo "Hello " . $me->name;

$workspaceId = $me->workspaces[0]->id;
$project = $client->projects->createInWorkspace($workspaceId, array('name' => 'new project'));
echo "Created project with id: " . $project->id;
$workspaceGid = $me->workspaces[0]->gid;
$project = $client->projects->createProjectForWorkspace($workspaceGid, array('name' => 'new project'));
echo "Created project with gid: " . $project->gid;
```

Methods that return multiple items (e.x. `findAll`) return an items iterator by default. See the "Collections" section
Expand Down Expand Up @@ -182,7 +182,7 @@ If you would rather suppress these warnings, you can set
By default, methods that return a collection of objects return an item iterator:
```php
<?php
$workspaces = $client->workspaces->findAll();
$workspaces = $client->workspaces->getWorkspaces();
foreach ($workspaces as $workspace) {
var_dump($workspace);
}
Expand All @@ -197,7 +197,7 @@ You can also use the raw API to fetch a page at a time:
<?php
$offset = null;
while (true) {
$page = $client->workspaces->findAll(null, array('offset' => $offset, 'iterator_type' => null, 'page_size' => 2));
$page = $client->workspaces->getWorkspaces(null, array('offset' => $offset, 'iterator_type' => null, 'page_size' => 2));
var_dump($page);
if (isset($page->next_page)) {
$offset = $page->next_page->offset;
Expand All @@ -219,8 +219,8 @@ To develop:

### Code generation

The specific Asana resource classes (`Tag`, `Workspace`, `Task`, etc) are
generated code, hence they shouldn't be modified by hand. See the [asana-api-meta](https://github.com/Asana/asana-api-meta) repo for details.
The specific Asana resource classes in the Gen folder (`Tag`, `Workspace`, `Task`, etc) are
generated code, hence they shouldn't be modified by hand.

### Deployment

Expand All @@ -240,3 +240,5 @@ The rest is automatically done by Composer / Packagist. Visit [the asana package

[packagist-url]: https://packagist.org/packages/asana/asana
[packagist-image]: https://img.shields.io/packagist/v/asana/asana.svg?style=flat-square

[asana-docs]: https://developers.asana.com/docs
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.1
0.10.0
28 changes: 28 additions & 0 deletions src/Asana/Resources/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,32 @@ public function createOnTask($task, $content, $filename, $contentType, $options
$options['files'] = array('file' => array($content, $filename, $contentType));
return $this->client->request('POST', $path, $options);
}

/**
* Returns the full record for a single attachment.
*
* @deprecated replace with getAttachment
*
* @param attachment Globally unique identifier for the attachment.
* @return response
*/
public function findById($attachment, $params = array(), $options = array())
{
$path = sprintf("/attachments/%s", $attachment);
return $this->client->get($path, $params, $options);
}

/**
* Returns the compact records for all attachments on the task.
*
* @deprecated replace with getAttachmentsForTask
*
* @param task Globally unique identifier for the task.
* @return response
*/
public function findByTask($task, $params = array(), $options = array())
{
$path = sprintf("/tasks/%s/attachments", $task);
return $this->client->getCollection($path, $params, $options);
}
}
9 changes: 9 additions & 0 deletions src/Asana/Resources/BatchAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Asana\Resources;

use Asana\Resources\Gen\BatchAPIBase;

class BatchAPI extends BatchAPIBase
{
}
27 changes: 27 additions & 0 deletions src/Asana/Resources/CustomFieldSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,31 @@

class CustomFieldSettings extends CustomFieldSettingsBase
{
/**
* Returns a list of all of the custom fields settings on a project.
*
* @deprecated replace with getCustomFieldSettingsForProject
*
* @param project The ID of the project for which to list custom field settings
* @return response
*/
public function findByProject($project, $params = array(), $options = array())
{
$path = sprintf("/projects/%s/custom_field_settings", $project);
return $this->client->getCollection($path, $params, $options);
}

/**
* Returns a list of all of the custom fields settings on a portfolio.
*
* @deprecated replace with getCustomFieldSettingsForPortfolio
*
* @param portfolio The ID of the portfolio for which to list custom field settings
* @return response
*/
public function findByPortfolio($portfolio, $params = array(), $options = array())
{
$path = sprintf("/portfolios/%s/custom_field_settings", $portfolio);
return $this->client->getCollection($path, $params, $options);
}
}
118 changes: 118 additions & 0 deletions src/Asana/Resources/CustomFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,122 @@ public function reorderEnumOption($customField, $params = array(), $options = ar
{
return $this->insertEnumOption($customField, $params, $options);
}

/**
* Creates a new custom field in a workspace. Every custom field is required to be created in a specific workspace, and this workspace cannot be changed once set.
*
* A custom field's `name` must be unique within a workspace and not conflict with names of existing task properties such as 'Due Date' or 'Assignee'. A custom field's `type` must be one of 'text', 'enum', or 'number'.
*
* Returns the full record of the newly created custom field.
*
* @deprecated replace with createCustomField
*
* @return response
*/
public function create($params = array(), $options = array())
{
return $this->client->post("/custom_fields", $params, $options);
}

/**
* Returns the complete definition of a custom field's metadata.
*
* @deprecated replace with getCustomField
*
* @param custom_field Globally unique identifier for the custom field.
* @return response
*/
public function findById($customField, $params = array(), $options = array())
{
$path = sprintf("/custom_fields/%s", $customField);
return $this->client->get($path, $params, $options);
}

/**
* Returns a list of the compact representation of all of the custom fields in a workspace.
*
* @deprecated replace with getCustomFieldsForWorkspace
*
* @param workspace The workspace or organization to find custom field definitions in.
* @return response
*/
public function findByWorkspace($workspace, $params = array(), $options = array())
{
$path = sprintf("/workspaces/%s/custom_fields", $workspace);
return $this->client->getCollection($path, $params, $options);
}

/**
* A specific, existing custom field can be updated by making a PUT request on the URL for that custom field. Only the fields provided in the `data` block will be updated; any unspecified fields will remain unchanged
*
* When using this method, it is best to specify only those fields you wish to change, or else you may overwrite changes made by another user since you last retrieved the custom field.
*
* An enum custom field's `enum_options` cannot be updated with this endpoint. Instead see "Work With Enum Options" for information on how to update `enum_options`.
*
* Locked custom fields can only be updated by the user who locked the field.
*
* Returns the complete updated custom field record.
*
* @deprecated replace with updateCustomField
*
* @param custom_field Globally unique identifier for the custom field.
* @return response
*/
public function update($customField, $params = array(), $options = array())
{
$path = sprintf("/custom_fields/%s", $customField);
return $this->client->put($path, $params, $options);
}

/**
* A specific, existing custom field can be deleted by making a DELETE request on the URL for that custom field.
*
* Locked custom fields can only be deleted by the user who locked the field.
*
* Returns an empty data record.
*
* @deprecated replace with deleteCustomField
*
* @param custom_field Globally unique identifier for the custom field.
* @return response
*/
public function delete($customField, $params = array(), $options = array())
{
$path = sprintf("/custom_fields/%s", $customField);
return $this->client->delete($path, $params, $options);
}

/**
* Creates an enum option and adds it to this custom field's list of enum options. A custom field can have at most 50 enum options (including disabled options). By default new enum options are inserted at the end of a custom field's list.
*
* Locked custom fields can only have enum options added by the user who locked the field.
*
* Returns the full record of the newly created enum option.
*
* @deprecated replace with createEnumOptionForCustomField
*
* @param custom_field Globally unique identifier for the custom field.
* @return response
*/
public function createEnumOption($customField, $params = array(), $options = array())
{
$path = sprintf("/custom_fields/%s/enum_options", $customField);
return $this->client->post($path, $params, $options);
}

/**
* Moves a particular enum option to be either before or after another specified enum option in the custom field.
*
* Locked custom fields can only be reordered by the user who locked the field.
*
* @deprecated replace with insertEnumOptionForCustomField
*
* @param custom_field Globally unique identifier for the custom field.
* @return response
*/
public function insertEnumOption($customField, $params = array(), $options = array())
{
$path = sprintf("/custom_fields/%s/enum_options/insert", $customField);
return $this->client->post($path, $params, $options);
}
}
3 changes: 3 additions & 0 deletions src/Asana/Resources/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

class Events extends EventsBase
{
/**
* @deprecated replace with getEvents and include {"full_payload" = true} as an option
*/
public function get($query = array(), $options = array())
{
$options['full_payload'] = true;
Expand Down
48 changes: 29 additions & 19 deletions src/Asana/Resources/Gen/AttachmentsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@

namespace Asana\Resources\Gen;

/**
* An _attachment_ object represents any file attached to a task in Asana,
* whether it's an uploaded file or one associated via a third-party service
* such as Dropbox or Google Drive.
*/
class AttachmentsBase
{
class AttachmentsBase {

/**
* @param Asana/Client client The client instance
*/
Expand All @@ -17,27 +12,42 @@ public function __construct($client)
$this->client = $client;
}

/**
* Returns the full record for a single attachment.
/** Delete an attachment
*
* @param attachment Globally unique identifier for the attachment.
* @param string $attachment_gid (required) Globally unique identifier for the attachment.
* @param array $params
* @param array $options
* @return response
*/
public function findById($attachment, $params = array(), $options = array())
{
$path = sprintf("/attachments/%s", $attachment);
public function deleteAttachment($attachment_gid, $params = array(), $options = array()) {
$path = "/attachments/{attachment_gid}";
$path = str_replace("{attachment_gid}", $attachment_gid, $path);
return $this->client->delete($path, $params, $options);
}

/** Get an attachment
*
* @param string $attachment_gid (required) Globally unique identifier for the attachment.
* @param array $params
* @param array $options
* @return response
*/
public function getAttachment($attachment_gid, $params = array(), $options = array()) {
$path = "/attachments/{attachment_gid}";
$path = str_replace("{attachment_gid}", $attachment_gid, $path);
return $this->client->get($path, $params, $options);
}

/**
* Returns the compact records for all attachments on the task.
/** Get attachments for a task
*
* @param task Globally unique identifier for the task.
* @param string $task_gid (required) The task to operate on.
* @param array $params
* @param array $options
* @return response
*/
public function findByTask($task, $params = array(), $options = array())
{
$path = sprintf("/tasks/%s/attachments", $task);
public function getAttachmentsForTask($task_gid, $params = array(), $options = array()) {
$path = "/tasks/{task_gid}/attachments";
$path = str_replace("{task_gid}", $task_gid, $path);
return $this->client->getCollection($path, $params, $options);
}
}
25 changes: 25 additions & 0 deletions src/Asana/Resources/Gen/BatchAPIBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Asana\Resources\Gen;

class BatchAPIBase {

/**
* @param Asana/Client client The client instance
*/
public function __construct($client)
{
$this->client = $client;
}

/** Submit parallel requests
*
* @param array $params
* @param array $options
* @return response
*/
public function createBatchRequest($params = array(), $options = array()) {
$path = "/batch";
return $this->client->post($path, $params, $options);
}
}
Loading

0 comments on commit 22bec8e

Please sign in to comment.