Skip to content

Add User management methods to the SDK and examples#21

Merged
jaimehgb merged 8 commits intomasterfrom
jaime/user-management
Mar 21, 2025
Merged

Add User management methods to the SDK and examples#21
jaimehgb merged 8 commits intomasterfrom
jaime/user-management

Conversation

@jaimehgb
Copy link
Contributor

Title

Add User management methods to the SDK and examples

Description

To manage endpoints for watchlists, permissions and API credits.

Watchlists, we could eventually build on top of assets, so that they don't need to deal with asset IDs directly. But we'll get there

Type of change

  • New feature (non-breaking change which adds functionality)

Related PRs

How can a reviewer test this code?

Screenshots (if appropriate):


> @messari/sdk-examples@0.0.1 start:user-management /Users/jaime/work/gin/MessariKit/packages/examples
> tsx src/userManagement.ts


--------------------------------
Get Team's Credit Allowance
--------------------------------
Team Allowance Information:
{
  "id": "d880bc67-a0c0-479a-8908-d9baec064689",
  "teamId": 14,
  "creditsAllocated": 500000,
  "startDate": "2025-01-28T21:54:56.684Z",
  "isActive": true,
  "endDate": "2027-01-08T05:00:00Z",
  "remainingCredits": 488054
}

--------------------------------
Get User Permissions
--------------------------------
User Permissions:
{
  "permissions": [
    {
      "name": "AI-Digest",
      "permissionSlug": "ai_digest_permission",
      "active": true
    },
    {
      "name": "AI ToolKit API",
      "permissionSlug": "ai_toolkit_permission",
      "active": true
    },
    {
      "name": "Asset-API",
      "permissionSlug": "asset_permission",
      "active": true
    },
    {
      "name": "Copilot-API",
      "permissionSlug": "copilot_permission",
      "active": true
    },
    {
      "name": "Core-Metrics-API",
      "permissionSlug": "core_metrics_permission",
      "active": true
    },
    {
      "name": "Diligence-API",
      "permissionSlug": "diligence_service_permission",
      "active": true
    },
    {
      "name": "Funding-API",
      "permissionSlug": "funding_permission",
      "active": true
    },
    {
      "name": "Gov-API",
      "permissionSlug": "governor_service_permission",
      "active": true
    },
    {
      "name": "Intel-API",
      "permissionSlug": "intel_permission",
      "active": true
    },
    {
      "name": "Market-Data-API",
      "permissionSlug": "market_data_permission",
      "active": true
    },
    {
      "name": "News-API",
      "permissionSlug": "news_permission",
      "active": true
    },
    {
      "name": "Research-API",
      "permissionSlug": "research_permission",
      "active": true
    },
    {
      "name": "Signal API",
      "permissionSlug": "signal_permission",
      "active": true
    },
    {
      "name": "Token-Unlocks-API",
      "permissionSlug": "token_unlocks_permission",
      "active": true
    }
  ],
  "hasFullMarketDataGranularity": true,
  "hasAllAccess": true
}

--------------------------------
List User's Watchlists
--------------------------------
User Watchlists:
[
  {
    "id": "D8E48781",
    "title": "null test",
    "assetIds": [
      "0b3d4b05-d9eb-490e-a50f-066fbfed06ac",
      "010d8528-1276-4fd2-9960-59faa1aaa512",
      "48cd59d3-886d-43b7-b0d2-479c29f9af5f",
      "21c795f5-1bfd-40c3-858e-e9d7e820c6d0",
      "8687eff5-83d0-409c-99f7-efab71091707",
      "61e64b39-e37f-4892-90fa-343c4cfb37c6",
      "e22766cd-b425-4b1d-89d3-ff565b131a07",
      "7c435a77-5be9-4424-b5d1-1c02b968c56f",
      "16e4e88e-4a3d-491b-921d-d480dac0c9b3",
      "f02ddaf1-7748-4a06-84c6-8ee147ef73a4",
      "3d6a1f69-2e25-4c65-8e85-b8608455f863",
      "17b91b7d-e10b-43be-b046-c170aecd0783",
      "4908cfef-d09c-4c9d-80cb-ab776153ae4f",
      "90b4f888-aa6d-4e30-9ee5-81141e6802d9",
      "158ea205-8ead-42e6-8bb3-89f5b80bc322",
      "6c60d416-4a21-4045-ab0c-6c993c98862b",
      "c5a18bc3-4f23-40db-811a-843eefb2ebef",
      "0e38e60e-02e0-43f7-ad90-2096d23d48b8",
      "3e6d2d8e-b4c8-4738-837c-bc29d948fc7c",
      "e36183a0-816a-44c0-8787-9c5912e3beb7",
      "f2cfff3b-a8ae-434f-b9e3-1c81a0ba2f81",
      "fa668ab5-7922-4688-9504-a93edbaa9ac1",
      "3ea9f9ed-f985-4d35-b6f2-1f9b70e27550",
      "56ec7b37-b0ca-42a3-b156-281217d57dea",
      "2749bf02-c5c8-4829-a127-b036e2672041",
      "b22d9d2b-8d46-4bd8-a0e8-a19423a16a83",
      "a98e01c8-42ab-4321-8290-ab06059f5306",
      "4b474270-99ba-4a18-869d-11cd3fc0201a",
      "d3198b3a-1007-45bc-8da0-c3f7a4e98799",
      "745c2adf-28ae-4835-aa6f-3f642a82c6b2",
      "3ac77d3e-4055-46b5-afa6-d2f66c62a4c8",
      "1e31218a-e44e-4285-820c-8282ee222035"
    ],
    "createdAt": "2024-12-02T15:49:35.909968Z",
    "updatedAt": "2024-12-02T15:49:35.873209Z"
  },
  {
    "id": "82B31196",
    "title": "OG's",
    "assetIds": [
      "1e31218a-e44e-4285-820c-8282ee222035",
      "21c795f5-1bfd-40c3-858e-e9d7e820c6d0",
      "7dc551ba-cfed-4437-a027-386044415e3e",
      "1d51479d-68f6-4886-8644-2a55ea9007bf",
      "2c72a501-65e1-4a91-94a0-c86ef350f779",
      "5ad4db9e-b40f-4d4e-9bb5-7a8b239b01c7",
      "b3d5d66c-26a2-404c-9325-91dc714a722b"
    ],
    "createdAt": "2024-12-04T18:56:56.875953Z",
    "updatedAt": "2025-02-03T16:05:38.94042Z"
  },
  {
    "id": "E74B9B61",
    "title": "Updated Watchlist - 2025-03-20T13:58:48.911Z",
    "assetIds": [
      "1e31218a-e44e-4285-820c-8282ee222035",
      "21c795f5-1bfd-40c3-858e-e9d7e820c6d0"
    ],
    "createdAt": "2025-03-20T13:58:47.631448Z",
    "updatedAt": "2025-03-20T13:58:49.146593Z"
  },
  {
    "id": "ACC8ECE9",
    "title": "Test Watchlist - 2025-03-20T16:44:01.579Z",
    "assetIds": [
      "1e31218a-e44e-4285-820c-8282ee222035",
      "21c795f5-1bfd-40c3-858e-e9d7e820c6d0"
    ],
    "createdAt": "2025-03-20T16:44:01.843853Z",
    "updatedAt": "2025-03-20T16:44:01.799665Z"
  }
]

--------------------------------
Create a New Watchlist
--------------------------------
Created new watchlist: "Test Watchlist - 2025-03-20T17:04:06.899Z"

--------------------------------
Get Watchlist (ID: 1DDE3741)
--------------------------------
Watchlist Details:
{
  "id": "1DDE3741",
  "title": "Test Watchlist - 2025-03-20T17:04:06.899Z",
  "assetIds": [
    "1e31218a-e44e-4285-820c-8282ee222035",
    "21c795f5-1bfd-40c3-858e-e9d7e820c6d0"
  ],
  "createdAt": "2025-03-20T17:04:07.190659Z",
  "updatedAt": "2025-03-20T17:04:07.151231Z"
}

--------------------------------
Update Watchlist (ID: 1DDE3741)
--------------------------------
Updated Watchlist:
{
  "id": "1DDE3741",
  "title": "Updated Watchlist - 2025-03-20T17:04:08.174Z",
  "assetIds": [
    "1e31218a-e44e-4285-820c-8282ee222035",
    "21c795f5-1bfd-40c3-858e-e9d7e820c6d0"
  ],
  "createdAt": "2025-03-20T17:04:07.190659Z",
  "updatedAt": "2025-03-20T17:04:08.464887Z"
}

--------------------------------
Add Assets to Watchlist (ID: 1DDE3741)
--------------------------------
Watchlist after adding assets:
{
  "id": "1DDE3741",
  "title": "Updated Watchlist - 2025-03-20T17:04:08.174Z",
  "assetIds": [
    "1e31218a-e44e-4285-820c-8282ee222035",
    "21c795f5-1bfd-40c3-858e-e9d7e820c6d0",
    "c16f5137-def3-4c5c-b3e8-7921f9c8f0d2"
  ],
  "createdAt": "2025-03-20T17:04:07.190659Z",
  "updatedAt": "2025-03-20T17:04:08.820044Z"
}

--------------------------------
Remove Assets from Watchlist (ID: 1DDE3741)
--------------------------------
Watchlist after removing assets:
{
  "id": "1DDE3741",
  "title": "Updated Watchlist - 2025-03-20T17:04:08.174Z",
  "assetIds": [
    "1e31218a-e44e-4285-820c-8282ee222035",
    "c16f5137-def3-4c5c-b3e8-7921f9c8f0d2"
  ],
  "createdAt": "2025-03-20T17:04:07.190659Z",
  "updatedAt": "2025-03-20T17:04:09.140948Z"
}

--------------------------------
Delete Watchlist (ID: 1DDE3741)
--------------------------------
Delete Result:
""
Watchlist successfully deleted.

@jaimehgb jaimehgb merged commit 748d8d8 into master Mar 21, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants