Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a meta struct (or two) #10

Open
tzapu opened this issue Oct 18, 2019 · 2 comments
Open

add a meta struct (or two) #10

tzapu opened this issue Oct 18, 2019 · 2 comments

Comments

@tzapu
Copy link
Contributor

tzapu commented Oct 18, 2019

there are only two types of meta objects currently (with and without pagination) so it would make sense to have them as separate structs and embed them into the top level structs

Meta:
  type: object
  description:
    en: Meta information about the request.
    zh: (...)
  properties:
    latestBlock:
      type: object
      description:
        en: Information about the latest block in the canonical chain.
        zh: (...)
      properties:
        number:
          description:
            en: The block number of the latest block.
            zh: (...)
          example: 7909779
          type: integer
​
        blockCreationTime:
          description:
            en: The inception timestamp (UTC) of the latest block.
            zh: (...)
          example: 1559879572
          format: unixtime
          type: integer
​
        blockHash:
          description:
            en: The hash of the latest block.
            zh: (...)
          example: '0x8f25ead8680577256d43d5401beeb9cefa4cc121478c79c75a2e23a4695aa450'
          format: hex256
          type: string
​
​
MetaPagination:
  type: object
  description: Meta information about the request.
  properties:
    latestBlock:
      type: object
      description: Information about the latest block in the canonical chain.
      properties:
        number:
          description:
            en: The block number of the latest block.
            zh: (...)
          example: 7909779
          type: integer
​
        blockCreationTime:
          description:
            en: The inception timestamp (UTC) of the latest block.
            zh: (...)
          example: 1559879572
          format: unixtime
          type: integer
​
        blockHash:
          description:
            en: The hash of the latest block.
            zh: (...)
          example: '0x8f25ead8680577256d43d5401beeb9cefa4cc121478c79c75a2e23a4695aa450'
          format: hex256
          type: string
​
    count:
      type: integer
      description:
        en: The number of items included in the current page.
        zh: (...)
      example: 10
​
    page:
      type: object
      description:
        en: Pagination flags.
        zh: (...)
      properties:
        hasNext:
          description:
            en: Flags `true` if the `next` page has at least one entry, `false` otherwise
            zh: (...)
          example: true
          type: boolean
​
        hasPrev:
          description:
            en: Flags `true` if the `prev` page has at least one entry, `false` otherwise
            zh: (...)
          example: true
          type: boolean
@tzapu
Copy link
Contributor Author

tzapu commented Oct 18, 2019

as there seems to be a third value, query as seen here https://api.aleth.io/v1/token-balances?filter[account]=0xa8fdd211190852dd83cf152a824d936012479d01 it makes less sense to break it up apart in two ... as there are 3 variants of the structs :P

needs some thinking, open to suggestions

@corpetty
Copy link
Owner

corpetty commented Oct 20, 2019

yeah I was planning on looking into cleaning up the structs once I naively captured them all from all the API calls. that's almost finished. I'd like to capture and clean them up significantly so we don't rewrite the code and it can be upgraded if they change it easily.

Once decision I haven't made is where to store the meta structures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants