module BlommingApi::BuyEndpoints

Public Instance Methods

carts_add(*skus, cart_id, params) click to toggle source

Add multiple SKUs to the Cart.

params:

:*skus => SKU list 
:cart_id => Cart Identifier (numeric)

example:

data = blomming.carts_add(608394, 608390, cart_id, {})
# File lib/blomming_api/buy_endpoints.rb, line 54
def carts_add(*skus, cart_id, params)
  url = api_url "/carts/#{cart_id}/add"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  # with a hash sends parameters as a urlencoded form body
  load = {skus: skus.join(','), multipart: true}

  feed_or_retry do
    RestClient.put url, load, req
  end  
end
carts_checkout_order(cart_id, order, payment_type, params={}) click to toggle source

Checkout of the Cart.

example:

order = {

ship_to_first_name: "Andrea",
ship_to_last_name: "Salicetti",
ship_to_address: "via%20Teodosio%2065",
ship_to_postal_code: 20100,
ship_to_city: "Milano",
ship_to_province: "MI",
ship_to_country: "Italy",
bill_is_ship: "false",
bill_to_first_name: "Nicola%20Junior",
bill_to_last_name: "Vitto",
bill_to_address: "via%20Teodosio%2065",
bill_to_postal_code: "20100",
bill_to_city: "Milano",
bill_to_province: "MI",
bill_to_country: "Italy",
bill_to_company: "Blomming%20SpA",
bill_to_vat_number: "IT07199240966",
phone_number3: ""

}

data = blomming.carts_checkout_order(608394, order, "MOO", {})
# File lib/blomming_api/buy_endpoints.rb, line 185
def carts_checkout_order(cart_id, order, payment_type, params={})
  url = api_url "/carts/#{cart_id}/checkout/#{payment_type}"
  req = request_params({currency: @currency, locale: @locale}.merge(params))

  # with a hash sends parameters as a urlencoded form body
  load = {order: order, multipart: true}
  
  feed_or_retry do
    RestClient.post url, load, req
  end  
end
carts_clear(cart_id, params={}) click to toggle source

Remove all SKUs from the Cart.

params:

:cart_id => Cart Identifier (numeric)
# File lib/blomming_api/buy_endpoints.rb, line 95
def carts_clear(cart_id, params={})
  url = api_url "/carts/#{cart_id}/clear"
  req = request_params({currency: @currency, locale: @locale}.merge(params))

  feed_or_retry do
    # PUT with a hash sends parameters as a urlencoded form body ?
    RestClient.put url, req
  end  
end
carts_create(sku_id, params={}) click to toggle source

Create a new Cart on the server, as present in the home page of the web site. It also redirects to the Cart URL.

:sku_id => SKU identifier (numeric)

# File lib/blomming_api/buy_endpoints.rb, line 18
def carts_create(sku_id, params={})
  url = api_url "/carts"
  req = request_params({currency: @currency}.merge(params)) 
    
  # with a hash sends parameters as a urlencoded form body
  load = {sku_id: sku_id, multipart: true}

  feed_or_retry do
    RestClient.post url, load, req
  end  
end
carts_find(cart_id, params={}) click to toggle source

Returns the Cart with the given ID, as returned from the create cart API.

:cart_id => Cart Identifier (numeric)

# File lib/blomming_api/buy_endpoints.rb, line 35
def carts_find(cart_id, params={})
  url = api_url "/carts/#{cart_id}"
  req = request_params({currency: @currency, locale: @locale}.merge(params))

  feed_or_retry do
    RestClient.get url, req
  end  
end
carts_place_paypal_order(cart_id, order_id, paypal_token, paypal_payer_id, params={}) click to toggle source

Complete a PayPal transaction

# File lib/blomming_api/buy_endpoints.rb, line 200
def carts_place_paypal_order(cart_id, order_id, paypal_token, paypal_payer_id, params={})
  url = api_url "/carts/#{cart_id}/order/#{order_id}/place_paypal"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  # with a hash sends parameters as a urlencoded form body
  load = {token: paypal_token, PayerID: paypal_payer_id, multipart: true}

  feed_or_retry do
    RestClient.post url, load, req
  end  
end
carts_remove(*skus, cart_id, params) click to toggle source

Remove multiple SKUs from the Cart.

params:

:*skus => SKU list 
:cart_id => Cart Identifier (numeric)

example:

data = blomming.carts_remove(608394, 608390, cart_id, {})
# File lib/blomming_api/buy_endpoints.rb, line 77
def carts_remove(*skus, cart_id, params)
  url = api_url "/carts/#{cart_id}/remove"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  # with a hash sends parameters as a urlencoded form body
  load = {skus: skus.join(','), multipart: true}

  feed_or_retry do
    RestClient.put url, load, req
  end  
end
carts_shipping_countries(cart_id, params={}) click to toggle source

Returns countries to which this Cart can be shipped to.

params:

:cart_id => Cart Identifier (numeric)
# File lib/blomming_api/buy_endpoints.rb, line 111
def carts_shipping_countries(cart_id, params={})
  url = api_url "/carts/#{cart_id}/shipping_countries"
  req = request_params({currency: @currency, locale: @locale}.merge(params))

  feed_or_retry do
    RestClient.get url, req
  end  
end
carts_validate_order(cart_id, order, payment_type, params={}) click to toggle source

Returns the Cart with the given ID, as returned from the create cart API.

example:

order = {

ship_to_first_name: "Andrea",
ship_to_last_name: "Salicetti",
ship_to_address: "via%20Teodosio%2065",
ship_to_postal_code: 20100,
ship_to_city: "Milano",
ship_to_province: "MI",
ship_to_country: "Italy",
bill_is_ship: "false",
bill_to_first_name: "Nicola%20Junior",
bill_to_last_name: "Vitto",
bill_to_address: "via%20Teodosio%2065",
bill_to_postal_code: "20100",
bill_to_city: "Milano",
bill_to_province: "MI",
bill_to_country: "Italy",
bill_to_company: "Blomming%20SpA",
bill_to_vat_number: "IT07199240966",
phone_number3: ""

}

data = blomming.carts_validate_order(608394, order, "MOO", {})
# File lib/blomming_api/buy_endpoints.rb, line 148
def carts_validate_order(cart_id, order, payment_type, params={})
  url = api_url "/carts/#{cart_id}/validate/#{payment_type}"
  req = request_params({order: order, currency: @currency, locale: @locale}.merge(params))

  feed_or_retry do
    RestClient.get url, req
  end  
end
categories(params={}) click to toggle source

Returns the categories

# File lib/blomming_api/buy_endpoints.rb, line 221
def categories(params={})
  url = api_url "/categories"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
category_items(category_id, params={}) click to toggle source

Returns all the Items (paged) belonging to a certain category.

# File lib/blomming_api/buy_endpoints.rb, line 233
def category_items (category_id, params={})
  url = api_url "/categories/#{category_id}/items" 
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end    
end
collection_items(collection_id, params={}) click to toggle source

Returns the Items of a shop.

# File lib/blomming_api/buy_endpoints.rb, line 262
def collection_items (collection_id, params={})
  url = api_url "/collections/#{collection_id}/items"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
collections(params={}) click to toggle source

Returns the collections

# File lib/blomming_api/buy_endpoints.rb, line 250
def collections(params={})
  url = api_url "/collections"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req 
  end  
end
countries(params={}) click to toggle source

Get the full list of the possible Countries, localized.

# File lib/blomming_api/buy_endpoints.rb, line 279
def countries(params={})
  url = api_url "/countries"
  req = request_params({locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
currencies(params={}) click to toggle source

Returns currencies accepted by Blomming

# File lib/blomming_api/buy_endpoints.rb, line 296
def currencies(params={})
  url = api_url "/currencies"
  req = request_params({locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
items_discounted(params={}) click to toggle source

Returns the “discounted” Items, as present in the home page of the web site

# File lib/blomming_api/buy_endpoints.rb, line 313
def items_discounted(params={})
  url = api_url "/items/discounted"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do 
    RestClient.get url, req
  end  
end
items_hand_picked(params={}) click to toggle source

Returns the “hand picked” Items, as present in the home page of the web site.

# File lib/blomming_api/buy_endpoints.rb, line 337
def items_hand_picked(params={})
  url = api_url "/items/hand_picked"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end   
end
items_list(item_id, params={}) click to toggle source

Returns the Items with the specified ids.

# File lib/blomming_api/buy_endpoints.rb, line 349
def items_list (item_id, params={})
  url = api_url "/items/list"
  req = request_params({id: item_id, currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
items_most_liked(params={}) click to toggle source

Returns the “most_liked” Items, as present in the home page of the web site.

# File lib/blomming_api/buy_endpoints.rb, line 361
def items_most_liked(params={})
  url = api_url "/items/most_liked"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
macrocategories(params={}) click to toggle source

Returns the Macrocategories

# File lib/blomming_api/buy_endpoints.rb, line 390
def macrocategories(params={})
  url = api_url "/macrocategories"
  req = request_params({locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end  
end
macrocategory_categories(macrocategory_id​, params={}) click to toggle source

Returns the Categories included in the given Macrocategory.

# File lib/blomming_api/buy_endpoints.rb, line 402
def macrocategory_categories (macrocategory_id​, params={})
  url = api_url "/macrocategories​/#{macrocategory_id}​/categories" 
  req = request_params({locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end    
end
macrocategory_items(macrocategory_id​, params={}) click to toggle source

Returns the Items inside a Macrocategory.

# File lib/blomming_api/buy_endpoints.rb, line 414
def macrocategory_items (macrocategory_id​, params={})
  url = api_url "/macrocategories​/#{macrocategory_id}/items" 
  req = request_params({locale: @locale}.merge(params))
  
  feed_or_retry do
    RestClient.get url, req
  end    
end
password_resets(email_of_user, params={}) click to toggle source

Perform a password reset request to Blomming. If it does succeed, an email is sent to the user with the link to renew his passowrd for Blomming.

# File lib/blomming_api/buy_endpoints.rb, line 434
def password_resets (email_of_user, params={})
  url = api_url "/password_resets"    
  
  feed_or_retry do
    # payload JSON ?
    RestClient.post url, {email_of_user: email_of_user}.merge(params)
  end  
end
provinces(province_country_code, params={}) click to toggle source

Retruns the provinces list for a given Country.

# File lib/blomming_api/buy_endpoints.rb, line 452
def provinces (province_country_code, params={})
  url = api_url "/provinces/#{province_country_code}"    
  
  feed_or_retry do 
    RestClient.get url, request_params(params)
  end  
end
shop_item(shop_id, item_id, params={}) click to toggle source

Returns the details of an Item.

# File lib/blomming_api/buy_endpoints.rb, line 495
def shop_item (shop_id, item_id, params={})
  url = api_url "/shops/#{shop_id}/items/#{item_id}"
  
  feed_or_retry do
    RestClient.get url, request_params(params)
  end  
end
shop_items(shop_id, params={}) click to toggle source

Returns the Items of a Shop. :shop_id is the Shop id (the User’s login owner of the Shop) as returned from the /shops endpoint.

# File lib/blomming_api/buy_endpoints.rb, line 481
def shop_items (shop_id, params={})
  url = api_url "/shops/#{shop_id}/items"
  
  data = feed_or_retry  do
    RestClient.get url, request_params(params)
  end

  #puts_response_header(__method__, data) if @verbose
  data
end
shops(params={}) click to toggle source

Returns the Shops list

# File lib/blomming_api/buy_endpoints.rb, line 468
def shops (params={})
  url = api_url "/shops"
  
  feed_or_retry do
    RestClient.get url, request_params(params)
  end  
end
shops_find(shop_id, params={}) click to toggle source

Get the details of a single Shop. :id is the Shop id (the User’s login owner of the Shop) as returned from the /shops endpoint.

# File lib/blomming_api/buy_endpoints.rb, line 508
def shops_find (shop_id, params={})
  url = api_url "/shops/#{shop_id}"
  
  feed_or_retry do
    RestClient.get url, request_params(params)
  end  
end
tags(params={}) click to toggle source

Retrieve the tags.

# File lib/blomming_api/buy_endpoints.rb, line 524
def tags (params={})
  url = api_url "/tags"
  
  feed_or_retry do 
    RestClient.get url, request_params(params)
  end  
end
tags_items(tag_id, params={}) click to toggle source

Returns the Items with a specific tag.

# File lib/blomming_api/buy_endpoints.rb, line 535
def tags_items (tag_id, params={})
  url = api_url "/tags/#{tag_id}/items"
  
  feed_or_retry do
    RestClient.get url, request_params(params)
  end  
end