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 / field_locate_api   ruby

Repository URL to install this package:

  README.md

FieldLocateApi

A Ruby wrapper for the FieldLocate REST API.

Installation

Add this line to your application's Gemfile:

    gem 'field_locate_api'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install field_locate_api

Usage

Configuration

Before you can make calls to FieldLocateApi you must configure the library with a valid API Token. You can request a token be generated by FieldLocateApi. The API Token ties the API request to a particular FieldLocateApi company id.

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.

I) Passing hash of configuration.

client = FieldLocateApi.client({api_key: "YOUR_TOKEN_HERE"})

II) Using a configure block

FieldLocateApi.configure do |config|
  config.api_key = "YOUR_TOKEN_HERE"
end
client = FieldLocateApi.client

Logging can also be enabled by passing an optional logger.

Examples in a rails application logger = Rails.logger with a custom logger logger = Logger.new("test.log")

client = FieldLocateApi.client({api_key: "YOUR_TOKEN_HERE", logger: logger})

or

FieldLocateApi.configure do |config|
  config.api_key = "YOUR_TOKEN_HERE"
  config.logger = logger
end
client = FieldLocateApi.client

Example calls
1. Customers
i) Fetch first page of size 100 using pageStartIndex.
client.customers({pageStartIndex: 0, pageSize: 100})
  • where

    • pageSize = number of customers to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of customers.(MIN=0)
  • return a list of first 100 customers from 0 to 99

ii) Fetch second page of size 100 using pageStartIndex.
client.customers({pageStartIndex: 100, pageSize: 100})
  • where

    • pageSize = number of customers to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of customers.(MIN=0)
    • pageStartIndex = ( pageSize * (page_number -1) ) = ( 100 * (2-1) )
  • return a list of 100 customers from 100 to 199

iii) Fetch first page of size 100 using pageNumber.
client.customers({pageNumber: 1, pageSize: 100})
  • where

    • pageSize = number of customers to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of first 100 customers from 0 to 99

iv) Fetch second page of size 100 using pageNumber.
client.customers({pageNumber: 2, pageSize: 100})
  • where

    • pageSize = number of customers to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of 100 customers from 100 to 199

v) Defaults
client.customers
  • where

    • pageSize = 100 (DEFAULT)
    • pageStartIndex = 0 (DEFAULT)
  • return a list of first 100 customers from 0 to 99

vi) Random pageStartIndex.
client.customers({pageSize: 50, pageStartIndex: 21})
  • where

    • pageSize = 50
    • pageStartIndex = 21
  • will return total 50 customers starting from index 21 to 70.

vii) To fetch single customer.
client.customer('CUSTOMER_UUID_HERE')
2. Invoices
i) Fetch first page of size 100 using pageStartIndex.
client.invoices({pageStartIndex: 0, pageSize: 100})
  • where

    • pageSize = number of invoices to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of invoices.(MIN=0)
  • return a list of first 100 invoices from 0 to 99

ii) Fetch second page of size 100 using pageStartIndex.
client.invoices({pageStartIndex: 100, pageSize: 100})
  • where

    • pageSize = number of invoices to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of invoices.(MIN=0)
    • pageStartIndex = ( pageSize * (page_number -1) ) = ( 100 * (2-1) )
  • return a list of 100 invoices from 100 to 199

iii) Fetch first page of size 100 using pageNumber.
client.invoices({pageNumber: 1, pageSize: 100})
  • where

    • pageSize = number of invoices to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of first 100 invoices from 0 to 99

iv) Fetch second page of size 100 using pageNumber.
client.invoices({pageNumber: 2, pageSize: 100})
  • where

    • pageSize = number of invoices to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of 100 invoices from 100 to 199

v) Defaults
client.invoices
  • where

    • pageSize = 100 (DEFAULT)
    • pageStartIndex = 0 (DEFAULT)
  • return a list of first 100 invoices from 0 to 99

vi) Random pageStartIndex.
client.invoices({pageSize: 50, pageStartIndex: 21})
  • where

    • pageSize = 50
    • pageStartIndex = 21
  • return total 50 invoices starting from index 21 to 70.

vii) To fetch single invoice.
client.invoice('INVOICE_UUID_HERE')
3. Agreements
i) Fetch first page of size 100 using pageStartIndex.
client.agreements({pageStartIndex: 0, pageSize: 100})
  • where

    • pageSize = number of agreements to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of agreements.(MIN=0)
  • return a list of first 100 agreements from 0 to 99

ii) Fetch second page of size 100 using pageStartIndex.
client.agreements({pageStartIndex: 100, pageSize: 100})
  • where

    • pageSize = number of agreements to fetch.(MAX=100)
    • pageStartIndex = start index to fetch from collection of agreements.(MIN=0)
    • pageStartIndex = ( pageSize * (page_number -1) ) = ( 100 * (2-1) )
  • return a list of 100 agreements from 100 to 199

iii) Fetch first page of size 100 using pageNumber.
client.agreements({pageNumber: 1, pageSize: 100})
  • where

    • pageSize = number of agreements to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of first 100 agreements from 0 to 99

iv) Fetch second page of size 100 using pageNumber.
client.agreements({pageNumber: 2, pageSize: 100})
  • where

    • pageSize = number of agreements to fetch.(MAX=100)
    • pageNumber = page number (MIN=1)
  • return a list of 100 agreements from 100 to 199

v) Defaults
client.agreements
  • where

    • pageSize = 100 (DEFAULT)
    • pageStartIndex = 0 (DEFAULT)
  • return a list of first 100 agreements from 0 to 99

vi) Random pageStartIndex.
client.agreements({pageSize: 50, pageStartIndex: 21})
  • where

    • pageSize = 50
    • pageStartIndex = 21
  • will return total 50 agreements starting from index 21 to 70.

vii) To fetch single agreement.
client.agreement('AGREEMENT_UUID_HERE')

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