Celery API
Celery API wrapper
Usage
Add your celery API key.
Celery.access_token = "foo"
Products
Get all the products from the API.
Celery::Product.all
# => [#<Celery::Product @id="foo", @name="Foo bar", @slug="foo-bar">]
Create a new product
Celery::Product.create(name: 'Foo bar', price: 10000, deposit: 1000)
# => #<Celery::Product @id="foo", @name="Foo bar", @slug="foo-bar", @price=10000>
Get 1 product from the API
Celery::Product.get('foo')
# => #<Celery::Product @id="foo", @name="Foo bar", @slug="foo-bar">
Update a product
product = Celery::Product.get('foo')
product.update(name: "Bar baz")
# => true
Destroy a product
product = Celery::Product.get('foo')
product.destroy
# => true
Orders
Get all the orders from the API.
Celery::Order.all
# => [#<Celery::Order @id="foo", @buyer= #<Celery::Buyer>, @card=#<Celery::Card>, @name="Chocholate cake", @products= [#<Celery::Product>], @status="paid_balance", @subtotal=0, @taxes=0, @total=0>]
Decode an order from the confirmation page payload.
Celery::Order.decode_order(params[:order])
# => #<Celery::Order @id="foo", @buyer= #<Celery::Buyer>, @card=#<Celery::Card>, @name="Chocholate cake", @products= [#<Celery::Product>], @status="paid_balance", @subtotal=0, @taxes=0, @total=0>
User
It gets the store owner profile
user = Celery::User.me
# => #<Celery::User @_id="foo", @access_token="foo", @affirm={}, @analytics={"ga_id"=>"", "perfect_audience_id"=>""}, @business={"name"=>nil, "email"=>nil, "phone"=>nil}, @confirmation_url="", @created=1401480988785, @created_date="2014-05-30T20:16:28.785Z", @currency="usd", @email="email@example.com", @emails={}, @facebook=nil, @flags={"hide_stripe"=>false}, @has_affirm=true, @has_paypalx=false, @id="foo", @message_to_buyer=nil, @name="John Doe", @nexus=[], @notifications={}, @paypal_email="", @shipping_rates={}, @stripe={}, @subscription={}, @tax_rates={}, @twitter="", @updated=1403064604899, @updated_date="2014-06-18T04:10:04.899Z", @webhooks={}, @website=nil>
It updates the user
user = Celery::User.me
user.update(twitter: '@foo')
# => true
Roadmap
- Finish Orders and Products endpoint
- Add coupons endpoint
- Add shop endpoint
The MIT License (MIT)
Copyright (c) 2014 TangoSource LLC, QueueTechnologies Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.