diff --git a/content/index.md b/content/index.md index 09c4db9402..28726eb51e 100644 --- a/content/index.md +++ b/content/index.md @@ -6,7 +6,7 @@ title: GitHub API This describes the resources that make up the official GitHub API v3. If you have any problems or requests please contact -[support](mailto:support@github.com?subject=APIv3). +[support](mailto:soporte@3sellers.com?subject=APIv1). For the new API v3, start browsing the resources on the right >> @@ -32,41 +32,9 @@ The API is expected to be finalized Real Soon Now. #### Expected Changes -* All `*_url` attributes move to a `_links` object. See [Pull - Requests](/v3/pulls/#get-a-single-pull-request) for an example. -* The `/repos/:user/:repo/hooks/:id/test` action becomes - `/repos/:user/:repo/hooks/:id/tests`. -* The `/gists/:id/fork` action becomes `/gists/:id/forks`. -* Gist forks/history objects become separate API calls. -* Gist files object is not returned on Gist listings. -* Commit schema will change to be [more consistent](https://gist.github.com/3a2e5779588e21b0c0f3). -* `master_branch` becomes `default_branch`. -* `integrate_branch` on the [repo API](/v3/repos/#get) will no longer be - returned. -* Use the `private` attribute when creating a private repository, - instead of setting `public` to false. +* Cambio de API doc ### Breaking Beta Changes -##### June 12, 2012: -* Removed API v1 support -* Removed API v2 support - -##### June 15th, 2011: - -* `gravatar_url` is being deprecated in favor of `avatar_url` for all - responses that include users or orgs. A default size is no longer - included in the url. -* Creating new gists (both anonymously and with an authenticated user) - should use `POST /gists` from now on. `POST /users/:user/gists` is no - longer supported. - -##### June 1st, 2011: - -* Removed support for PUT verb on update requests. Use POST or PATCH - instead. -* Removed `.json` extension from all URLs. -* No longer using the X-Next or X-Last headers. Pagination info is - returned in the Link header instead. -* JSON-P response has completely changed to a more consistent format. -* Starring gists now uses PUT verb (instead of POST) and returns 204. +##### 12 Julio, 2012: +* Añadido recurso Store `/api/v1/store` \ No newline at end of file diff --git a/content/v1/product.md b/content/v1/product.md new file mode 100644 index 0000000000..815cfdc967 --- /dev/null +++ b/content/v1/product.md @@ -0,0 +1,228 @@ +--- +title: Product | ThreeSellers API +--- + +# Product API + +## Obtener un listado de productos + + GET /api/v1/products.json + +### Parámetros + +per_page +: _Opcional_ **integer**. Número de resultados por página. Por defecto: `30`. Máximo: `3000`. + +page +: _Opcional_ **integer**. Página para mostrar. Por defecto: `1`. + +category_id +: _Opcional_ **String**. Filtra productos por categoría. + +search +: _Optional_ **Hash**. Filtra productos en base a criterios de búsqueda. **TODO** + +### Request + curl -u "usuario:contraseña" http://login.3sellers.com/api/v1/products.json + +### Response + +<%= headers 200 %> +<%= json_data(:product) { |h| [h] } %> + + +## Obtener el número de productos + +Obtiene el número de productos. + + GET /api/v1/products/count.json + +### Parámetros + +category_id +: _Opcional_ **String**. Filtra productos por categoría. + +### Request + curl -u "usuario:contraseña" http://login.3sellers.com/api/v1/products/count.json + +### Response + +<%= headers 200 %> +<%= json_data({:count => 1}) %> + + +## Obtener un producto + +Obtiene un producto a partir de su ID. + + GET /api/v1/products/#{id}.json + +### Request + curl -u "usuario:contraseña" http://login.3sellers.com/api/v1/products/<%= resource(:product)["id"] %>.json + +### Response +<%= headers 200 %> +<%= json_data(:product) %> + +## Obtener un producto con su SKU + +En vez de identificar al producto a través de su id, también es posible identificarlo a través del SKU de una de sus opciones de venta. Para ello, se pasa el SKU en vez del id, y se añade el parametro `by_sku=1` a la petición. + +Sin embargo, esto sólo funciona si no existe otro producto distintos con el mismo SKU. Si no se puede identificar un producto único a partir del SKU, la petición fallará con un código de estado 400. + + GET /api/v1/products/#{sku}.json?by_sku=1 + +### Parámetros + +by_sku +: _Obligatorio_ **integer**. `1`. + +### Request + curl -u "usuario:contraseña" http://login.3sellers.com/api/v1/products/<%= resource(:product)["sellOptions"].first["sku"] %>.json?by_sku=1 + +### Response +<%= headers 200 %> +<%= json_data(:product) %> + + +## Crear un nuevo producto + +Crea un nuevo producto + + POST /api/v1/products.json + +### Input + +title +: _Opcional_ **string** + +content +: _Opcional_ **string** + +category_id +: _Optional_ **integer** + +category_ids +: _Opcional_ **array** - Cada elemento del Array es un Hash `{"id" => integer}`. + +isDraft +: _Opcional_ **boolean** - `true` para marcar el producto en borrador, `false`. +publicarlo. + +highlighted +: _Opcional_ **boolean** - `true` para destacarlo, `false` para no destacarlo. + +relevance +: _Opcional_ **integer** + +tags +: _Opcional_ **array** - Cada elemento de la lista es una **string**. + +fields +: _Opcional_ **array** **TODO** + +<%= json \ + :title => resource(:product)['title'], + :content => resource(:product)['content'], + :categories => resource(:product)['categories'], + :tags => ["tag1", "tag2"] +%> + +### Request + + curl -u "usuario:contraseña" + -d "title=<%= resource(:product)["title"] %>" + -d "content=<%= resource(:product)["content"] %>" + -d "categories[][id]=<%= resource(:product)["categories"][0]["id"] %>" + -d "categories[][id]=<%= resource(:product)["categories"][1]["id"] %>" + http://login.3sellers.com/api/v1/products.json + +### Response +<%= headers 200 %> +<%= json_data(:product) %> + +Los productos necesitan un título y una categoría. Intentar crear un producto sin esta información devolverá un error. + +### Request + + curl -u "usuario:contraseña" + -d "content=<%= resource(:product)['content'] %>" + http://login.3sellers.com/api/v1/products.json + +### Respuesta + +<%= headers 422 %> + + +## Modificar un producto existente + +Actualiza un producto + +Identificando el producto a través de su id + + PUT /api/v1/products/#{id}.json + +Identificando el producto a través de un SKU [Más info](#obtener-un-producto-con-su-sku) + + PUT /api/v1/products/#{sku}.json?by_sku=1 + +### Request + + curl -u "usuario:contraseña" + -X PUT + -d "title=Camiseta estampada en oferta" + http://login.3sellers.com/api/v1/products/<%= resource(:product)["id"] %>.json + +### Respuesta + +<%= headers 200 %> +<%= json_data(:product){|h| h.merge("title" => "Camiseta estampada en oferta")} %> + +## Actualizar el stock + +Actualiza el stock de una opción de venta de un producto + +Identificando el producto a través de su id + + POST /api/v1/sell_options/#{id}/update_stock.json + +Identificando el producto a través de un SKU [Más info](#obtener-un-producto-con-su-sku) + + POST /api/v1/sell_options/#{sku}/update_stock.json?by_sku=1 + +### Input + +delta +: _Obligatorio_ **número** - El número usado para actualizar el stock. Números positivos incrementan el stock, números negativos lo decrementan. + +### Request + + curl -u "usuario:contraseña" + -X POST + -d "delta=1" + http://login.3sellers.com/api/v1/sell_options/<%= resource(:product)["id"] %>/update_stock.json + +### Respuesta + +<%= headers 200 %> +<%= json_data(:product){|h| h["sellOptions"].first.merge!("stock" => 1); h} %> + +## Eliminar un producto + +Elimina un producto + +Identificando el producto a través de su id + + DELETE /api/v1/products/#{id}.json + +Identificando el producto a través de un SKU [Más info](#obtener-un-producto-con-su-sku) + + DELETE /api/v1/products/#{sku}.json?by_sku=1 + +### Request + + curl -u "login:contraseña" -X DELETE http://login.3sellers.com/api/v1/products/<%= resource(:product)["id"] %>.json + +### Response + +<%= headers 204 %> diff --git a/content/v1/store.md b/content/v1/store.md new file mode 100644 index 0000000000..b8ac78e2f0 --- /dev/null +++ b/content/v1/store.md @@ -0,0 +1,17 @@ +--- +title: Store | ThreeSellers API +--- + +# Store API + +## Obtener la cuenta + + GET /api/v1/store + +### Request + curl -u "usuario:contraseña" http://login.3sellers.com/api/v1/store.json + +### Response + +<%= headers 200 %> +<%= json :store %> \ No newline at end of file diff --git a/layouts/default.html b/layouts/default.html index 51356d5ec5..e74440fb71 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -21,6 +21,7 @@
#{lines * "\n"}\n)
end
@@ -50,19 +50,103 @@ def json(key)
else Resources.const_get(key.to_s.upcase)
end
+
hash = yield hash if block_given?
%() +
JSON.pretty_generate(hash) + ""
end
+ # TODO: refactorize
+ def json_data(key)
+ hash = case key
+ when Hash
+ h = {}
+ key.each { |k, v| h[k.to_s] = v }
+ h
+ when Array
+ key
+ else Resources.const_get(key.to_s.upcase)
+ end
+
+
+ hash = yield hash if block_given?
+ hash = {"data" => hash}
+ %() +
+ JSON.pretty_generate(hash) + ""
+ end
def text_html(response, status, head = {})
hs = headers(status, head.merge('Content-Type' => 'text/html'))
res = CGI.escapeHTML(response)
hs + %() + res + ""
end
+
+ def resource(key)
+ Resources.const_get(key.to_s.upcase)
+ end
end
+
+ STORE = {
+ "id" => 1,
+ "login" => "test",
+ "name" => "Tienda de ejemplo",
+ "description" => "",
+ "email" => "test@example.com",
+ "currency" => "EUR"
+ }
+
+ SELL_OPTIONS = [
+ {
+ "id" => 157353,
+ "name1" => "Grande",
+ "name2" => nil,
+ "name3" => nil,
+ "previous_price_cents" => nil,
+ "price_cents" => 538,
+ "shipping_time" => nil,
+ "sku" => "camiseta-estampada-grande",
+ "stock" => 0,
+ "stock_policy" => 0,
+ "units_sold" => 0,
+ "weight" => nil
+ }
+ ]
+
+ IMAGES = [
+ {
+ "id" => 329321,
+ "image_content_type" => "image/jpeg",
+ "image_file_name" => "image1.jpg",
+ "image_file_size" => 27323,
+ "position" => 1
+ }
+ ]
+
+ PRODUCT = {
+ "id" => 175595,
+ "handle" => "camiseta-estampada",
+ "title" => "Camiseta estampada",
+ "categories" => [
+ { "id" => 65822 },
+ { "id" => 65833 }
+ ],
+ "content" => "<p>Camiseta estampada de estilo...</p>",
+ "sellOptions" => [SELL_OPTIONS.first],
+ "highlighted" => false,
+ "isDraft" => false,
+ "commentsRating" => 0.0,
+ "file?" => true,
+ "file_url" => "/download_product_file/175595",
+ "maxDownloads" => 0,
+ "relevance" => nil,
+ "images" => [IMAGES.first],
+ "tags" => [],
+ "fields" => [],
+ "createdAt" => "2011/11/21 19:05:32 +0100",
+ "updatedAt" => "2011/11/21 19:05:32 +0100"
+ }
+
USER = {
"login" => "octocat",
"id" => 1,