|
| 1 | +--- |
| 2 | +name: contentstack-android-cda |
| 3 | +description: Use when implementing or changing CDA features – Stack/Config, entries, assets, sync, HTTP, callbacks, and Content Delivery API alignment |
| 4 | +--- |
| 5 | + |
| 6 | +# Contentstack Android CDA SDK – CDA Implementation |
| 7 | + |
| 8 | +Use this skill when implementing or changing Content Delivery API (CDA) behavior in the Android SDK. |
| 9 | + |
| 10 | +## When to use |
| 11 | + |
| 12 | +- Adding or modifying Stack, Entry, Query, Asset, Content Type, or Sync behavior. |
| 13 | +- Changing Config options (host, version, region, branch, proxy, connection pool). |
| 14 | +- Working with the HTTP layer (CSHttpConnection/Volley, Stack/APIService/Retrofit/OkHttp) or callbacks and Error handling. |
| 15 | + |
| 16 | +## Instructions |
| 17 | + |
| 18 | +### Stack and Config |
| 19 | + |
| 20 | +- **Entry point:** `Contentstack.stack(Context, apiKey, deliveryToken, environment)`. Overloads accept `Config` for host, version, region, branch, proxy, connection pool, endpoint. |
| 21 | +- **Defaults:** host `cdn.contentstack.io`, version `v3` (see `Config`). Region and branch via `Config.setRegion()`, `Config.setBranch()`. |
| 22 | +- **Reference:** `Contentstack.java`, `Stack.java`, `Config.java`. |
| 23 | + |
| 24 | +### CDA resources |
| 25 | + |
| 26 | +- **Entries:** `Stack.contentType(uid).entry(uid)`, query APIs, and entry fetch. Use existing `Entry`, `Query`, `EntriesModel`, and callback types. |
| 27 | +- **Assets:** `Stack.assetLibrary()`, asset fetch and query. Use `Asset`, `AssetLibrary`, `AssetModel`, and related callbacks. |
| 28 | +- **Content types:** Content type schema and listing. Use `ContentType`, `ContentTypesModel`, `ContentTypesCallback`. |
| 29 | +- **Sync:** Sync API usage. Use existing sync request/response and pagination patterns. |
| 30 | +- **Official API:** Align with [Content Delivery API](https://www.contentstack.com/docs/apis/content-delivery-api/) for parameters, response shape, and semantics. |
| 31 | + |
| 32 | +### HTTP and retry |
| 33 | + |
| 34 | +- **HTTP:** CDA requests use **CSHttpConnection** (Volley) and/or **Retrofit** + **OkHttp** (e.g. `Stack`, `APIService`). Set headers (User-Agent, auth) per constants and existing request building. |
| 35 | +- **Retry:** Volley retry is configured via `DefaultRetryPolicy` in `CSHttpConnection`; constants in `SDKConstant` (e.g. `TimeOutDuration`, `NumRetry`, `BackOFMultiplier`). Keep timeouts and retry behavior consistent when changing the HTTP layer. |
| 36 | +- **Reference:** `CSHttpConnection.java`, `CSConnectionRequest.java`, `Stack.java`, `APIService.java`, `SDKConstant.java`. |
| 37 | + |
| 38 | +### Errors and callbacks |
| 39 | + |
| 40 | +- **Errors:** Map API errors to the `Error` class. Pass to the appropriate callback (e.g. `ResultCallBack`) so callers receive a consistent error shape. |
| 41 | +- **Callbacks:** Use existing callback types (`ResultCallBack`, `EntryResultCallBack`, `QueryResultsCallBack`, etc.). Do not change callback contracts without considering backward compatibility. |
| 42 | + |
| 43 | +## Key classes |
| 44 | + |
| 45 | +- **Entry points:** `Contentstack`, `Stack`, `Config` |
| 46 | +- **CDA:** `Entry`, `Query`, `Asset`, `AssetLibrary`, `ContentType`, sync-related classes |
| 47 | +- **HTTP:** `CSHttpConnection`, `CSConnectionRequest`, `APIService`, `Stack` (Retrofit) |
| 48 | +- **Errors / results:** `Error`, `QueryResult`, and callback interfaces in `com.contentstack.sdk` |
| 49 | + |
| 50 | +## References |
| 51 | + |
| 52 | +- [Content Delivery API – Contentstack Docs](https://www.contentstack.com/docs/apis/content-delivery-api/) |
| 53 | +- Project rules: `.cursor/rules/contentstack-android-cda.mdc`, `.cursor/rules/java.mdc` |
0 commit comments