mercredi 18 février 2015

Retrieving and caching nested objects from a REST API

I have a series of nested objects, exposed over a REST API, like so:



class Category
{
int id;
string name;
List<Subcategory> subcategories;
}

class Subcategory
{
int id;
string name;
List<Product> products;
}

class Product
{
int id;
string name;
List<Model> models;
}

class Model
{
int id;
string name;
Dictionary<string, string> metadata;
}


These objects can be accessed over a REST API with the following end points



// get a list of categories
GET /categories

// get a category
GET /categories/:id

// Get subcategories for a product
GET /categories/:categoryId/subcategories

// Get a subcategory
GET //categories/:categoryId/:subcategoryId


//Get products under a subcategory
GET /categories/:categoryId/:subcategoryId/products

//Get a product
/categories/:categoryId/:subcategoryId/:productId

//Get models
/categories/:categoryId/:subcategoryId/:productId/models


Get a model under a product
/categories/:categoryId/:subcategoryId/:productId/:modelId


What design pattern do I use to design a data access layer on the client side? Please note that my client only reads these objects, it doesn't write to them. DAO? Repository? I am a bit confused between the two, not sure what would be applicable here.


Aucun commentaire:

Enregistrer un commentaire