Skip to content

Commit 91cd1be

Browse files
committed
add readme
1 parent 3d717ff commit 91cd1be

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# MercadoLibre's .NET SDK
2+
3+
This is the official .NET SDK for MercadoLibre's Platform.
4+
5+
## How do I install it?
6+
7+
You can download the latest build at:
8+
https://github.com/mercadolibre/net-sdk/downloads
9+
10+
And that's it!
11+
12+
## How do I start using it?
13+
14+
The first thing to do is to instance a ```Meli``` class. You'll need to give a ```clientId``` and a ```clientSecret```. You can obtain both after creating your own application. For more information on this please read: [creating an application](http://developers.mercadolibre.com/creating-your-own-application/)
15+
16+
```csharp
17+
Meli m = new Meli(1234, "a secret");
18+
```
19+
With this instance you can start working on MercadoLibre's APIs.
20+
21+
There are some design considerations worth to mention.
22+
1. This SDK is just a thin layer on top of an http client to handle all the OAuth WebServer flow for you.
23+
2. There is no JSON parsing. This is left to you. But this SDK uses [json.net](http://www.json.net/) library for internal usage.
24+
25+
## How do I redirect users to authorize my application?
26+
27+
This is a 2 step process.
28+
29+
First get the link to redirect the user. This is very easy! Just:
30+
31+
```csharp
32+
string redirectUrl = m.GetAuthUrl("http://somecallbackurl");
33+
```
34+
35+
This will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process.
36+
37+
Once the user is redirected to your callback url, you'll receive in the query string, a parameter named ```code```. You'll need this for the second part of the process.
38+
39+
```csharp
40+
m.Authorize("the received code", "http://somecallbackurl");
41+
```
42+
43+
This will get an ```accessToken``` and a ```refreshToken``` (is case your application has the ```offline_access```) for your application and your user.
44+
45+
At this stage your are ready to make call to the API on behalf of the user.
46+
47+
## Making GET calls
48+
49+
```csharp
50+
var p = new Parameter ();
51+
p.Name = "access_token";
52+
p.Value = m.AccessToken;
53+
54+
var ps = new List<Parameter> ();
55+
ps.Add (p);
56+
IRestResponse response = m.Get ("/users/me", ps);
57+
```
58+
59+
## Making POST calls
60+
61+
```csharp
62+
var p = new Parameter ();
63+
p.Name = "access_token";
64+
p.Value = m.AccessToken;
65+
66+
var ps = new List<Parameter> ();
67+
ps.Add (p);
68+
IRestResponse r = m.Post ("/items", ps, new {foo="bar"});
69+
```
70+
## Making PUT calls
71+
72+
```csharp
73+
var p = new Parameter ();
74+
p.Name = "access_token";
75+
p.Value = m.AccessToken;
76+
77+
var ps = new List<Parameter> ();
78+
ps.Add (p);
79+
IRestResponse r = m.Put ("/items/123", ps, new {foo="bar"});
80+
```
81+
## Making DELETE calls
82+
83+
```csharp
84+
var p = new Parameter ();
85+
p.Name = "access_token";
86+
p.Value = m.AccessToken;
87+
88+
var ps = new List<Parameter> ();
89+
ps.Add (p);
90+
IRestResponse r = m.Delete ("/items/123", ps);
91+
```
92+
93+
## Do I always need to include the ```access_token``` as a parameter?
94+
No. Actually most ```GET``` requests don't need an ```access_token``` and it is easier to avoid them and also it is better in terms of caching.
95+
But this decision is left to you. You should decide when it is necessary to include it or not.
96+
97+
## Community
98+
99+
You can contact us if you have questions using the standard communication channels described in the [developer's site](http://developers.mercadolibre.com/discuss)
100+
101+
## I want to contribute!
102+
103+
That is great! Just fork the project in github. Create a topic branch, write some code, and add some tests for your new code.
104+
105+
To run the tests run ```make test```.
106+
107+
You'll need [nodejs](http://www.nodejs.org) in order to run the tests. We use it to mock the API.
108+
109+
Thanks for helping!

0 commit comments

Comments
 (0)