Spire is a Ruby wrapper around the Spire Systems API.
This gem was inspired by ruby-trello. If you like this gem, definitely go and check it out.
Additionaly, we want to say thanks to International Safety Inc. for sponsoring a lof of the development of this gem.
If you want the latest, add this line to your application's Gemfile:
gem 'spire', git: "https://github.com/bitesite/spire-ruby", branch: "master"
OR you could grab a specific version, for example 'v2.5.0':
gem 'spire', git: "https://github.com/bitesite/spire-ruby", tag: "v2.5.0"
And then execute:
$ bundle
First you will need to configure spire. This is a global configuration. Thus it will be applied anywhere you use spire within your application.
If you are using spire within a Rails application, you could put the following config in an initializer.
Spire.configure do |config|
config.company = 'company name'
config.username = 'username' # Username of a user account within "company name"
config.password = 'xxxxxxxx' # Password of that user
config.host = 'example.com' # Location of your Spire server
end
Below are a few usage examples. For other uses, please refer to lib/item.rb
.
Will retrieve one item from Spire
Spire::Item.find(itemId)
Will search Spire for an item that matches the given query
Spire::Item.search('GF-1234')
Will retrieve many Items based on a filter from Spire
Spire::Item.filter('{"partNo":"ABCD-0001", "whse":"00"}')
Will create a new item on Spire
Spire::Item.create(options)
Will delete an item from Spire
Spire::Item.find(itemId).delete
Updates item description on Spire
item = Spire::Item.find(71)
item.description = 'This is a new description'
item.save
Below are a few usage examples. For other uses, please refer to lib/upc.rb
.
Will retrieve many UPCs based on a filter from Spire
Spire::Upc.filter('{"partNo":"ABCD-0001", "whse":"00"}')
Will retrieve one UPC from Spire
Spire::Upc.find(upcId)
Will create a new UPC on Spire
Spire::Upc.create(upc: "12345678901", uomCode: "EA", inventory: {id: 1})
Will delete a UPC from Spire
Spire::Upc.find(upcId).delete
Updates a UPC on Spire
upc = Spire::Upc.find(1)
upc.upc = '12345678902'
upc.save
Below are a few usage examples. For other uses, please refer to lib/customer.rb
.
Will retrieve one customer from Spire
Spire::Customer.find(customerId)
Will search Spire for a customer that matches the given query
Spire::Customer.search('[email protected]')
The syntax for orders is very similar to items. For additional information please refer to lib/order.rb
.
Will retrieve one order from Spire
Spire::Order.find(orderId)
Will search Spire for any order that match the given query
Spire::Order.search('[email protected]')
Will create order in Spire
Spire::Order.create({
'customer' => {'id': 'customer id'},
'address': {
'line1':'123 ABC Street',
'line2':' Unit #',
'line3':'Attention: Accounts Payable',
'line4':'Special Instructions?',
'city':'Toronto',
'postalCode':'A1A2B2',
'provState':'ON',
'country':'CAN',
},
'shippingAddress': {
'line1':'456 HIJ Dr.',
'line2':' Unit #',
'line3':'Attention: SomeOne',
'line4':'Delivery Instructions?',
'city':'Toronto',
'postalCode':'A1A2B2',
'provState':'ON',
'country':'CAN',
},
'items': [
{ 'inventory': { 'id': 93 }, 'orderQty': '2' },
{ 'inventory': { 'id': 2279 } },
{
'description': 'MAKE COMMENT THRU API',
'comment': 'MAKE COMMENT THRU API'
}
],
'discount': '4',
'freight': '14'
})
Above is the minimum param to create an order in Spire
The syntax for vendors is very similar to items. For additional information please refer to lib/vendor.rb
.
Will retrieve one vendor from Spire
Spire::Vendor.find(vendorId)
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Note '2.4.1' is being used as an example below, your version will be different.
Ensure version number is updatedTag `git tag 'v2.4.1'Push tags to GitHubgit push origin --tags
Build the gemgem build spire.gemspec
Publish to BiteSite's RubyGems accountgem push spire-2.4.1.gem
After trying to publish to rubygems.org, we realized we had a name conflict. If we changed the name of the gem, that would also affect the code that requires the top-level package. Until we're willing to release a Major version upgrade with breaking changes, we'll just have to publish via GitHub.
Until then, when we're ready to release a new version:
- On master,
git checkout master
- Make sure you have the latest changes
git pull
- Update
spire/version.rb
with a new version number following Semantic Versioning Rules. - Commit the change
git add .
andgit commit -m "Updated version number for release."
- Push changes
git push origin master
- Tag the commit
git tag 'vX.X.X'
- Push tags
git push origin --tags
Bug reports and pull requests are welcome on GitHub at https://github.com/bitesite/spire.
We do not currently support the entire Spire api. Any pull requests adding CRUD resources to this gem are appreciated.
The gem is available as open source under the terms of the MIT License.