DEV Rest Services Documentation 230412 0836 8

Embed Size (px)

Citation preview

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    1/15

    REST Services - Documentation

    IPAD Food Server -REST Services usage

    IPAD Food Server - REST Services usageCachingApplication versionAPI KeyAuthenticationREST Services

    CREATE A USERUPDATE A USERDELETE A USERGET USER BY IDPURCHASE A COLLECTIONVIEW ALL COLLECTION FOR A USERVIEW ALL COLLECTIONSVIEW A COLLECTIONVIEW ALL COLLECTIONS FOR A GIVEN RECIPEDOWNLOAD PURCHASED COLLECTIONS

    SEARCH ALL PUBLISHED RECIPESGET A PUBLISHED RECIPE BY IDGET ALL RECIPES FOR A COLLECTIONGETINGREDIENTSGET TAGSGET TAGS DIMENSIONS MAPPING

    Appendix-AJSON REPRESENTATION OF A USER

    Appendix-BJSON REPRESENTATION OF A COLLECTION

    Appendix-CAppendix-D

    Caching

    The IFS uses Etags to determine if the content requested has been modified. The etags must be supplied inside a if-none-match header.

    Application version

    To ensure compatibility between the iPad food app and the iPad food Server, the IFS application version must be supplied for each call to aservice. In this service URL example, the application version is the first part of the service URL.

    /{version}/{apikey}/users/{id}/collections

    So to get all the collections purchased by a user with the id 124 on the IFS version 1.0, with the api key 123456789 the URL would be:/1.0/123456789/users/124/collectionsh2. Language

    Language is specified using the accept-language request header. The values supported are en-CA, fr-CA, en, fr. If no accept-language header

    is supplied or if the header supplied is no supported, en-Ca will be assumed. Language has no influence on services that return element based onspecific ids.

    API Key

    An API key must be supplied with every call to a service. Api Keys will be supplied to the client application by tc.media. Api keys will be differentfor each environment (QA, STG, PROD)

    Ex:

    /{version}/{apikey}/users/{id}/collections

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    2/15

    h2. Authentication

    All communications with the server will be done through https. Authentication will be needed to access each service. It will be handled usingHTTP Digest by passing an MD5 hash of the email and password of the user.

    Authentication

    The api services a protected by basic authentication over https. To find out what the user and password are contact operations

    REST Services

    This is a list of all the services available for the iPad Food Server.

    CREATE A USER

    The service is used to create a user in the iPad Food Server.

    Method Parameter(s)

    POST

    URL

    /{version}/{apikey}/users

    POST

    firstNamelastNameemailpasswordphoneHomepostalAddressHomepostalAddressAdditionalHomestateHomepostCodeHomedob (Date of birth)tcInfotcPartnersInfo

    See the for more details on each of these fieldsIPad food app server Software Design Document

    Output

    Success:

    HTTP 201, with the get URL of the newly created user and its JSON representation in the body. See Appendix-A for the JSON model

    Failure:

    Required fields failure: HTTP 412 with the list of required fields missingServer error: HTTP 500 with a message detailing the error.

    Workflow

    UPDATE A USER

    This service is used to update the information of a specific user.

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    3/15

    Method

    PUT

    URL

    /{version}/{apikey}/users/{id}

    POST Parameter(s)

    firstNamelastNameemailpasswordphoneHomepostalAddressHomepostalAddressAdditionalHomestateHomepostCodeHomedob (Date of birth)tcInfotcPartnersInfoHTTP 200, with a JSON representation of the User Object. See Appendix-A for the JSON modelRequired fields failure: HTTP 412 with the list of required fields missingServer error: HTTP 500 with a message detailing the error.

    Output

    Success:

    HTTP 200, with a JSON representation of the User Object. See Appendix-A for the JSON model

    Failure:

    Required fields failure: HTTP 412 with the list of required fields missingServer error: HTTP 500 with a message detailing the error.

    Workflow

    DELETE A USER

    This service is used to permanently delete a user and is purchased collection from the database.

    Method

    DELETE

    URL

    /{version}/{apikey}/users/{id}

    h4. POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 204

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    4/15

    Failure:

    Server error: HTTP 500 with a message detailing the error.

    Workflow

    GET USER BY IDThis service is used to retrieve the information for specific user.

    Method

    GET

    URL

    /{version}/{apikey}/users/{id}

    h4. POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of the User Object. See Appendix-A for the JSON model

    Failure:

    Id supplied not found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    PURCHASE A COLLECTION

    The service is used to associate a user with a collection purchase purchased.

    Method

    POST

    URL

    /{version}/{apikey}/users/{id}/collections/{cid}/purchase

    POST Parameter(s)

    receipt

    Output

    Success:

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    5/15

    HTTP 200, with a JSON representation of the collection purchased.

    Failure:

    id or cid supplied not found: HTTP 404 Not foundInvalid receipt: HTTP 402 Payment required.Server error: HTTP 500 with a message detailing the error.

    Workflow

    VIEW ALL COLLECTION FOR A USER

    This service is used to retrieve the information for all the collections purchased by a user.

    Method

    GET

    URL

    /{version}/{apikey}/users/{id}/collections

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of collection objects. See Appendix-B for the JSON model

    Failure:

    id supplied not found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    VIEW ALL COLLECTIONS

    This service is used to retrieve the information for all published collections

    Method

    GET

    URL

    /{version}/{apikey}/collections/

    h4. POST Parameter(s)

    NONE

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    6/15

    Output

    Success:

    HTTP 200, with a JSON representation of a list of all the published collection objects. See Appendix-B for the JSON model

    Failure:

    No published collection available: HTTP 404 Not found

    Server error: HTTP 500 with a message detailing the error.

    Workflow

    VIEW A COLLECTION

    This service is used to retrieve the information for a specific collection

    Method

    GET

    URL

    /{version}/{apikey}/collections/{id}

    h4. POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation collection objects. See Appendix-B for the JSON model

    Failure:

    Id supplied not available: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    VIEW ALL COLLECTIONS FOR A GIVEN RECIPE

    This service is used to get information for all the collections associated to a specific recipe

    Method

    GET

    URL

    /{version}/{apikey}/recipes/{id}/collections

    h4. POST Parameter(s)

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    7/15

    1.2.3.4.

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of collection objects. See Appendix-B for the JSON model

    Failure:

    id supplied not found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    DOWNLOAD PURCHASED COLLECTIONS

    This service is used to download previously purchased collections. It will return collections regardless of there publishable state

    Method

    GET

    URL

    /{version}/{apikey}/collections/purchased?sku...=abc123

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of collection objects. See Appendix-B for the JSON model

    Failure:

    sku(s) supplied not found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    SEARCH ALL PUBLISHED RECIPES

    This service is used to search through all the published recipes and retrieve recipe info. To be published a recipe must meet these criarias

    Recipe must have a status of PUBLISHEDRecipe embargo date must be in the pastRecipe expiration date must be in the futureRecipe must be part of a collection

    Method

    GET

    URL

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    8/15

    /{version}/{apikey}/recipes/search?term=value&tags=value

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of recipe objects. See Appendix-C for the JSON model

    Failure:

    If not matching recipes are found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    GET A PUBLISHED RECIPE BY ID

    This service is used to retrieve the information for a specific recipe

    Method

    GET

    URL

    /{version}/{apikey}/recipes/{id}

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a recipe objects. See Appendix-C for the JSON model

    Failure:

    If not matching recipes are found: HTTP 404 Not found

    Server error: HTTP 500 with a message detailing the error.

    Workflow

    GET ALL RECIPES FOR A COLLECTION

    This service is used to get information for all the recipes associated to a specific collection

    Method

    GET

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    9/15

    URL

    /{version}/{apikey}/collections/{id}/recipes

    h4. POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of recipe objects. See Appendix-C for the JSON model

    Failure:

    If collection id supplied not found: HTTP 404 Not foundIf not matching recipes are found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    Workflow

    GETINGREDIENTS

    This service is used to get a list of Ingredient names based on the language supplied with the accept-language Header param.

    Method

    GET

    URL

    /{version}/{apikey}/ingredients

    h4. POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of a list of Strings

    Failure:

    If no ingredients are found: HTTP 404 Not foundServer error: HTTP 500 with a message detailing the error.

    GET TAGS

    This service is used to get a list of all available tags. See Appendix-D for the JSON

    The term param is optional. A search with no term will return all tags that have recipes associated to them.

    Method

    GET

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    10/15

    URL

    /{version}/{apikey}/tags?term=

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of tags

    Failure:

    If search term doesnt yield a result HTTP 200, with a JSON representation of an empty listServer error: HTTP 500 with a message detailing the error.

    GET TAGS DIMENSIONS MAPPING

    This service is used to get a map object of resolutions between iPad Food App tag Ids and Endeca Dimension Ids.

    The keys of the map are Tag ids. The values are dimension ids.

    Method

    GET

    URL

    /{version}/{apikey}/tags/dimensions

    POST Parameter(s)

    NONE

    Output

    Success:

    HTTP 200, with a JSON representation of tags

    Failure:

    If search term doesnt yield a result HTTP 200, with a JSON representation of an empty listServer error: HTTP 500 with a message detailing the error.

    Appendix-A

    JSON REPRESENTATION OF A USER

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    11/15

    {

    : ,"dob" "1971-01-12"

    : ,"email" "[email protected]"

    : ,"firstName" "Jean-Sebastien"

    : 35,"id"

    : ,"lastName" "Deschambault"

    : ,"phoneHome" "5147842547"

    : ,"postCodeHome" "h2m1m2"

    : ,"postalAddressAdditionalHome" null

    : ,"postalAddressHome" "123 test drive"

    : ,"stateHome" "CA-QC"

    : ,"tcInfo" false

    :"tcPartnersInfo" false

    }

    Appendix-B

    JSON REPRESENTATION OF A COLLECTION

    {

    : ,"category" "COLLECTION": 2.99,"cost"

    : ,"currency" "CAD"

    : ,"description" "Desserts from our tables"

    : ,"free" true

    : 4,"id"

    : ,"language" "en"

    : ["medias"

    {

    : ,"approved" false

    : ,"category" "IMAGE_THUMBNAIL"

    : ,"description" null

    : ,"displaySize" "230 X 158"

    : 158,"height"

    : ,"imageFileName" null

    : ["metas"

    {

    : ,"tag" "Rights"

    :"value" "http://legals4.tc.tc"

    }

    ],

    : ,"mimeType" "image/jpeg"

    : ,"title" "Thumbnail pour une recette"

    :"url" "http: ,//www.coupdepouce.com/media/images/recettes/mousses-et-poudings.gif"

    : 230"width"

    }

    ],

    : ["metas"

    {

    : 11,"id"

    : ,"tag" "Rights"

    :"value" "http://legals1.tc.tc"}

    ],

    : ,"name" "Desserts"

    : ,"publishable" true

    : 2,"recipesCount"

    :"sku" null

    }

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    12/15

    Appendix-C

    JSON REPRESENTATION OF ARECIPE

    {

    : 10,"cookTime"

    : 4,"id"

    : ["instructions"

    {

    : ,"directive" "Burn ground beef 5 minutes"

    : ["recipeIngredients"

    {

    : 19,"id"

    : ,"quantity" "2"

    :"recipeIngredient" "Burger Buns"

    }

    ]

    },

    {

    : ,"directive" "Put bun on table"

    : ["recipeIngredients"

    {

    : 18,"id"

    : ,"quantity" "0.25 lb (250 g)"

    :"recipeIngredient" "Ground Beef"

    }

    ]

    },

    {

    : ,"directive" "Put patty on bunn"

    : ["recipeIngredients"

    {

    : 18,"id"

    : ,"quantity" "0.25 lb (250 g)"

    :"recipeIngredient" "Ground Beef"

    },

    {

    : 19,"id"

    : ,"quantity" "2"

    :"recipeIngredient" "Burger Buns"

    }

    ]

    },

    {

    : ,"directive" "Put oignons on patty"

    : ["recipeIngredients"

    {

    : 17,"id"

    : ,"quantity" "1"

    :"recipeIngredient" "Chopped Oignon"

    },

    {

    : 19,"id"

    : ,"quantity" "2":"recipeIngredient" "Burger Buns"

    }

    ]

    },

    {

    : ,"directive" "Put top bun on onions"

    : ["recipeIngredients"

    {

    : 17,"id"

    : ,"quantity" "1"

    :"recipeIngredient" "Chopped Oignon"

    },

    {

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    13/15

    : 18,"id"

    : ,"quantity" "0.25 lb (250 g)"

    :"recipeIngredient" "Ground Beef"

    }

    ]

    }

    ],

    : ,"language" "en"

    : ["medias"

    {

    : ,"category" "IMAGE_FULLSIZE": ,"description" "Burger all dressed on a plate"

    : ,"displaySize" "410 X 280"

    : 280,"height"

    : ,"imageFileName" null

    : ["metas"

    {

    : ,"tag" "Rights"

    :"value" "http://legals3.tc.tc"

    }

    ],

    : ,"mimeType" "image/jpeg"

    : ,"title" "Burger"

    :"url" "http:

    //www.coupdepouce.com/img/photos/biz/CoupDePouce/recettes_non_importees/Plats%20principaux/hamburger-pou

    ,

    : 410"width"

    }

    ],

    : ["metas"

    {

    : 15,"id"

    : ,"tag" "Creator"

    :"value" "Jean Charet"

    },

    {

    : 18,"id"

    : ,"tag" "Publisher"

    :"value" "Parti Liberal"

    }

    ],

    : 10,"preparationTime": ,"publishable" true

    : ["recipeIngredients"

    {

    : 17,"id"

    : ,"quantity" "1"

    :"recipeIngredient" "Chopped Oignon"

    },

    {

    : 18,"id"

    : ,"quantity" "0.25 lb (250 g)"

    :"recipeIngredient" "Ground Beef"

    },

    {

    : 19,"id"

    : ,"quantity" "2"

    :"recipeIngredient" "Burger Buns"

    }

    ],

    : ["recipeNutritionals"

    {

    :"recipeNutritional" "5 g sodium"

    },

    {

    :"recipeNutritional" "35 g fat"

    },

    {

    :"recipeNutritional" "25 g proteins"

    },

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    14/15

    {

    :"recipeNutritional" "15 g carbohydrates"

    },

    {

    :"recipeNutritional" "90 cal calories"

    },

    {

    :"recipeNutritional" "4 g saturated_fat"

    }

    ],

    : ,"servingSize" null: ,"source" "Jean Charet, Canadian Living"

    : ,"summary" "Best Burger"

    : ["tags"

    {

    : ,"fullName" "barbecue"

    : ,"language" "fr"

    : ,"name" "barbecue"

    :"parentTag" null

    },

    {

    : ,"fullName" "bbq"

    : ,"language" "en"

    : ,"name" "bbq"

    :"parentTag" null

    },

    {

    : ,"fullName" "Fast food"

    : ,"language" "en"

    : ,"name" "Fast food"

    :"parentTag" null

    }

    ],

    : ,"title" "Burger"

  • 8/2/2019 DEV Rest Services Documentation 230412 0836 8

    15/15

    : 20,"totalTime"

    :"yield" "1"

    Appendix-D

    JSON REPRESENTATION OF A TAG