Skip to content

jdestradap/ig_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ig App API

This is an api sample app, using oauth for authentication.

Instalation

Clone the application from github

git clone [email protected]/jdestradap/ig_app

Install all required gems

bundle install

Create and setup a database for development and another one for testing

rake db:create:all

rake db:migrate

Ig App Client

Please check this out. Is a pretty client (on rails) to get data from Ig App API.

Ig App Sample code

Get all products

HTTP method PATH Parameters
GET http://localhost:3000/api/products name, description
require 'oauth'
require 'json'

consumer = OAuth::Consumer.new("GfoBZmWinGMmxwnQEiYeDjW2jB31IchcvWNRaeLV", "5uyICKnFnCPBFcFBIpqvSWscepbI1Aay4njNuPv6", {
    :site                 => "http://matiz.igapps.co",
    :request_token_path   => "/oauth/request_token",
    :authorize_url        => "/oauth/access_token",
    :access_token_path    => "/oauth/authorize"
  })

client = OAuth::AccessToken.new(consumer,
                       			 "SS8hK5pZeEGADVNo1ZbgpFS2sh802ZpQzRxHwOgb",
                       			 "IBU8OAIgx6bnUVFJgGtw3WFoAcsuBwtahc3tCqSd")

body = JSON.generate('name'=>'Baloto', 'description'=>'Muy Rico')
result = client.get('http://localhost:3000/api/products')

print result.body

Create a product

HTTP method PATH Parameters
POST http://localhost:3000/api/products name, description
require 'oauth'
require 'json'

consumer = OAuth::Consumer.new("GfoBZmWinGMmxwnQEiYeDjW2jB31IchcvWNRaeLV", "5uyICKnFnCPBFcFBIpqvSWscepbI1Aay4njNuPv6", {
    :site                 => "http://matiz.igapps.co",
    :request_token_path   => "/oauth/request_token",
    :authorize_url        => "/oauth/access_token",
    :access_token_path    => "/oauth/authorize"
  })

client = OAuth::AccessToken.new(consumer,
                       			 "SS8hK5pZeEGADVNo1ZbgpFS2sh802ZpQzRxHwOgb",
                       			 "IBU8OAIgx6bnUVFJgGtw3WFoAcsuBwtahc3tCqSd")

body = JSON.generate('name'=>'Baloto', 'description'=>'Muy Rico')
result = client.post('http://localhost:3000/api/products', body, {"Content-Type"=>"application/json"})

print result.body

Update product name or description

HTTP method PATH Parameters
PUT http://localhost:3000/api/products/{product_id} name, description
require 'oauth'
require 'json'

consumer = OAuth::Consumer.new("GfoBZmWinGMmxwnQEiYeDjW2jB31IchcvWNRaeLV", "5uyICKnFnCPBFcFBIpqvSWscepbI1Aay4njNuPv6", {
    :site                 => "http://matiz.igapps.co",
    :request_token_path   => "/oauth/request_token",
    :authorize_url        => "/oauth/access_token",
    :access_token_path    => "/oauth/authorize"
  })

client = OAuth::AccessToken.new(consumer,
                       			 "SS8hK5pZeEGADVNo1ZbgpFS2sh802ZpQzRxHwOgb",
                       			 "IBU8OAIgx6bnUVFJgGtw3WFoAcsuBwtahc3tCqSd")

body = JSON.generate('name'=>'Baloto', 'description'=>'Rico')
result = client.put('http://localhost:3000/api/products/1', body, {"Content-Type"=>"application/json"})

print result.body

Delete product

HTTP method PATH Parameters
DELETE http://localhost:3000/api/products/{product_id} name, description
require 'oauth'
require 'json'

consumer = OAuth::Consumer.new("GfoBZmWinGMmxwnQEiYeDjW2jB31IchcvWNRaeLV", "5uyICKnFnCPBFcFBIpqvSWscepbI1Aay4njNuPv6", {
    :site                 => "http://matiz.igapps.co",
    :request_token_path   => "/oauth/request_token",
    :authorize_url        => "/oauth/access_token",
    :access_token_path    => "/oauth/authorize"
  })

client = OAuth::AccessToken.new(consumer,
                       			 "SS8hK5pZeEGADVNo1ZbgpFS2sh802ZpQzRxHwOgb",
                       			 "IBU8OAIgx6bnUVFJgGtw3WFoAcsuBwtahc3tCqSd")

result = client.delete('http://localhost:3000/api/products/1')

print result.body

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published