Giter Site home page Giter Site logo

oliverabdulrahim / kotlin-asana Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 205 KB

๐Ÿ“š Client library for Asana written in Kotlin

License: MIT License

Kotlin 100.00%
asana asana-api kotlin serialization java kotlin-library wrapper declarative pagination

kotlin-asana's Introduction

Oliver Abdulrahim (@OliverAbdulrahim)

kotlin-asana's People

Contributors

oliverabdulrahim avatar

Stargazers

 avatar

Watchers

 avatar

kotlin-asana's Issues

Serialization of `CustomField`s with the "people" `resourceSubtype` is impossible

Issue outlined

Summary
No field in CustomField captures the people_value property given by custom field api endpoints. Example:

Example request

curl -X GET https://app.asana.com/api/1.0/tasks/12345?opt_fields=custom_fields
    ... header stuff ...

Example response

{
  "data": {
    "gid": "12345",
    "custom_fields": [
      {
        "gid": "...",
        "resource_subtype": "people",
        "resource_type": "custom_field",
        "people_value": [
          {
            "gid": "...",
            "resource_type": "user"
          },
          {
            "gid": "...",
            "resource_type": "user"
          }
        ],
        "type": "people"
      }
    ]
  }
}

Relevant part of the response

        "people_value": [
          {
            "gid": "...",
            "resource_type": "user"
          },
          {
            "gid": "...",
            "resource_type": "user"
          }
        ]
  • people_value is an array of User resources.

Proposed solution

Changes to CustomField class (Java)
Must implement a field to serialize the people_value object within CustomField.

@SerializedName("people_value")
public Collection<User> peopleValue;

Allow fields annotated with @AsanaCustomField to be processed optionally

Feature request

Allow fields annotated with the @AsanaCustomField annotation to be processed optionally.

Minimum viable example

data class Person(
    @AsanaCustomField("Preferred name")     override var name: String = "",=
    @AsanaCustomField("Fluent in Spanish?") override var bilingual: String = "",
) : AsanaSerializable<Person>

If the given Person class is used to serialize a task in a project where the Fluent in Spanish custom field does not exist, an error occurs:

Stack trace to avoid

Exception in thread "DefaultDispatcher-worker-4"
    org.conservationco.asana.serialization.customfield.CustomFieldException: No custom field in CustomFieldContext matches name=var bilingual: kotlin.String
    org.conservationco.asana.serialization.AsanaTaskSerializer.buildCustomFieldFrom(AsanaTaskSerializer.kt:92) at
    org.conservationco.asana.serialization.AsanaTaskSerializer.convertPropertiesToCustomFields(AsanaTaskSerializer.kt:80) at
    org.conservationco.asana.serialization.AsanaTaskSerializer.serialize(AsanaTaskSerializer.kt:44) at
    org.conservationco.asana.serialization.AsanaTaskSerializer.serialize(AsanaTaskSerializer.kt:52) at
    org.conservationco.asana.extensions.AsanaClientExtension.convertToTask(AsanaClientExtension.kt:360) at org.conservationco.asanahire.util.ApplicantsKt.copyAndUpdate(Applicants.kt:96) at
        

Proposed changes and syntax

annotation class AsanaCustomField(
    val name: String,
    val isOptional: Boolean = false,
)

Then don't throw an exception on custom field that don't appear and are marked as optional == true.

Serialization of `CustomField`s with the "date" `resourceSubtype` is impossible

Issue outlined

Summary
No field in CustomField captures the date_value property given by custom field api endpoints. Example:

Example request

curl -X GET https://app.asana.com/api/1.0/tasks/12345?opt_fields=custom_fields
    ... header stuff ...

Example response

{
  "data": {
    "gid": "12345",
    "custom_fields": [
      {
        "gid": "...",
        "resource_subtype": "date",
        "resource_type": "custom_field",
        "date_value": {
          "date": "2022-10-03",
          "date_time": "2022-10-03T23:00:00.000Z"
        }
      }
    ]
  }
}

Relevant part of the response

        "date_value": {
          "date": "2022-10-03",
          "date_time": "2022-10-03T23:00:00.000Z"
        }
  • date_value.date is a date string with the format YYYY-MM-DD, and
  • date_value.date_time is a full ISO-8601 string.

Proposed solution

Must implement a class to serialize the date_value object.

DateValue Implementation (Kotlin example)

data class DateValue(val date: DateTime?, val dateTime: DateTime?)

Changes to CustomField class (Java)
A field of type DateValue will need to be declared CustomField class:

@SerializedName("date_value")
public DateValue dateValue;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.