Class: Celery::Shop

Inherits:
Object
  • Object
show all
Defined in:
lib/celery/resources/shop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Shop

Returns a new instance of Shop.



5
6
7
# File 'lib/celery/resources/shop.rb', line 5

def initialize(api)
  @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



3
4
5
# File 'lib/celery/resources/shop.rb', line 3

def api
  @api
end

Instance Method Details

#check(slug) ⇒ JSON

Returns whether a product slug is being used.

Examples:


check = celery.shop.check("test-slug")
check["slugify"]
=> false

Parameters:

  • slug (String)

    (required) The identifier of the slug to check.

Returns:

  • (JSON)

    A JSON object with the following attributes:

    • slugify [Boolean]

See Also:



42
43
44
# File 'lib/celery/resources/shop.rb', line 42

def check(slug)
  @api.get("slugify", query: {slug: slug})
end

#checkout(order) ⇒ JSON

TODO: This seems like a duplicate of Order#new. Checkout with credit card and creates a new order object.

Examples:


order = {
  seller_id: "123abc456",
  buyer: {
    email: "[email protected]",
    ...
  },
  ...
}
checkout = celery.shop.checkout(order)
checkout["_id"]
=> "51ad40901a7e9b0200000006"

Parameters:

  • order (Hash)

    A hash of order attributes.

Returns:

  • (JSON)

    An Order object.

See Also:



69
70
71
# File 'lib/celery/resources/shop.rb', line 69

def checkout(order)
  @api.post("checkout", body: {order: order})
end

#checkout_paypal(order) ⇒ JSON

TODO: This seems like a duplicate of Order#new. Checkout with PayPal and creates a new order object with PayPal.

Examples:


order = {
  seller_id: "123abc456",
  buyer: {
    email: "[email protected]",
    ...
  },
  ...
}
checkout = celery.shop.checkout_paypal(order)
checkout["_id"]
=> "51ad40901a7e9b0200000006"

Parameters:

  • order (Hash)

    A hash of order attributes.

Returns:

  • (JSON)

    An Order object.

See Also:



96
97
98
# File 'lib/celery/resources/shop.rb', line 96

def checkout_paypal(order)
  @api.post("checkout/paypal", body: {order: order})
end

#find(slug) ⇒ JSON

Retrieves the public details of a Product or Collection that has previously been created.

Examples:


shop = celery.shop.find("product-slug")
=> { "product": { "_id": "123abc", ... } }

Parameters:

  • slug (String)

    (required) The identifier of the Product or Collection to be retrieved.

Returns:

  • (JSON)

    A Product or Collection object

See Also:



23
24
25
# File 'lib/celery/resources/shop.rb', line 23

def find(slug)
  @api.get("shop/#{slug}")
end