The interface to the Veeqo API (In development)
Ruby Shell
Latest commit 236284a Jan 15, 2017 @abunashir Remove `list` related spec duplications
The `.list` API supports one additional parameter, which can be
used to filter the listing, but we are repeating that in every
resources's `list` spec, which is kind of a duplication.

Now that we have moved `list` action to a module, so it makes
more sense to move those `list` specific edge cases a spec that
will test that module.

README.md

Veeqo

Build
Status Code
Climate

The Interface to the Veeqo API

Installation

Add this line to your application's Gemfile:

gem "veeqo", github: "abunashir/veeqo"

And then execute:

bundle install

Configure

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"

Usage

Order

Resources related to the orders in the API.

List orders

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

# 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",
}

View an order details

Veeqo::Order.find(order_id)

Update order details

Veeqo::Order.update(order_id, new_attributes)

Delete an order

Veeqo::Order.delete(order_id)

Product

Resources related to the products in the API.

List all products

Veeqo::Product.list(
  since_id: 123_45, page: 1, page_size: 12
)

Create a new product

# 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",
}

View a product details

Veeqo::Product.find(product_id)

Update product details

Veeqo::Product.update(product_id, new_attributes)

Delete a product

Veeqo::Product.delete(product_id)

Purchase Orders

Resources related to the purchase orders in the API.

List purchase orders

Veeqo::PurchaseOrder.list(
  page: 1, page_size: 12, show_complete: false
)

Suppliers

Resources related to the suppliers in the API.

List all suppliers

Veeqo::Supplier.list(page: 1, page_size: 12)

Create a new supplier

Veeqo::Supplier.create(name: "ACME")

View a supplier details

Veeqo::Supplier.find(supplier_id)

Update a supplier details

Veeqo::Supplier.update(supplier_id, new_attributes_hash)

Delete a supplier

Veeqo::Supplier.delete(supplier_id)

Company

Information about current company

View company details

Veeqo::Company.find

Update company details

Veeqo::Company.update(new_attributes_hash)

Warehouse

Resources related to the warehouses in the API.

List all warehouses

Veeqo::Warehouse.list(page: 1, page_size: 12)

Create a new warehouse

Veeqo::Warehouse.create(name: "My Warehouse")

View a warehouse details

Veeqo::Warehouse.find(warehouse_id)

Update a warehouse details

Veeqo::Warehouse.update(warehouse_id, new_attributes_hash)

Delete a warehouse

Veeqo::Warehouse.delete(warehouse_id)

Customer

Resources related to the customers in the API.

List all customers

Veeqo::Customer.list(page: 1, page_size: 12)

Create a customer

Veeqo::Customer.create(
  email: "customer@example.com",
  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",
  }
)

View a customer details

Veeqo::Customer.find(customer_id)

Update a customer details

Veeqo::Customer.update(
  customer_id, new_attributes_hash
)

Delete a customer

Veeqo::Customer.delete(customer_id)

Store

Resources related to the stores in the API.

List all stores

Veeqo::Store.list(page: 1, page_size: 12)

Create a new store

Veeqo::Store.create(name: "Phone", type_code: "direct")

View a store details

Veeqo::Store.find(store_id)

Update a store details

Veeqo::Store.update(store_id, new_attributes_hash)

Delete a store

Veeqo::Store.delete(store_id)

Delivery Method

Resources related to the delivery methods in the API

List all delivery methods

Veeqo::DeliveryMethod.list(page: 1, page_size: 12)

Create a delivery method

Veeqo::DeliveryMethod.create(name: "Next Day Delivery")

View a delivery method details

Veeqo::DeliveryMethod.find(delivery_method_id)

Update a delivery method

Veeqo::DeliveryMethod.update(delivery_method_id, new_attributes_hash)

Delete a delivery method

Veeqo::DeliveryMethod.delete(delivery_method_id)

Shipment

Information about creating shipments in the API. Please follow the shipment doc regarding the carrier_id or other details.

Create a shipment

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

Delete a shipment

Veeqo::Shipment.delete(shipment_id)

Development

We are following Sandi Metz's Rules for this gem, you can read the description of the rules here. 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.

Setup

Clone the repository.

git clone https://github.com/abunashir/veeqo

Setup your environment.

bin/setup

Run the test suite

bin/rspec

Play Box

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/abunashir/veeqo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.