Module: BlommingApi::BuyEndpoints

Included in:
Client
Defined in:
lib/blomming_api/buy_endpoints.rb

Instance Method Summary collapse

Instance Method Details

#carts_add(*skus, cart_id, params) ⇒ Object

Add multiple SKUs to the Cart.

params:

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

example:

data = blomming.carts_add(608394, 608390, cart_id, {})


54
55
56
57
58
59
60
61
62
63
64
# 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 = {}) ⇒ Object

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", {})


185
186
187
188
189
190
191
192
193
194
195
# 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 = {}) ⇒ Object

Remove all SKUs from the Cart.

params:

:cart_id => Cart Identifier (numeric)


95
96
97
98
99
100
101
102
103
# 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 = {}) ⇒ Object

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)



18
19
20
21
22
23
24
25
26
27
28
# 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 = {}) ⇒ Object

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

:cart_id => Cart Identifier (numeric)



35
36
37
38
39
40
41
42
# 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 = {}) ⇒ Object

Complete a PayPal transaction



200
201
202
203
204
205
206
207
208
209
210
# 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) ⇒ Object

Remove multiple SKUs from the Cart.

params:

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

example:

data = blomming.carts_remove(608394, 608390, cart_id, {})


77
78
79
80
81
82
83
84
85
86
87
# 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 = {}) ⇒ Object

Returns countries to which this Cart can be shipped to.

params:

:cart_id => Cart Identifier (numeric)


111
112
113
114
115
116
117
118
# 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 = {}) ⇒ Object

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", {})


148
149
150
151
152
153
154
155
# 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 = {}) ⇒ Object

Returns the categories



221
222
223
224
225
226
227
228
# 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 = {}) ⇒ Object

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



233
234
235
236
237
238
239
240
# 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 = {}) ⇒ Object

Returns the Items of a shop.



262
263
264
265
266
267
268
269
# 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 = {}) ⇒ Object

Returns the collections



250
251
252
253
254
255
256
257
# 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 = {}) ⇒ Object

Get the full list of the possible Countries, localized.



279
280
281
282
283
284
285
286
# 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 = {}) ⇒ Object

Returns currencies accepted by Blomming



296
297
298
299
300
301
302
303
# 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 = {}) ⇒ Object

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



313
314
315
316
317
318
319
320
# 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

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



325
326
327
328
329
330
331
332
# File 'lib/blomming_api/buy_endpoints.rb', line 325

def items_featured(params={})
  url = api_url "/items/featured"
  req = request_params({currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do 
    RestClient.get url, req
  end     
end

#items_hand_picked(params = {}) ⇒ Object

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



337
338
339
340
341
342
343
344
# 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 = {}) ⇒ Object

Returns the Items with the specified ids.



349
350
351
352
353
354
355
356
# 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 = {}) ⇒ Object

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



361
362
363
364
365
366
367
368
# 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

#items_search(keyword, params = {}) ⇒ Object

Search Blomming for items that respond to a query.



373
374
375
376
377
378
379
380
# File 'lib/blomming_api/buy_endpoints.rb', line 373

def items_search (keyword, params={})
  url = api_url "/items/search"
  req = request_params({q: keyword, currency: @currency, locale: @locale}.merge(params))
  
  feed_or_retry do 
    RestClient.get url, req
  end  
end

#macrocategories(params = {}) ⇒ Object

Returns the Macrocategories



390
391
392
393
394
395
396
397
# 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 = {}) ⇒ Object

Returns the Categories included in the given Macrocategory.



402
403
404
405
406
407
408
409
# 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 = {}) ⇒ Object

Returns the Items inside a Macrocategory.



414
415
416
417
418
419
420
421
# 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 = {}) ⇒ Object

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.



434
435
436
437
438
439
440
441
# 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 = {}) ⇒ Object

Retruns the provinces list for a given Country.



452
453
454
455
456
457
458
# 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 = {}) ⇒ Object

Returns the details of an Item.



495
496
497
498
499
500
501
# 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 = {}) ⇒ Object

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.



481
482
483
484
485
486
487
488
489
490
# 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 = {}) ⇒ Object

Returns the Shops list



468
469
470
471
472
473
474
# 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 = {}) ⇒ Object

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.



508
509
510
511
512
513
514
# 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 = {}) ⇒ Object

Retrieve the tags.



524
525
526
527
528
529
530
# 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 = {}) ⇒ Object

Returns the Items with a specific tag.



535
536
537
538
539
540
541
# 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