diff --git a/examples/delete.rb b/examples/delete.rb deleted file mode 100644 index f20b5e9..0000000 --- a/examples/delete.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/ruby - -require 'rubygems' -require '../lib/meli' -require 'json' - -meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN) - -response = meli.delete("/questions/QUESTION_ID", {:access_token => meli.access_token}) - -#Json format -puts response.body - -#ruby hash format -res = JSON.parse response.body -puts res.inspect diff --git a/examples/example_login.rb b/examples/example_login.rb deleted file mode 100644 index cc7be25..0000000 --- a/examples/example_login.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "rubygems" -require 'lib/meli' -require 'sinatra' -require 'json' - -set :meli, Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN) -disable :reload - -get '/authorize' do - content_type :text - settings.meli.authorize(params["code"], CALLBACK_URI) if params["code"] - #Don't Forget to Save this data! - "SUCESS! Token: #{settings.meli.access_token} RefresToken: #{settings.meli.refresh_token}" -end - -get '/login' do - "Login" -end diff --git a/examples/get.rb b/examples/get.rb deleted file mode 100644 index f5c408f..0000000 --- a/examples/get.rb +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/ruby - -require 'rubygems' -require '../lib/meli' -require 'json' - -meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN) - -response = meli.get("/items/MLB488622999") - -#Json format -puts response.body - -#ruby hash format -res = JSON.parse response.body -puts res.inspect diff --git a/examples/post.rb b/examples/post.rb deleted file mode 100644 index d396854..0000000 --- a/examples/post.rb +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/ruby - -require 'rubygems' -require '../lib/meli' - -meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN) - -body = {"condition"=>"new", - "warranty"=>"60 dias", - "currency_id"=>"BRL", - "accepts_mercadopago"=>true, - "description"=>"Lindo Ray_Ban_Original_Wayfarer", - "listing_type_id"=>"bronze", - "title"=>"\303\223culos Ray Ban Aviador Que Troca As Lentes Lan\303\247amento!", - "available_quantity"=>64, - "price"=>289, - "subtitle"=>"Acompanha 3 Pares De Lentes!! Compra 100% Segura", - "buying_mode"=>"buy_it_now", - "category_id"=>"MLB5125", - "pictures"=>[{"source"=>"http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"}, - {"source"=>"http://en.wikipedia.org/wiki/File:Teashades.gif"}] -} - -response = meli.post("/items", body, {:access_token => meli.access_token}) - -#Json format -puts response.body - -#ruby hash format -res = JSON.parse response.body -puts res.inspect diff --git a/examples/put.rb b/examples/put.rb deleted file mode 100644 index ba9aef5..0000000 --- a/examples/put.rb +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/ruby - -require 'rubygems' -require '../lib/meli' - -meli = Meli.new(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN) - -body = {"title"=>"New Title", "price"=>1000} - -response = meli.put("/items/#{ITEM_ID}", body, {:access_token => meli.access_token}) - -#Json format -puts response.body - -#ruby hash format -res = JSON.parse response.body -puts res.inspect diff --git a/lib/config.yml b/lib/config.yml deleted file mode 100755 index 84320b8..0000000 --- a/lib/config.yml +++ /dev/null @@ -1,21 +0,0 @@ -config: - sdk_version: MELI-RUBY-SDK-2.0.0 - api_root_url: https://api.mercadolibre.com - auth_url: https://auth.mercadolivre.com.br/authorization # # Don't forget to set the URL of your country. - oauth_url: /oauth/token - -# Set the auth_url according to your country - -#MLA https://auth.mercadolibre.com.ar/authorization # Argentina -#MLB https://auth.mercadolivre.com.br/authorization # Brasil -#MCO https://auth.mercadolibre.com.co/authorization # Colombia -#MCR https://auth.mercadolibre.com.cr/authorization # Costa Rica -#MEC https://auth.mercadolibre.com.ec/authorization # Ecuador -#MLC https://auth.mercadolibre.cl/authorization # Chile -#MLM https://auth.mercadolibre.com.mx/authorization # Mexico -#MLU https://auth.mercadolibre.com.uy/authorization # Uruguay -#MLV https://auth.mercadolibre.com.ve/authorization # Venezuela -#MPA https://auth.mercadolibre.com.pa/authorization # Panama -#MPE https://auth.mercadolibre.com.pe/authorization # Peru -#MPT https://auth.mercadolibre.com.pt/authorization # Prtugal -#MRD https://auth.mercadolibre.com.do/authorization # Dominicana diff --git a/spec/meli_spec.rb b/spec/meli_spec.rb deleted file mode 100644 index 8173f40..0000000 --- a/spec/meli_spec.rb +++ /dev/null @@ -1,172 +0,0 @@ -# encoding: UTF-8 - -require 'spec_helper' - -describe Meli do - - before(:each) do - @client_id = "1234567" - @secret_code = "a secret" - @access_token = "access_token" - @refresh_token = "refresh_token" - @new_access_token = "a new access_token" - @new_refresh_token = "a new refresh_token" - - @meli = Meli.new @client_id, @secret_code, @access_token, @refresh_token - - @meli.https.stub(:request) do |req| - case req.method - when "GET" - if req.path =~ /\/users\/me/ - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - else - Net::HTTPOK.new(1, 200, "OK") - end - when "POST" - if req.path =~ /\/oauth\/token/ - if !req.path =~ /grant_type/ || !req.path =~ /client_id/ || !req.path =~ /client_secret/ - Net::HTTPForbidden.new(1, 403, "Forbidden") - else - response = Net::HTTPOK.new(1, 200, "OK") - if req.body =~ /grant_type=authorization_code/ - def response.body - {:access_token => 'access_token', :refresh_token => 'refresh_token'}.to_json - end - elsif req.body =~ /grant_type=refresh_token/ - def response.body - {:access_token => 'a new access_token', :refresh_token => 'a new refresh_token'}.to_json - end - end - end - response - else - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - end - when "PUT" - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - when "DELETE" - if req.path =~ /access_token/ - Net::HTTPOK.new(1, 200, "OK") - else - Net::HTTPForbidden.new(1, 403, "Forbidden") - end - else - Net::HTTPInternalServerError.new(1, 500, "Internal Server Error") - end - end #stub - end #before each - - describe "Requireds Gems" do - it "should have json gem version 1.8.0" do - Gem::Specification::find_all_by_name('json').any?.should be_true - end - end - - describe "#new" do - it "should return a Meli object" do - @meli.should be_an_instance_of Meli - end - it "should return corret app_id" do - @meli.app_id.should == @client_id - end - it "should return corret secret" do - @meli.secret.should == @secret_code - end - it "should return correct access_token" do - @meli.access_token.should == @access_token - end - it "should return correct refresh_token" do - @meli.refresh_token.should == @refresh_token - end - it "should return a net/http service" do - @meli.https.should be_an_instance_of Net::HTTP - end - it "should have a http service with ssl" do - @meli.https.use_ssl?.should be_true - end - end - - describe "http methods" do - it "should return a reponse from get" do - response = @meli.get("/items/test1") - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from post" do - body = {"condition"=>"new", - "warranty"=>"60 dias", - "currency_id"=>"BRL", - "accepts_mercadopago"=>true, - "description"=>"Lindo Ray_Ban_Original_Wayfarer", - "listing_type_id"=>"bronze", - "title"=>"\303\223culos Ray Ban Aviador Que Troca As Lentes Lan\303\247amento!", - "available_quantity"=>64, - "price"=>289, - "subtitle"=>"Acompanha 3 Pares De Lentes!! Compra 100% Segura", - "buying_mode"=>"buy_it_now", - "category_id"=>"MLB5125", - "pictures"=>[{"source"=>"http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"}, - {"source"=>"http://en.wikipedia.org/wiki/File:Teashades.gif"}] - } - response = @meli.post("/items/test1", body, {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from put" do - body = {"title"=>"New Title", "price"=>1000} - response = @meli.put("/items/test1", body, {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "should return a reponse from delete" do - response = @meli.delete("/questions/123", {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - it "get should return forbidden without access_token" do - response = @meli.get("/users/me") - response.should be_an_instance_of Net::HTTPForbidden - end - it "get should return OK with access_token" do - response = @meli.get("/users/me", {:access_token => @meli.access_token}) - response.should be_an_instance_of Net::HTTPOK - end - end - - describe "Auth Url" do - it "should return the correct auth url" do - callback = "http://test.com/callback" - @meli.auth_url(callback).should match "^https\:\/\/auth.mercadolibre.com\/authorization" - @meli.auth_url(callback).should match callback - @meli.auth_url(callback).should match @client_id - @meli.auth_url(callback).should match "response_type" - end - end - - describe "Authorize" do - it "should return Access Token" do - @meli.access_token = nil - @meli.refresh_token = nil - @meli.authorize("a code from get param", "A redirect Uri") - @meli.access_token.should == @access_token - @meli.refresh_token.should == @refresh_token - end - end - - describe "Refresh Token" do - it "should return new Access Token and a new Refresh Token" do - response = @meli.get_refresh_token() - @meli.access_token.should == @new_access_token - @meli.refresh_token == @new_refresh_token - end - end - -end