Mejuri's ERP integration

The ERP integration gem allows connecting to multiple ERP at the same time and query the data from these ERP's. It's currently only supporting Fulfil.

Installation

Add this line to your application's Gemfile:

  gem 'erp_integration'

Or run the following command to add ErpIntegration to your Gemfile:

  $ bundle add erp_integration

Usage

Configuration

To configure the gem, create an initializer and add the following lines:

# config/initializers/erp_integration.rb
ErpIntegration.configure do |config|
  config.fulfil_api_key = '<your-api-key>'
  config.fulfil_merchant_id = '<your-merchant-id>'
end

Supported Query Methods

After configuring the gem, one can easily query all the available ERP resources from the connected third-parties. In all cases, the API will return a collection of resources.

NOTE: If you need to lookup an individual resource take a look at the "Supported finder methods" section.

$ ErpIntegration::SalesOrder.where(reference: 'MT1000SKX')
=> [<ErpIntegration::SalesOrder @id=100 />]

There are also other type of where queries available:

  • where_like for case sensitive queries.
  • where_ilike for case insensitive queries.
  • where_not for non-equality queries.
  • where_in for inclusion queries.
  • where_not_in for exclusion queries.

Supported Finder Methods

The Query Methods allow you to lookup a list of resources. The Finder Methods allow you to lookup an individual resource from the API.

  • #find looks up a resource by id and raises ErpIntegration::ResourceNotFound when no result is found.
  • #find_by looks up a resource by a given set of query methods and returns nil when no result is found.
  • #find_by! looks up a resource by a given set of query methods and raises ErpIntegration::ResourceNotFound when no result is found.

A difference between the query methods and the finder methods is the way it's executed. The finder methods are executed directly after they're called. The query methods will be lazily executed.

$ ErpIntegration::SalesOrder.find(100)
# => #<ErpIntegration::SalesOrder @id=100 />

$ ErpIntegration::SalesOrder.find_by(code: "MT100")
# => #<ErpIntegration::SalesOrder @id=100 />

$ ErpIntegration::SalesOrder.find_by!(code: "MT100")
# => #<ErpIntegration::SalesOrder @id=100 />

Supported Selection Methods

By default, only the id will be added to ERP resources. However, one can use the select method to include more fields.

$ ErpIntegration::SalesOrder.select(:id, :reference).find_by(reference: 'MT1000SKX')
# => <ErpIntegration::SalesOrder @id=100 @reference=MT1000SKX />

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Releasing

Prerequisites

To be able to publish a new release, you'll need to set up a Rubygems account.

To begin, you’ll need to create an account on RubyGems.org. Visit the sign up page and supply an email address that you control, a handle (username) and a password.

After creating the account, use your email and password when pushing the gem. (RubyGems saves the credentials in ~/.gem/credentials for you so you only need to log in once.) Publishing to RubyGems.org

It's important to note that you'll need the right privileges to publish the gem. Ask @germansvriz or @stefanvermaas to add you as a gem owner.

Publish a new version

  1. Run the prerelease script

    $ bin/prerelease 0.0.1
    
  2. Create Pull Request

  3. Merge it to develop

  4. Run Release script

    $ bin/release 0.0.1
    

We're following semver for the release process of this gem. Make sure to apply the correct semver version for a new release.

NOTE: You don't have to add a v to the version you want to release. The release script will handle that for you.

Contributing

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

License

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

Code of Conduct

Everyone interacting in the ErpIntegration project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.