Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

customerlobby / service_m8   ruby

Repository URL to install this package:

  lib
5y   .gitignore
5y   Gemfile
5y   Gemfile.lock
5y   LICENSE.txt
5y   README.md
5y   Rakefile
5y   TESTING.md
5y   service_m8.gemspec
  README.md

ServiceM8

A Ruby wrapper for the ServiceM8 REST API.

Installation

Add this line to your application's Gemfile:

gem 'service_m8'

And then execute:

$ bundle

Or install it yourself as:

$ gem install service_m8

Usage

Configuration

Before you can make calls to ServiceM8 you must configure the library with a valid email & password or a valid OAuth access token.

There are two ways to configure the gem. You can pass a hash of configuration options when you create a client, or you can use a configure block.

Using an OAuth access token:

client = ServiceM8.client(access_token: "YOUR_ACCESS_TOKEN_HERE")

Using a Basic access authentication:

ServiceM8.configure do |config|
  config.email = "YOUR_EMAIL_HERE"
  config.password = "YOUR_PASSWORD_HERE"
end

Using OAuth access token

ServiceM8.configure do |config|
  config.access_token = 'ACCESS_TOKEN'
end

Create ServiceM8 client

client = ServiceM8.client

Get customers

get specific client details

client.client('CLIENT_UUID')

get all the clients

client.clients

get clients by page, first page cursor value will always be -1 and next page cursor value can be obtained from current page response

client.clients(cursor: -1)

filter clients by date

client.clients(filter: 'edit_date gt 2017-01-01')

filter clients by date and get all the records by page

client.clients(cursor: 'NEXT_CURSOR_VALUE_FROM_RESPONSE', filter: 'edit_date gt 2017-01-01')

Get customer contacts

get specific client's contact details

client.company_contacts(filter: 'company_uuid eq CLIENT_UUID')

get all the client's contacts

client.company_contacts

Get jobs

get specific job details

client.job('JOB_UUID')

get all the jobs

client.jobs

get all the jobs by page: first page cursor value will always be -1 and next page cursor value can be obtained from current page response

client.jobs(cursor: -1)

filter jobs by date

client.jobs(filter: 'date gt 2017-02-02')

filter jobs by date and get all the records by page

client.jobs(cursor: 'NEXT_CURSOR_VALUE_FROM_RESPONSE', filter: 'date gt 2017-02-02')

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request