The Ruby Interface to the Veeqo API
Add this line to your application's Gemfile:
gem "veeqo"
And then execute:
bundle install
Follow these simple steps to get up and running with the Veeqo API. Once you have your API key then you can configure it by adding an initializer with the following code
Veeqo.configure do |config|
config.api_key = "SECRET_API_KEY"
end
Or
Veeqo.configuration.api_key = "SECRET_API_KEY"
Resources related to the orders in the API.
Veeqo::Order.list(
page: 1,
page_size: 25,
since_id: since_id,
status: "awaiting_fulfillment",
created_at_min: "2017-01-01 11:10:01",
updated_at_min: "2017-01-01 11:10:01",
)
# Create a new order for customer
#
# Please pay close attention to the argumetns construction.
# Some attrbitues require some nested attributes, that's why
# we've extracted those to make it easier to understand, but
# you don't have to do it unelss you prefer a clean code :)
Veeqo::Order.create(
channel_id: store_id,
customer_id: customer_id,
delivery_method_id: deliver_method_id,
deliver_to_id: deliver_to_id,
total_discounts: 0,
total_tax: 0,
due_date: "",
send_notification_email: false,
deliver_to_attributes: deliver_to_attributes,
line_items_attributes: [line_item_one_attributes]
payment_attributes: payment_attributes,
)
# Delivery Attributes
#
# This includes the details attributes to specify the
# delivery details for that specific order.
deliver_to_attributes = {
address1: "294 queenstown road",
address2: "",
city: "london",
company: "",
country: "GB",
customer_id: customer_id,
first_name: "Sky",
last_name: "Schonhuber",
phone: "07734450718",
state: "london",
zip: "sw8 4lt",
}
# Line Item Attributes
#
# This includes the details about a specific
# Line items for the new order
line_item_one_attributes = {
price_per_unit: 13.99,
quantity: "1",
sellable_id: 1226615,
tax_rate: 0
}
# Payment Attributes
#
# Include the payment details with the order
payment_attributes = {
payment_type: "bank_transfer",
reference_number: "123456789",
}
Veeqo::Order.find(order_id)
Veeqo::Order.update(order_id, new_attributes)
Veeqo::Order.delete(order_id)
Resources related to the allocations in the API. This allocates a set of stock item to a specific order. To allocate stock to an order, the item must be added as a line item within that order and not be allocated already.
Veeqo::Allocation.create(
order_id: 123_456,
warehouse_id: 456_789,
line_items: [{
quantity: 1,
sellable_id: 123_456,
}],
)
Veeqo::Allocation.update(
allocation_id,
order_id: 123_456,
warehouse_id: 456_789,
line_items: [{
quantity: 2,
sellable_id: 123_456,
}],
)
Veeqo::Allocation.delete(order_id, allocation_id)
Resources related to the products in the API.
Veeqo::Product.list(
since_id: 123_45, page: 1, page_size: 12
)
# Create a new product
#
# Pay close attension to the argument constructions. It
# simlify the process, and the `variants` and `images`
# supports mutiple item, and we can pass those as an
# array, please check the example bellow for inspiration
Veeqo::Product.create(
title: "T Shirt",
description: "The best t-shirt!",
estimated_delivery: 3,
notes: "This is a limited addtion!",
variants: [variant_one_attributes],
images: [image_one_attributes],
)
# Variant attributes
variant_one_attributes = {
cost_price: "10",
min_reorder_level: "0",
price: "15",
quantity_to_reorder: "0",
sku_code: "t-shirt-large",
tax_rate: "0",
title: "Large",
}
# Image attributes
image_one_attributes = {
display_position: "1"
src: "http://veeqo.com/t-shirt.jpg",
}
Veeqo::Product.find(product_id)
Veeqo::Product.update(product_id, new_attributes)
Veeqo::Product.delete(product_id)
Resources related to the purchase orders in the API.
Veeqo::PurchaseOrder.list(
page: 1, page_size: 12, show_complete: false
)
Resources related to the suppliers in the API.
Veeqo::Supplier.list(page: 1, page_size: 12)
Veeqo::Supplier.create(name: "ACME")
Veeqo::Supplier.find(supplier_id)
Veeqo::Supplier.update(supplier_id, new_attributes_hash)
Veeqo::Supplier.delete(supplier_id)
Information about current company
Veeqo::Company.find
Veeqo::Company.update(new_attributes_hash)
Resources related to the warehouses in the API.
Veeqo::Warehouse.list(page: 1, page_size: 12)
Veeqo::Warehouse.create(name: "My Warehouse")
Veeqo::Warehouse.find(warehouse_id)
Veeqo::Warehouse.update(warehouse_id, new_attributes_hash)
Veeqo::Warehouse.delete(warehouse_id)
Resources related to the customers in the API.
Veeqo::Customer.list(page: 1, page_size: 12)
Veeqo::Customer.create(
email: "[email protected]",
phone: "01792 720740",
mobile: "07329023903",
billing_address_attributes: {
first_name: "John",
last_name: "Doe",
company: "FooBar Ltd",
address1: "221 High Street Lane",
city: "Swansea",
country: "GB",
zip: "SA1 1NW",
}
)
Veeqo::Customer.find(customer_id)
Veeqo::Customer.update(
customer_id, new_attributes_hash
)
Veeqo::Customer.delete(customer_id)
Resources related to the stores in the API.
Veeqo::Store.list(page: 1, page_size: 12)
Veeqo::Store.create(name: "Phone", type_code: "direct")
Veeqo::Store.find(store_id)
Veeqo::Store.update(store_id, new_attributes_hash)
Veeqo::Store.delete(store_id)
Resources related to the delivery methods in the API
Veeqo::DeliveryMethod.list(page: 1, page_size: 12)
Veeqo::DeliveryMethod.create(name: "Next Day Delivery")
Veeqo::DeliveryMethod.find(delivery_method_id)
Veeqo::DeliveryMethod.update(delivery_method_id, new_attributes_hash)
Veeqo::DeliveryMethod.delete(delivery_method_id)
Information about creating shipments in the API. Please follow the shipment doc
regarding the carrier_id
or other details.
# Create a new shipment
#
# Please pay close attention to the construciton of
# the arugments, This simplified some attrbitues, so
# the developer does not need to worry about the too
# much details on how it needs to structured.
Veeqo::Shipment.create(
order_id: 1,
allocation_id: 1,
shipment: {
carrier_id: 3,
notify_customer: false,
update_remote_order: false,
tracking_number: "12345679ABC",
},
)
Resources related to the order tags in the API.
Veeqo::Tag.list
Veeqo::Shipment.delete(shipment_id)
We are following Sandi Metz's Rules for this gem, you can read the [description of the rules here] (http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers). All new code should follow these rules. If you make changes in a pre-existing file that violates these rules you should fix the violations as part of your contribution.
Clone the repository.
git clone https://github.com/abunashir/veeqo
Setup your environment.
bin/setup
Run the test suite
bin/rspec
The API Play Box provides an interactive console so we can easily test out the actual API interaction. But before moving forward let's configure the key and API host (In case you wanna test on a mock server).
Setup the client configuration.
cp .sample.pryrc .pryrc
vim .pryrc
Start the console.
bin/console
Start playing with it.
Veeqo::Order.list
First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.
Here are a few technical guidelines to follow:
- Open an issue to discuss a new feature.
- Write tests to support your new feature.
- Make sure the entire test suite passes locally and on CI.
- Open a Pull Request.
- Squash your commits after receiving feedback.
- Party!
The gem is available as open source under the terms of the MIT License.