0

Not a question anymore

I was given this:

GET api/Products?apiKey={apiKey}

It returns all of the products available among all shops in an airport in this format(application/json, text/json):

[
  {
    "ProductShop": {
      "AirportName": "sample string 1",
      "ADCShopCode": "sample string 2",
      "libShop": "sample string 3",
      "StorePhoneNumber": "sample string 4",
      "idPoi": 5,
      "PoiName": "sample string 6"
    },
    "productActivity": "sample string 1",
    "productBrand": "sample string 2",
    "ProductFamily": "sample string 3"
  },
... ]

So to be able to access the data from this API I would need to define this in the request URI (I think), How can I do that and how can use this external data for my app ?

Please, can you be clear in your answer as to where should I define the parameters to connect the API in a rails app.

Thanks.

EDIT: What help me (I am a beginner):

http://railscasts.com/episodes/290-soap-with-savon

http://apionrails.icalialabs.com/book/chapter_two

Antoine
  • 559
  • 8
  • 21
  • possible duplicate of [Connecting to web services using Rails (HTTP requests)?](http://stackoverflow.com/questions/5043818/connecting-to-web-services-using-rails-http-requests) – Antoine Jun 05 '15 at 22:24

1 Answers1

2

To read the data from an external API, you usually want to write a wrapper around the API. For example using httparty (https://github.com/jnunemaker/httparty, warning this can be a little slower, but it's an easier start). Once you have the data, you will have it in a hash-like object, and what you do with it, it's up to you!

Leonel Galán
  • 6,993
  • 2
  • 41
  • 60